|
35 | 35 | import com.jme3.audio.AudioData; |
36 | 36 | import com.jme3.audio.AudioNode; |
37 | 37 | import com.jme3.audio.Environment; |
| 38 | +import com.jme3.audio.LowPassFilter; |
38 | 39 | import com.jme3.input.KeyInput; |
39 | 40 | import com.jme3.input.controls.ActionListener; |
40 | 41 | import com.jme3.input.controls.KeyTrigger; |
|
48 | 49 | import com.jme3.scene.debug.Grid; |
49 | 50 | import com.jme3.scene.shape.Sphere; |
50 | 51 |
|
| 52 | +/** |
| 53 | + * @author capdevon |
| 54 | + */ |
51 | 55 | public class TestReverb extends SimpleApplication implements ActionListener { |
52 | 56 |
|
53 | 57 | public static void main(String[] args) { |
@@ -86,10 +90,12 @@ public void simpleInitApp() { |
86 | 90 | // Activate 3D audio |
87 | 91 | audioSource = new AudioNode(assetManager, "Sound/Effects/Bang.wav", AudioData.DataType.Buffer); |
88 | 92 | audioSource.setLooping(false); |
| 93 | + audioSource.setVolume(1.2f); |
89 | 94 | audioSource.setPositional(true); |
90 | 95 | audioSource.setMaxDistance(100); |
91 | 96 | audioSource.setRefDistance(5); |
92 | 97 | audioSource.setReverbEnabled(true); |
| 98 | + audioSource.setReverbFilter(new LowPassFilter(1f, 1f)); |
93 | 99 | rootNode.attachChild(audioSource); |
94 | 100 |
|
95 | 101 | Geometry marker = makeShape("Marker", new Sphere(16, 16, 1f), ColorRGBA.Red); |
@@ -147,9 +153,9 @@ public void onAction(String name, boolean isPressed, float tpf) { |
147 | 153 | if (!isPressed) return; |
148 | 154 |
|
149 | 155 | 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); |
153 | 159 |
|
154 | 160 | } else if (name.equals("nextEnvironment")) { |
155 | 161 | index = (index + 1) % environments.length; |
|
0 commit comments