Java Code Examples for com.jme3.audio.AudioNode#setVolume()

The following examples show how to use com.jme3.audio.AudioNode#setVolume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelloAudio.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** We create two audio nodes. */
private void initAudio() {
  /* gun shot sound is to be triggered by a mouse click. */
  audio_gun = new AudioNode(assetManager, 
          "Sound/Effects/Gun.wav", DataType.Buffer);
  audio_gun.setPositional(false);
  audio_gun.setLooping(false);
  audio_gun.setVolume(2);
  rootNode.attachChild(audio_gun);

  /* nature sound - keeps playing in a loop. */
  audio_nature = new AudioNode(assetManager, 
          "Sound/Environment/Ocean Waves.ogg", DataType.Stream);
  audio_nature.setLooping(true);  // activate continuous playing
  audio_nature.setPositional(true);   
  audio_nature.setVolume(3);
  rootNode.attachChild(audio_nature);
  audio_nature.play(); // play continuously!
}
 
Example 2
Source File: SoundPerformer.java    From OpenRTS with MIT License 6 votes vote down vote up
@Override
public void perform(Actor a) {
	SoundActor actor = (SoundActor)a;
	AudioNode audio = actorDrawer.getAudioNode(actor.soundPath);
	audio.setPositional(actor.positional);
	if(actor.positional)
		audio.setLocalTranslation(TranslateUtil.toVector3f(actor.getParentModelActor().getPos()));
	
	audio.setLooping(actor.looping);
	audio.setVolume((float)(actor.volume));
	
	audio.setRefDistance(4);
	audio.setReverbEnabled(false);
	
	audio.playInstance();
	a.stopActing();
}
 
Example 3
Source File: HelloAudio.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** We create two audio nodes. */
private void initAudio() {
  /* gun shot sound is to be triggered by a mouse click. */
  audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
  audio_gun.setLooping(false);
  audio_gun.setVolume(2);
  rootNode.attachChild(audio_gun);

  /* nature sound - keeps playing in a loop. */
  audio_nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
  audio_nature.setLooping(true);  // activate continuous playing
  audio_nature.setPositional(true);
  audio_nature.setLocalTranslation(Vector3f.ZERO.clone());
  audio_nature.setVolume(3);
  rootNode.attachChild(audio_nature);
  audio_nature.play(); // play continuously!
}
 
Example 4
Source File: TestAmbient.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
  float[] eax = new float[]{15, 38.0f, 0.300f, -1000, -3300, 0,
    1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f, 0.00f,
    0.00f, -229, 0.088f, 0.00f, 0.00f, 0.00f, 0.125f, 1.000f,
    0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f};
  Environment env = new Environment(eax);
  audioRenderer.setEnvironment(env);

  waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg",
          DataType.Buffer);
  waves.setPositional(true);
  waves.setLocalTranslation(new Vector3f(0, 0,0));
  waves.setMaxDistance(100);
  waves.setRefDistance(5);

  nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg",
          DataType.Stream);
  nature.setPositional(false);
  nature.setVolume(3);
  
  waves.playInstance();
  nature.play();
  
  // just a blue box to mark the spot
  Box box1 = new Box(.5f, .5f, .5f);
  Geometry player = new Geometry("Player", box1);
  Material mat1 = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");
  mat1.setColor("Color", ColorRGBA.Blue);
  player.setMaterial(mat1);
  rootNode.attachChild(player);
}
 
Example 5
Source File: TestAmbient.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp()
{     
    /*
    footsteps  = new AudioNode(audioRenderer, assetManager, "Sound/Effects/Foot steps.ogg", true);
    
    footsteps.setPositional(true);
    footsteps.setLocalTranslation(new Vector3f(4, -1, 30));
    footsteps.setMaxDistance(5);
    footsteps.setRefDistance(1);
    footsteps.setLooping(true);

    beep = new AudioNode(audioRenderer, assetManager, "Sound/Effects/Beep.ogg", true);
    beep.setVolume(3);
    beep.setLooping(true);
    
    audioRenderer.playSourceInstance(footsteps);
    audioRenderer.playSource(beep);
    */
    
    waves  = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
    waves.setPositional(true);

    nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
    
    waves.setLocalTranslation(new Vector3f(4, -1, 30));
    waves.setMaxDistance(5);
    waves.setRefDistance(1);
    
    nature.setVolume(3);
    audioRenderer.playSourceInstance(waves);
    audioRenderer.playSource(nature);
}
 
Example 6
Source File: TestAmbient.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
  float[] eax = new float[]{15, 38.0f, 0.300f, -1000, -3300, 0,
    1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f, 0.00f,
    0.00f, -229, 0.088f, 0.00f, 0.00f, 0.00f, 0.125f, 1.000f,
    0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f};
  Environment env = new Environment(eax);
  audioRenderer.setEnvironment(env);

  waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
  waves.setPositional(true);
  waves.setLocalTranslation(new Vector3f(0, 0,0));
  waves.setMaxDistance(100);
  waves.setRefDistance(5);

  nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
  nature.setVolume(3);
  
  waves.playInstance();
  nature.play();
  
  // just a blue box to mark the spot
  Box box1 = new Box(Vector3f.ZERO, .5f, .5f, .5f);
  Geometry player = new Geometry("Player", box1);
  Material mat1 = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");
  mat1.setColor("Color", ColorRGBA.Blue);
  player.setMaterial(mat1);
  rootNode.attachChild(player);
}