jMonkeyEngine provides you with predefined audio environments in the com.jme3.audio.Environment
package.
The following example plays one sound repeatedly in several different environments so you can hear the difference:
Make a copy of
Main.java
and name the classAudioEnvironments.java
. Remember to also refactor the first line of themain()
method toAudioEnvironments app = new AudioEnvironments();
.Copy the provided file
Sounds/Effects/Bang.wav
into your project'sSounds/Effects/
directory.Keep the code that attaches a blue cube as point of reference.
Create two class fields: one audio node, and one audio environment. Initialize the environment to the predefined value
AcousticLab
:private AudioNode stepsAudio; private Environment env = Environment.AcousticLab;
In the
simpleInitApp()
method, initialize SimpleApplication's defaultaudioRenderer
to use your custom environment:public void simpleInitApp() { audioRenderer.setEnvironment(env);
Initialize...