Class WavBuffer

java.lang.Object
jmri.jmrit.sound.WavBuffer

public class WavBuffer extends Object
Wrap a byte array to provide WAV file functionality
  • Field Details

  • Constructor Details

    • WavBuffer

      public WavBuffer(byte[] content)
      Create from already existing byte array.
      Parameters:
      content - a WAV format byte array, starting with a RIFF header
    • WavBuffer

      public WavBuffer(File file) throws IOException
      Create from contents of file. The file contents are expected to be in .wav format, starting with a RIFF header.
      Parameters:
      file - file containing the .wav.
      Throws:
      IOException - on error.
  • Method Details

    • findHeader

      public int findHeader(int i1, int i2, int i3, int i4)
      Find a specific header in the .wav fragment.
      Parameters:
      i1 - index 1.
      i2 - index 2.
      i3 - index 3.
      i4 - index 4.
      Returns:
      offset of the 1st byte of the header in the buffer
    • getSampleRate

      public float getSampleRate()
    • getSampleSizeInBits

      public int getSampleSizeInBits()
    • getChannels

      public int getChannels()
    • getBigEndian

      public boolean getBigEndian()
    • getSigned

      public boolean getSigned()
    • getDataStart

      public int getDataStart()
      Offset to the first data byte in the buffer.
      Returns:
      first data byte offset.
    • getDataSize

      public int getDataSize()
      Size of the data segment in bytes.
      Returns:
      data size in bytes.
    • getDataEnd

      public int getDataEnd()
      Offset to the last data byte in the buffer. One more than this points to the next header.
      Returns:
      data end value.
    • twoByte

      int twoByte(int index)
    • fourByte

      int fourByte(int index)
    • getByteArray

      public byte[] getByteArray()