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

The following examples show how to use com.jme3.audio.AudioNode#play() . 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: AudioViewer3DPart.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Play the current audio.
 */
@JmeThread
private void playImpl() {

    final AudioNode currentAudioNode = getAudioNode();

    if (currentAudioNode != null) {

        final Status status = currentAudioNode.getStatus();

        if (status == Status.Paused) {
            currentAudioNode.play();
            return;
        } else if (status == Status.Playing) {
            return;
        }
    }

    loadImpl(getAudioData(), getAudioKey());

    final AudioNode audioNode = getAudioNode();
    audioNode.play();
}
 
Example 2
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 3
Source File: TestDoppler.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public void simpleInitApp() {
        flyCam.setMoveSpeed(10);

        Torus torus = new Torus(10, 6, 1, 3);
        Geometry g = new Geometry("Torus Geom", torus);
        g.rotate(-FastMath.HALF_PI, 0, 0);
        g.center();

        g.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
//        rootNode.attachChild(g);

        ufoNode = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", AudioData.DataType.Buffer);
        ufoNode.setLooping(true);
        ufoNode.setPitch(0.5f);
        ufoNode.setRefDistance(1);
        ufoNode.setMaxDistance(100000000);
        ufoNode.setVelocityFromTranslation(true);
        ufoNode.play();

        Geometry ball = new Geometry("Beeper", new Sphere(10, 10, 0.1f));
        ball.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        ufoNode.attachChild(ball);

        rootNode.attachChild(ufoNode);
    }
 
Example 4
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 5
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 6
Source File: TestMusicStreaming.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp(){
    assetManager.registerLocator("https://web.archive.org/web/20170625151521if_/http://www.vorbis.com/music/", UrlLocator.class);
    AudioNode audioSource = new AudioNode(assetManager, "Lumme-Badloop.ogg",
            AudioData.DataType.Stream);
    audioSource.setPositional(false);
    audioSource.setReverbEnabled(false);
    audioSource.play();
}
 
Example 7
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);
}
 
Example 8
Source File: TestDoppler.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp(){
    audioRenderer.setEnvironment(Environment.Dungeon);
    AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
    
    ufo  = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", false);
    ufo.setPositional(true);
    ufo.setLooping(true);
    ufo.setReverbEnabled(true);
    ufo.setRefDistance(100000000);
    ufo.setMaxDistance(100000000);
    ufo.play();
}
 
Example 9
Source File: TestOgg.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp(){
    System.out.println("Playing without filter");
    audioSource = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", DataType.Buffer);
    audioSource.play();
}
 
Example 10
Source File: TestMusicStreaming.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp(){
    assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class);
    AudioNode audioSource = new AudioNode(assetManager, "Lumme-Badloop.ogg", true);
    audioSource.play();
}
 
Example 11
Source File: TestOgg.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp(){
    System.out.println("Playing without filter");
    audioSource = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
    audioSource.play();
}