Search in sources :

Example 1 with AudioNode

use of com.jme3.audio.AudioNode in project jmonkeyengine by jMonkeyEngine.

the class TestAmbient method simpleInitApp.

@Override
public void simpleInitApp() {
    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, -229, 0.088f, 0.00f, 0.00f, 0.00f, 0.125f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f };
    Environment env = new Environment(eax);
    audioRenderer.setEnvironment(env);
    waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
    waves.setPositional(true);
    waves.setLocalTranslation(new Vector3f(0, 0, 0));
    waves.setMaxDistance(100);
    waves.setRefDistance(5);
    nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
    nature.setPositional(false);
    nature.setVolume(3);
    waves.playInstance();
    nature.play();
    // just a blue box to mark the spot
    Box box1 = new Box(.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);
}
Also used : Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Environment(com.jme3.audio.Environment) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) AudioNode(com.jme3.audio.AudioNode)

Example 2 with AudioNode

use of com.jme3.audio.AudioNode in project jmonkeyengine by jMonkeyEngine.

the class HelloAudio method initAudio.

/** We create two audio nodes. */
private void initAudio() {
    /* gun shot sound is to be triggered by a mouse click. */
    audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
    audio_gun.setPositional(false);
    audio_gun.setLooping(false);
    audio_gun.setVolume(2);
    rootNode.attachChild(audio_gun);
    /* nature sound - keeps playing in a loop. */
    audio_nature = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
    // activate continuous playing
    audio_nature.setLooping(true);
    audio_nature.setPositional(true);
    audio_nature.setVolume(3);
    rootNode.attachChild(audio_nature);
    // play continuously!
    audio_nature.play();
}
Also used : AudioNode(com.jme3.audio.AudioNode)

Example 3 with AudioNode

use of com.jme3.audio.AudioNode in project jmonkeyengine by jMonkeyEngine.

the class AudioTrack method read.

/**
     * Internal use only serialization
     *
     * @param im importer
     * @throws IOException Exception
     */
public void read(JmeImporter im) throws IOException {
    InputCapsule in = im.getCapsule(this);
    audio = (AudioNode) in.readSavable("audio", null);
    length = in.readFloat("length", length);
    startOffset = in.readFloat("startOffset", 0);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 4 with AudioNode

use of com.jme3.audio.AudioNode in project jmonkeyengine by jMonkeyEngine.

the class AudioTrack method findAudio.

/**    
     * recursive function responsible for finding the newly cloned AudioNode
     *
     * @param spat
     * @return
     */
private AudioNode findAudio(Spatial spat) {
    if (spat instanceof AudioNode) {
        //spat is an AudioNode
        AudioNode em = (AudioNode) spat;
        //getting the UserData TrackInfo so check if it should be attached to this Track
        TrackInfo t = (TrackInfo) em.getUserData("TrackInfo");
        if (t != null && t.getTracks().contains(this)) {
            return em;
        }
        return null;
    } else if (spat instanceof Node) {
        for (Spatial child : ((Node) spat).getChildren()) {
            AudioNode em = findAudio(child);
            if (em != null) {
                return em;
            }
        }
    }
    return null;
}
Also used : Spatial(com.jme3.scene.Spatial) AudioNode(com.jme3.audio.AudioNode) Node(com.jme3.scene.Node) AudioNode(com.jme3.audio.AudioNode)

Example 5 with AudioNode

use of com.jme3.audio.AudioNode in project jmonkeyengine by jMonkeyEngine.

the class TestOgg method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    if (audioSource.getStatus() != AudioSource.Status.Playing) {
        audioRenderer.deleteAudioData(audioSource.getAudioData());
        System.out.println("Playing with low pass filter");
        audioSource = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", DataType.Buffer);
        audioSource.setDryFilter(new LowPassFilter(1f, .1f));
        audioSource.setVolume(3);
        audioSource.play();
    }
}
Also used : LowPassFilter(com.jme3.audio.LowPassFilter) AudioNode(com.jme3.audio.AudioNode)

Aggregations

AudioNode (com.jme3.audio.AudioNode)13 Environment (com.jme3.audio.Environment)2 LowPassFilter (com.jme3.audio.LowPassFilter)2 Vector3f (com.jme3.math.Vector3f)2 Geometry (com.jme3.scene.Geometry)2 Node (com.jme3.scene.Node)2 Spatial (com.jme3.scene.Spatial)2 AssetInfo (com.jme3.asset.AssetInfo)1 AssetLoader (com.jme3.asset.AssetLoader)1 OGGLoader (com.jme3.audio.plugins.OGGLoader)1 WAVLoader (com.jme3.audio.plugins.WAVLoader)1 InputCapsule (com.jme3.export.InputCapsule)1 ActionListener (com.jme3.input.controls.ActionListener)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 AmbientLight (com.jme3.light.AmbientLight)1 DirectionalLight (com.jme3.light.DirectionalLight)1 Material (com.jme3.material.Material)1 ColorRGBA (com.jme3.math.ColorRGBA)1 Quaternion (com.jme3.math.Quaternion)1 FilterPostProcessor (com.jme3.post.FilterPostProcessor)1