WavStream
JavaScript is disabled on your browser.

br.usp.ime.dspbenchmarking.streams

Class WavStream



  • public class WavStream
    extends AudioStream
    An audio stream that comes from a WAV file.
    • Field Detail

      • channels

        private int channels
      • sampleRate

        private int sampleRate
      • inputStream

        private java.io.InputStream inputStream
      • dataSizeInBytes

        private int dataSizeInBytes
      • dataBuffer

        java.nio.ShortBuffer dataBuffer
      • scheduler

        java.util.concurrent.ScheduledExecutorService scheduler
      • dspTask

        java.util.concurrent.ScheduledFuture<?> dspTask
      • readFromInput

        private boolean readFromInput
      • fileDspCallback

        final java.lang.Runnable fileDspCallback
        Listener for when using AUDIO_SOURCE_FILE
    • Constructor Detail

      • WavStream

        public WavStream(java.io.InputStream is,
                 int bSize)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
        Constructor
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
    • Method Detail

      • readHeader

        private void readHeader()
                         throws java.io.IOException
        Reads the Wav Header.
        Throws:
        java.io.IOException
      • initWavPcm

        private void initWavPcm()
                         throws java.io.IOException
        Prepares the Short buffer for reading the wav file.
        Throws:
        java.io.IOException
      • getBuffer

        public java.nio.ShortBuffer getBuffer()
        Returns:
        Short buffer with the data of the WAV file.
      • resetBuffer

        private void resetBuffer()
        resets the internal buffer.
      • read

        public void read(short[] buffer,
                int offset,
                int size)
        Queries the Short buffer for more data.
        Parameters:
        buffer -
        offset -
        size -
      • checkFormat

        private void checkFormat(java.lang.Boolean b,
                       java.lang.String msg)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • getSampleRate

        public int getSampleRate()
        Returns the sample rate.
        Returns:
      • getDataSizeInBytes

        public int getDataSizeInBytes()
        Returns the WAV size in Bytes.
        Returns:
      • getDataSizeInShorts

        public int getDataSizeInShorts()
        Returns the WAV size in Shorts.
        Returns:
      • readLoop

        public void readLoop(short[] buffer)
        Specified by:
        readLoop in class AudioStream