Package com.badlogic.gdx.audio
Interface AudioDevice
-
- All Superinterfaces:
Disposable
public interface AudioDevice extends Disposable
Encapsulates an audio device in mono or stereo mode. Use thewriteSamples(float[], int, int)
andwriteSamples(short[], int, int)
methods to write float or 16-bit signed short PCM data directly to the audio device. Stereo samples are interleaved in the order left channel sample, right channel sample. Thedispose()
method must be called when this AudioDevice is no longer needed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
dispose()
Frees all resources associated with this AudioDevice.int
getLatency()
boolean
isMono()
void
pause()
Pauses the audio device if supportedvoid
resume()
Unpauses the audio device if supportedvoid
setVolume(float volume)
Sets the volume in the range [0,1].void
writeSamples(float[] samples, int offset, int numSamples)
Writes the array of float PCM samples to the audio device and blocks until they have been processed.void
writeSamples(short[] samples, int offset, int numSamples)
Writes the array of 16-bit signed PCM samples to the audio device and blocks until they have been processed.
-
-
-
Method Detail
-
isMono
boolean isMono()
- Returns:
- whether this AudioDevice is in mono or stereo mode.
-
writeSamples
void writeSamples(short[] samples, int offset, int numSamples)
Writes the array of 16-bit signed PCM samples to the audio device and blocks until they have been processed.- Parameters:
samples
- The samples.offset
- The offset into the samples arraynumSamples
- the number of samples to write to the device
-
writeSamples
void writeSamples(float[] samples, int offset, int numSamples)
Writes the array of float PCM samples to the audio device and blocks until they have been processed.- Parameters:
samples
- The samples.offset
- The offset into the samples arraynumSamples
- the number of samples to write to the device
-
getLatency
int getLatency()
- Returns:
- the latency in samples.
-
dispose
void dispose()
Frees all resources associated with this AudioDevice. Needs to be called when the device is no longer needed.- Specified by:
dispose
in interfaceDisposable
-
setVolume
void setVolume(float volume)
Sets the volume in the range [0,1].
-
pause
void pause()
Pauses the audio device if supported
-
resume
void resume()
Unpauses the audio device if supported
-
-