From 26f2fe8c8dcb85f2db48674ab8dde4f3f63354b3 Mon Sep 17 00:00:00 2001 From: "roo..om" Date: Fri, 2 Sep 2011 19:53:26 +0000 Subject: [PATCH] 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 --- .../src/test/jme3test/audio/TestAmbient.java | 26 ++++++++++++++----- .../src/test/jme3test/audio/TestDoppler.java | 2 +- .../test/jme3test/audio/TestMusicPlayer.java | 8 +++--- .../jme3test/audio/TestMusicStreaming.java | 4 +-- engine/src/test/jme3test/audio/TestOgg.java | 18 ++++++------- .../src/test/jme3test/audio/TestReverb.java | 8 +++--- engine/src/test/jme3test/audio/TestWav.java | 8 +++--- 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/engine/src/test/jme3test/audio/TestAmbient.java b/engine/src/test/jme3test/audio/TestAmbient.java index a8bf01189..c6b38c2c5 100644 --- a/engine/src/test/jme3test/audio/TestAmbient.java +++ b/engine/src/test/jme3test/audio/TestAmbient.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 diff --git a/engine/src/test/jme3test/audio/TestDoppler.java b/engine/src/test/jme3test/audio/TestDoppler.java index 30903ed68..3368874a2 100644 --- a/engine/src/test/jme3test/audio/TestDoppler.java +++ b/engine/src/test/jme3test/audio/TestDoppler.java @@ -69,7 +69,7 @@ public class TestDoppler extends SimpleApplication { ufo.setReverbEnabled(true); ufo.setRefDistance(100000000); ufo.setMaxDistance(100000000); - audioRenderer.playSource(ufo); + ufo.play(); } @Override diff --git a/engine/src/test/jme3test/audio/TestMusicPlayer.java b/engine/src/test/jme3test/audio/TestMusicPlayer.java index a957e0095..0b42dab9a 100644 --- a/engine/src/test/jme3test/audio/TestMusicPlayer.java +++ b/engine/src/test/jme3test/audio/TestMusicPlayer.java @@ -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(); } diff --git a/engine/src/test/jme3test/audio/TestMusicStreaming.java b/engine/src/test/jme3test/audio/TestMusicStreaming.java index dde4394c3..49159af18 100644 --- a/engine/src/test/jme3test/audio/TestMusicStreaming.java +++ b/engine/src/test/jme3test/audio/TestMusicStreaming.java @@ -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 diff --git a/engine/src/test/jme3test/audio/TestOgg.java b/engine/src/test/jme3test/audio/TestOgg.java index 64ab7a4bc..59b8d04ba 100644 --- a/engine/src/test/jme3test/audio/TestOgg.java +++ b/engine/src/test/jme3test/audio/TestOgg.java @@ -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(); } } diff --git a/engine/src/test/jme3test/audio/TestReverb.java b/engine/src/test/jme3test/audio/TestReverb.java index 56b6045f6..0a20096d6 100644 --- a/engine/src/test/jme3test/audio/TestReverb.java +++ b/engine/src/test/jme3test/audio/TestReverb.java @@ -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; } diff --git a/engine/src/test/jme3test/audio/TestWav.java b/engine/src/test/jme3test/audio/TestWav.java index 63bb52212..7e73dede3 100644 --- a/engine/src/test/jme3test/audio/TestWav.java +++ b/engine/src/test/jme3test/audio/TestWav.java @@ -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); } }