Audio tests: Using play() and playInstance() on AudioNodes instead of 'deprecated' playSource() on AudioRenderer.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8150 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
roo..om 14 years ago
parent 1acd324d02
commit 26f2fe8c8d
  1. 26
      engine/src/test/jme3test/audio/TestAmbient.java
  2. 2
      engine/src/test/jme3test/audio/TestDoppler.java
  3. 8
      engine/src/test/jme3test/audio/TestMusicPlayer.java
  4. 4
      engine/src/test/jme3test/audio/TestMusicStreaming.java
  5. 18
      engine/src/test/jme3test/audio/TestOgg.java
  6. 8
      engine/src/test/jme3test/audio/TestReverb.java
  7. 8
      engine/src/test/jme3test/audio/TestWav.java

@ -31,7 +31,11 @@ package jme3test.audio;
import com.jme3.app.SimpleApplication;
import com.jme3.audio.AudioNode;
import com.jme3.audio.Environment;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
public class TestAmbient extends SimpleApplication {
@ -53,14 +57,24 @@ public class TestAmbient extends SimpleApplication {
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
waves.setPositional(true);
waves.setLocalTranslation(new Vector3f(4, -1, 30));
waves.setMaxDistance(5);
waves.setRefDistance(1);
waves.setLocalTranslation(new Vector3f(0, 0,0));
waves.setMaxDistance(100);
waves.setRefDistance(5);
nature = new AudioNode(assetManager, "Sound/Environment/River.ogg", true);
nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
nature.setVolume(3);
audioRenderer.playSourceInstance(waves);
audioRenderer.playSource(nature);
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);
}
@Override

@ -69,7 +69,7 @@ public class TestDoppler extends SimpleApplication {
ufo.setReverbEnabled(true);
ufo.setRefDistance(100000000);
ufo.setMaxDistance(100000000);
audioRenderer.playSource(ufo);
ufo.play();
}
@Override

@ -197,7 +197,7 @@ public class TestMusicPlayer extends javax.swing.JFrame {
ex.printStackTrace();
}
musicSource = new AudioNode(ar, musicData, key);
musicSource = new AudioNode(musicData, key);
musicLength = musicData.getDuration();
updateTime();
}
@ -229,7 +229,7 @@ public class TestMusicPlayer extends javax.swing.JFrame {
ar.pauseSource(musicSource);
}else{
musicSource.setPitch(1);
ar.playSource(musicSource);
musicSource.play();
}
}//GEN-LAST:event_btnPlayActionPerformed
@ -263,8 +263,8 @@ public class TestMusicPlayer extends javax.swing.JFrame {
musicSource.setTimeOffset(curTime);
if (musicSource.getStatus() == Status.Playing){
ar.stopSource(musicSource);
ar.playSource(musicSource);
musicSource.stop();
musicSource.play();
}
updateTime();
}

@ -46,8 +46,8 @@ public class TestMusicStreaming extends SimpleApplication {
@Override
public void simpleInitApp(){
assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class);
AudioNode src = new AudioNode(assetManager, "Lumme-Badloop.ogg", true);
audioRenderer.playSource(src);
AudioNode audioSource = new AudioNode(assetManager, "Lumme-Badloop.ogg", true);
audioSource.play();
}
@Override

@ -38,7 +38,7 @@ import com.jme3.audio.LowPassFilter;
public class TestOgg extends SimpleApplication {
private AudioNode src;
private AudioNode audioSource;
public static void main(String[] args){
TestOgg test = new TestOgg();
@ -48,20 +48,20 @@ public class TestOgg extends SimpleApplication {
@Override
public void simpleInitApp(){
System.out.println("Playing without filter");
src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
audioRenderer.playSource(src);
audioSource = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
audioSource.play();
}
@Override
public void simpleUpdate(float tpf){
if (src.getStatus() != AudioNode.Status.Playing){
audioRenderer.deleteAudioData(src.getAudioData());
if (audioSource.getStatus() != AudioNode.Status.Playing){
audioRenderer.deleteAudioData(audioSource.getAudioData());
System.out.println("Playing with low pass filter");
src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
src.setDryFilter(new LowPassFilter(1f, .1f));
src.setVolume(3);
audioRenderer.playSource(src);
audioSource = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
audioSource.setDryFilter(new LowPassFilter(1f, .1f));
audioSource.setVolume(3);
audioSource.play();
}
}

@ -36,7 +36,7 @@ import com.jme3.math.Vector3f;
public class TestReverb extends SimpleApplication {
private AudioNode src;
private AudioNode audioSource;
private float time = 0;
private float nextTime = 1;
@ -47,7 +47,7 @@ public class TestReverb extends SimpleApplication {
@Override
public void simpleInitApp() {
src = new AudioNode(assetManager, "Sound/Effects/Bang.wav");
audioSource = new AudioNode(assetManager, "Sound/Effects/Bang.wav");
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,
@ -70,8 +70,8 @@ public class TestReverb extends SimpleApplication {
v.multLocal(40, 2, 40);
v.subtractLocal(20, 1, 20);
src.setLocalTranslation(v);
audioRenderer.playSourceInstance(src);
audioSource.setLocalTranslation(v);
audioSource.playInstance();
time = 0;
nextTime = FastMath.nextRandomFloat() * 2 + 0.5f;
}

@ -35,7 +35,7 @@ import com.jme3.audio.AudioNode;
public class TestWav extends SimpleApplication {
private float time = 0;
private AudioNode src;
private AudioNode audioSource;
public static void main(String[] args) {
TestWav test = new TestWav();
@ -46,7 +46,7 @@ public class TestWav extends SimpleApplication {
public void simpleUpdate(float tpf) {
time += tpf;
if (time > 1f) {
audioRenderer.playSourceInstance(src);
audioSource.playInstance();
time = 0;
}
@ -54,7 +54,7 @@ public class TestWav extends SimpleApplication {
@Override
public void simpleInitApp() {
src = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
src.setLooping(false);
audioSource = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
audioSource.setLooping(false);
}
}

Loading…
Cancel
Save