Class WavBuffer


  • public class WavBuffer
    extends java.lang.Object
    Wrap a byte array to provide WAV file functionality
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) byte[] buffer  
      (package private) int dataOffset  
      (package private) int fmtOffset  
    • Constructor Summary

      Constructors 
      Constructor Description
      WavBuffer​(byte[] content)
      Create from already existing byte array.
      WavBuffer​(java.io.File file)
      Create from contents of file.
    • Constructor Detail

      • 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​(java.io.File file)
                  throws java.io.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:
        java.io.IOException - on error.
    • Method Detail

      • 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
      • 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)