Java Reference
In-Depth Information
By creating an AuralAttributes object and attaching it to a SoundScape leaf node for a
certain sound in the scene graph, we can also specify the use of certain acoustical effects
in the rendering of the sound. This is done through using the various methods to change
important acoustic parameters in the AuralAttributes object.
backgroundsound
This is a subclass of the Sound class for audio and sound that are unattenuated and nonspa-
tialized. That is, similar to ambient lighting, the sound generated will not have a specific
position or direction and will be independent of where the user is in the virtual 3D world.
However, unlike a background scenery, more than one BackgroundSound node can be
enabled and played at the same time.
Figure 1. Code segment for SoundBackgroundPanel.java
1.
BackgroundSound back_sound = new BackgroundSound();
2.
3.
public void addSound ()
4.
{
5.
MediaContainer sample1 = new MediaContainer("file:sound files/sample1.wav");
6.
sample1.setCacheEnable(true);
7.
8.
back_sound.setCapability(ConeSound.ALLOW_SOUND_DATA_READ);
9.
back_sound.setCapability(ConeSound.ALLOW_SOUND_DATA_WRITE);
10.
back_sound.setCapability(ConeSound.ALLOW_ENABLE_READ);
11.
back_sound.setCapability(ConeSound.ALLOW_ENABLE_WRITE);
12.
back_sound.setCapability(ConeSound.ALLOW_LOOP_READ);
13.
back_sound.setCapability(ConeSound.ALLOW_LOOP_WRITE);
14.
back_sound.setCapability(ConeSound.ALLOW_RELEASE_READ);
15.
back_sound.setCapability(ConeSound.ALLOW_RELEASE_WRITE);
16.
back_sound.setCapability(ConeSound.ALLOW_CONT_PLAY_READ);
17.
back_sound.setCapability(ConeSound.ALLOW_CONT_PLAY_WRITE);
18.
back_sound.setSoundData(sample1);
19.
back_sound.setInitialGain(2.0f);
20.
back_sound.setLoop(0);
21.
back_sound.setReleaseEnable(false);
22.
back_sound.setContinuousEnable(false);
23.
back_sound.setEnable(false);
24.
back_sound.setSchedulingBounds(bounds);
25.
back_sound.setPriority(1.0f);
26. }
Search WWH ::




Custom Search