Class ReadableSoundBuffer

java.lang.Object
de.pottgames.tuningfork.SoundBuffer
de.pottgames.tuningfork.ReadableSoundBuffer
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class ReadableSoundBuffer extends SoundBuffer
A SoundBuffer that keeps a copy of the audio data that can be read.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    ReadableSoundBuffer(byte[] pcm, int channels, int sampleRate, int bitsPerSample, PcmFormat.PcmDataType pcmDataType, int blockAlign)
    Creates a SoundBuffer with the given pcm data.
    Consider using ReadableSoundBuffer(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 Type
    Method
    Description
    byte[]
    Returns a copy of the audio data (no allocation involved here) used in this SoundBuffer.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 data
      channels - number of channels
      sampleRate - number of samples per second
      bitsPerSample - number of bits per sample
      pcmDataType - 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 buffer
      channels - number of channels
      sampleRate - number of samples per second
      bitsPerSample - number of bits per sample
      pcmDataType - the pcm data type
      blockAlign - 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 using ReadableSoundBuffer(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 data
      channels - number of channels
      sampleRate - number of samples per second
      bitsPerSample - number of bits per sample
      pcmDataType - the pcm data type
      blockAlign - 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.
      Use SoundBuffer.getPcmFormat() to get info about the data layout.
      Returns:
      a copy of the audio data