Java Reference
In-Depth Information
conesound
ConeSound creates a sound source that has characteristics similar to using a spot or cone
light source that points at a certain direction. Basically, similar to a point sound, a cone
sound source is located at a certain position, and gives out acoustic sounds that radiates
from this position. Of course, the sound becomes weaker of get attenuated the further it
travels.
Figure 3. Cone sound source and code segment for SoundConePanel.java
1.
ConeSound cone_sound = new ConeSound();
2.
Point2f[] myFrontAtten = { new Point2f(100,1), new Point2f(350,0.5), new Point2f(600,0) };
3.
Point2f[] myBackAtten = { new Point2f(50,1), new Point2f(100,0.5), new Point2f(200,0) };
4.
Point3f[] smallAngular = { new Point3f(0,1,20000),
5.
new Point3f( (float)Math.PI/20, 0.5f, 5000.0f ), new Point3f( (float)Math.PI/10, 0.0f, 2000.0f ) };
6.
Point3f[] averageAngular = { new Point3f( 0,1,20000),
7.
new Point3f( (float)Math.PI/8, 0.5f, 5000.0f ), new Point3f( (float)Math.PI/4, 0.0f, 2000.0f ) };
8.
Point3f[] largeAngular = { new Point3f(0,1,20000),
9.
new Point3f( (float)Math.PI/4, 0.5f, 5000.0f ), new Point3f( (float)Math.PI/2, 0.0f, 2000.0f ) };
10.
11. public void addSound ()
12. {
13.
MediaContainer sample1 = new MediaContainer("file:sound files/sample1.wav");
14.
sample1.setCacheEnable(true);
15.
16.
cone_sound.setCapability(ConeSound.ALLOW_SOUND_DATA_READ);
17.
cone_sound.setCapability(ConeSound.ALLOW_SOUND_DATA_WRITE);
18.
cone_sound.setCapability(ConeSound.ALLOW_ENABLE_READ);
19.
cone_sound.setCapability(ConeSound.ALLOW_ENABLE_WRITE);
20.
cone_sound.setCapability(ConeSound.ALLOW_LOOP_READ);
21.
cone_sound.setCapability(ConeSound.ALLOW_LOOP_WRITE);
22.
cone_sound.setCapability(ConeSound.ALLOW_RELEASE_READ);
23.
cone_sound.setCapability(ConeSound.ALLOW_RELEASE_WRITE);
24.
cone_sound.setCapability(ConeSound.ALLOW_CONT_PLAY_READ);
25.
cone_sound.setCapability(ConeSound.ALLOW_CONT_PLAY_WRITE);
26.
cone_sound.setCapability(ConeSound.ALLOW_ANGULAR_ATTENUATION_READ);
27.
cone_sound.setCapability(ConeSound.ALLOW_ANGULAR_ATTENUATION_WRITE);
28.
29.
cone_sound.setSoundData(sample1);
30.
cone_sound.setInitialGain(2.0f);
31.
cone_sound.setLoop(0);
32.
cone_sound.setReleaseEnable(false);
33.
cone_sound.setContinuousEnable(false);
34.
cone_sound.setEnable(false);
35.
cone_sound.setSchedulingBounds(bounds);
36.
cone_sound.setPriority(1.0f);
37.
cone_sound.setPosition(0.0f, 0.0f, -12.5f);
38.
cone_sound.setDirection( new Vector3f( 0.0f, 0.0f, 1.0f ) );
39.
cone_sound.setDistanceGain( myFrontAtten, myBackAtten );
40.
cone_sound.setAngularAttenuation( smallAngular );
41. }
Search WWH ::




Custom Search