@Override public void simpleInitApp() { audioSource = new AudioNode(assetManager, "Sound/Effects/Bang.wav", AudioData.DataType.Buffer); 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}; audioRenderer.setEnvironment(new Environment(eax)); Environment env = Environment.Cavern; audioRenderer.setEnvironment(env); }
/** * Set the direction of this audio node. * Does nothing if the audio node is not directional. * * @param direction * @see AudioNode#setDirectional(boolean) */ public void setDirection(Vector3f direction) { this.direction = direction; if (channel >= 0) getRenderer().updateSourceParam(this, AudioParam.Direction); }
private void btnStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopActionPerformed if (musicSource != null){ musicSource.setPitch(1); ar.stopSource(musicSource); } }//GEN-LAST:event_btnStopActionPerformed
@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(); } }
@Override public void simpleInitApp() { audioSource = new AudioNode(assetManager, "Sound/Effects/Gun.wav", AudioData.DataType.Buffer); audioSource.setLooping(false); } }
/** * Start playing the audio. */ public void play(){ if (positional && data.getChannels() > 1) { throw new IllegalStateException("Only mono audio is supported for positional audio nodes"); } getRenderer().playSource(this); }
/** * Pause the audio that was started with {@link AudioNode#play() }. */ public void pause(){ getRenderer().pauseSource(this); }
/** * Start playing an instance of this audio. This method can be used * to play the same <code>AudioNode</code> multiple times. Note * that changes to the parameters of this AudioNode will not affect the * instances already playing. */ public void playInstance(){ if (positional && data.getChannels() > 1) { throw new IllegalStateException("Only mono audio is supported for positional audio nodes"); } getRenderer().playSourceInstance(this); }
/** * Stop playing the audio that was started with {@link AudioNode#play() }. */ public void stop(){ getRenderer().stopSource(this); }
@Override public float getPlaybackTime() { if (channel >= 0) return getRenderer().getSourcePlaybackTime(this); else return 0; }
@Override public void simpleUpdate(float tpf) { time += tpf; if (time > 1f) { audioSource.playInstance(); time = 0; } }
public void setVolume(float volume) { this.volume = volume; if (renderer != null) renderer.updateListenerParam(this, ListenerParam.Volume); }
/** * Creates a new <code>AudioNode</code> with the given data and key. * * @param audioData The audio data contains the audio track to play. * @param audioKey The audio key that was used to load the AudioData */ public AudioNode(AudioData audioData, AudioKey audioKey) { setAudioData(audioData, audioKey); }
/** * Reads samples from the stream. * * @see AudioStream#readSamples(byte[], int, int) * @param buf Buffer where to read the samples * @return number of bytes read. */ public int readSamples(byte[] buf) { return readSamples(buf, 0, buf.length); }
@Override public void resetObject() { this.id = -1; setUpdateNeeded(); }
@Override public void resetObject() { id = -1; ids = null; setUpdateNeeded(); }
/** * Set the looping mode for the audio node. The default is false. * * @param loop True if the audio should keep looping after it is done playing. */ public void setLooping(boolean loop) { this.loop = loop; if (channel >= 0) getRenderer().updateSourceParam(this, AudioParam.Looping); }
/** * Set the directional audio node cone outer angle. * Does nothing if the audio node is not directional. * * @param outerAngle The cone outer angle. */ public void setOuterAngle(float outerAngle) { this.outerAngle = outerAngle; if (channel >= 0) getRenderer().updateSourceParam(this, AudioParam.OuterAngle); }
/** * Set the directional audio node cone inner angle. * Does nothing if the audio node is not directional. * * @param innerAngle The cone inner angle. */ public void setInnerAngle(float innerAngle) { this.innerAngle = innerAngle; if (channel >= 0) getRenderer().updateSourceParam(this, AudioParam.InnerAngle); }
/** * Set the audio node as positional. * The position, velocity, and distance parameters affect positional * audio nodes. Set to false if the audio node should play in "headspace". * * @param positional True if the audio node should be positional, otherwise * false if it should be headspace. */ public void setPositional(boolean positional) { this.positional = positional; if (channel >= 0) { getRenderer().updateSourceParam(this, AudioParam.IsPositional); } }