1/*
2 * Copyright (c) 2009-2010 jMonkeyEngine All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * * Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 *
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29package jme3test.audio;
30
31import com.jme3.app.SimpleApplication;
32import com.jme3.audio.AudioNode;
33import com.jme3.audio.Environment;
34import com.jme3.material.Material;
35import com.jme3.math.ColorRGBA;
36import com.jme3.math.Vector3f;
37import com.jme3.scene.Geometry;
38import com.jme3.scene.shape.Box;
39
40public class TestAmbient extends SimpleApplication {
41
42  private AudioNode nature, waves;
43
44  public static void main(String[] args) {
45    TestAmbient test = new TestAmbient();
46    test.start();
47  }
48
49  @Override
50  public void simpleInitApp() {
51    float[] eax = new float[]{15, 38.0f, 0.300f, -1000, -3300, 0,
52      1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f, 0.00f,
53      0.00f, -229, 0.088f, 0.00f, 0.00f, 0.00f, 0.125f, 1.000f,
54      0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f};
55    Environment env = new Environment(eax);
56    audioRenderer.setEnvironment(env);
57
58    waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
59    waves.setPositional(true);
60    waves.setLocalTranslation(new Vector3f(0, 0,0));
61    waves.setMaxDistance(100);
62    waves.setRefDistance(5);
63
64    nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
65    nature.setVolume(3);
66
67    waves.playInstance();
68    nature.play();
69
70    // just a blue box to mark the spot
71    Box box1 = new Box(Vector3f.ZERO, .5f, .5f, .5f);
72    Geometry player = new Geometry("Player", box1);
73    Material mat1 = new Material(assetManager,
74            "Common/MatDefs/Misc/Unshaded.j3md");
75    mat1.setColor("Color", ColorRGBA.Blue);
76    player.setMaterial(mat1);
77    rootNode.attachChild(player);
78  }
79
80  @Override
81  public void simpleUpdate(float tpf) {
82  }
83}
84