Skip to content

Commit 606d064

Browse files
authored
Update TestReverb: add reverbFilter
1 parent 64d08f9 commit 606d064

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jme3-examples/src/main/java/jme3test/audio/TestReverb.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.jme3.audio.AudioData;
3636
import com.jme3.audio.AudioNode;
3737
import com.jme3.audio.Environment;
38+
import com.jme3.audio.LowPassFilter;
3839
import com.jme3.input.KeyInput;
3940
import com.jme3.input.controls.ActionListener;
4041
import com.jme3.input.controls.KeyTrigger;
@@ -48,6 +49,9 @@
4849
import com.jme3.scene.debug.Grid;
4950
import com.jme3.scene.shape.Sphere;
5051

52+
/**
53+
* @author capdevon
54+
*/
5155
public class TestReverb extends SimpleApplication implements ActionListener {
5256

5357
public static void main(String[] args) {
@@ -86,10 +90,12 @@ public void simpleInitApp() {
8690
// Activate 3D audio
8791
audioSource = new AudioNode(assetManager, "Sound/Effects/Bang.wav", AudioData.DataType.Buffer);
8892
audioSource.setLooping(false);
93+
audioSource.setVolume(1.2f);
8994
audioSource.setPositional(true);
9095
audioSource.setMaxDistance(100);
9196
audioSource.setRefDistance(5);
9297
audioSource.setReverbEnabled(true);
98+
audioSource.setReverbFilter(new LowPassFilter(1f, 1f));
9399
rootNode.attachChild(audioSource);
94100

95101
Geometry marker = makeShape("Marker", new Sphere(16, 16, 1f), ColorRGBA.Red);
@@ -147,9 +153,9 @@ public void onAction(String name, boolean isPressed, float tpf) {
147153
if (!isPressed) return;
148154

149155
if (name.equals("toggleReverbEnabled")) {
150-
boolean reverbEnabled = audioSource.isReverbEnabled();
151-
audioSource.setReverbEnabled(!reverbEnabled);
152-
System.out.println("reverbEnabled: " + audioSource.isReverbEnabled());
156+
boolean reverbEnabled = !audioSource.isReverbEnabled();
157+
audioSource.setReverbEnabled(reverbEnabled);
158+
System.out.println("reverbEnabled: " + reverbEnabled);
153159

154160
} else if (name.equals("nextEnvironment")) {
155161
index = (index + 1) % environments.length;

0 commit comments

Comments
 (0)