Java Reference
In-Depth Information
the sound rendered, and has application bounds that covers all other areas not under the
bounds of the other two Soundscapes.
Lines 25 and 26 creates a third Soundscape that simulates being in a large cavern. This
is done by have a large ReverbDelay, a unit ReflectionCoefficient and a large ReverbOrder.
The large ReverbDelay increases the lengths of echoes, a unit ReflectionCoefficient removes
the absorption of reflected sounds, and a large ReverbOrder increases the lifespan of echoes
by allowing a higher number of multiple reflections.
The use of various PointSounds and Soundscapes with different ApplicationBounds
enables us to create a 3D virtual world with sounds where the user can move around, see
objects from different perspectives, and experience the resulting positional and reverbera-
tion effects.
In the addAvatar method in Figure 5, a PointSound is added to simulate footsteps. This
is done by using a custom behavior class KeySoundBehavior, the code segment for which
is given in Figure 6. In particular, through lines 9 to 10, the pressing of a navigation key
will set the gain of the PointSound to 1 and make it audible, while the releasing of the key
will set the gain to 0 and make it inaudible. With the PointSound set to loop infinitely in
line 36 in Figure 5, an effect similar to that of footsteps is obtained.
Some screen captures for the example described are shown in Figure 4. Note that the
sphere gives the ApplicationBounds of the SoundScape, and when this intersects with the
ActivationVolume of the ViewPlatform, the AuralAttributes specified will be applied to
the sound being rendered.
Figures 7 and 8 show the code segment and screen capture in another example where
the aural or acoustical characteristics can be changed during run time. This is done by
extending the TestApplet class and using JComponent based controls. Note that in order
for the aural parameters to be varied in real-time after the objects have become live, the
appropriate capabilities have to be set.
Figure 6. Code segment for KeySoundBehavior.java
1.
public void processStimulus( Enumeration criteria ) {
2.
WakeupCriterion wakeup;
3.
AWTEvent[] event;
4.
while( criteria.hasMoreElements() ) {
5.
wakeup = (WakeupCriterion) criteria.nextElement();
6.
if( !(wakeup instanceof WakeupOnAWTEvent) ) continue;
7.
event = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
8.
for( int i = 0; i < event.length; i++ ) {
9.
if( event[i].getID() == KeyEvent.KEY_PRESSED) pSound.setInitialGain(1.0f);
10.
else if(event[i].getID() == KeyEvent.KEY_RELEASED) pSound.setInitialGain(0.0f); } }
11.
wakeupOn( keyCriterion );}
Search WWH ::




Custom Search