Class ReadableSoundBuffer
java.lang.Object
de.pottgames.tuningfork.SoundBuffer
de.pottgames.tuningfork.ReadableSoundBuffer
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
A
SoundBuffer that keeps a copy of the audio data that can be read.-
Constructor Summary
ConstructorsConstructorDescriptionReadableSoundBuffer(byte[] pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType) Creates a SoundBuffer with the given pcm data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound.ReadableSoundBuffer(byte[] pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType, int blockAlign) Creates a SoundBuffer with the given pcm data.
Consider usingReadableSoundBuffer(byte[], int, int, int, PcmDataType)instead if you're not providing MS_ADPCM data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound.ReadableSoundBuffer(ShortBuffer pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType, int blockAlign) Creates a SoundBuffer with the given pcm data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns a copy of the audio data (no allocation involved here) used in this SoundBuffer.Methods inherited from class SoundBuffer
dispose, fetchDuration, fetchSamplesPerChannel, generateBufferAndUpload, getDuration, getLoopPoints, getPcmFormat, play, play, play, play, play, play, play, play, play, play3D, play3D, play3D, play3D, play3D, play3D, play3D, play3D, play3D, playAtTime, setLoopPoints
-
Constructor Details
-
ReadableSoundBuffer
public ReadableSoundBuffer(byte[] pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType) Creates a SoundBuffer with the given pcm data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound.- Parameters:
pcm- the pcm datachannels- number of channelssampleRate- number of samples per secondbitsPerSample- number of bits per samplepcmDataType- the pcm data type
-
ReadableSoundBuffer
public ReadableSoundBuffer(ShortBuffer pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType, int blockAlign) Creates a SoundBuffer with the given pcm data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound.- Parameters:
pcm- the pcm data bufferchannels- number of channelssampleRate- number of samples per secondbitsPerSample- number of bits per samplepcmDataType- the pcm data typeblockAlign- the block alignment (currently only used for MS ADPCM data)
-
ReadableSoundBuffer
public ReadableSoundBuffer(byte[] pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType, int blockAlign) Creates a SoundBuffer with the given pcm data.
Consider usingReadableSoundBuffer(byte[], int, int, int, PcmDataType)instead if you're not providing MS_ADPCM data.
8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero .
16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero.
Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.
The interleaved format also applies to surround sound.- Parameters:
pcm- the pcm datachannels- number of channelssampleRate- number of samples per secondbitsPerSample- number of bits per samplepcmDataType- the pcm data typeblockAlign- the block alignment (currently only used for MS ADPCM data)
-
-
Method Details
-
getAudioData
public byte[] getAudioData()Returns a copy of the audio data (no allocation involved here) used in this SoundBuffer. Writing to it has no effect to the actual data used.
UseSoundBuffer.getPcmFormat()to get info about the data layout.- Returns:
- a copy of the audio data
-