WavStream
JavaScript is disabled on your browser.
br.usp.ime.dspbenchmarking.streams
Class WavStream
- java.lang.Object
-
- br.usp.ime.dspbenchmarking.streams.AudioStream
-
- br.usp.ime.dspbenchmarking.streams.WavStream
-
public class WavStream extends AudioStream
An audio stream that comes from a WAV file.
-
-
Field Summary
Fields Modifier and Type Field and Description private intchannels(package private) java.nio.ShortBufferdataBufferprivate intdataSizeInBytes(package private) java.util.concurrent.ScheduledFuture<?>dspTask(package private) java.lang.RunnablefileDspCallbackListener for when using AUDIO_SOURCE_FILEprivate static intHEADER_SIZEprivate java.io.InputStreaminputStreamprivate booleanreadFromInputprivate intsampleRate(package private) java.util.concurrent.ScheduledExecutorServicescheduler-
Fields inherited from class br.usp.ime.dspbenchmarking.streams.AudioStream
blockSize, callbackPeriod, dspCallback, isRunning, readTicks, sampleReadTime
-
-
Constructor Summary
Constructors Constructor and Description WavStream(java.io.InputStream is, int bSize)Constructor
-
Method Summary
Methods Modifier and Type Method and Description intblocks()private voidcheckFormat(java.lang.Boolean b, java.lang.String msg)java.nio.ShortBuffergetBuffer()intgetBufferSize()intgetDataSizeInBytes()Returns the WAV size in Bytes.intgetDataSizeInShorts()Returns the WAV size in Shorts.intgetMinBufferSize()intgetSampleRate()Returns the sample rate.private voidinitWavPcm()Prepares the Short buffer for reading the wav file.voidread(short[] buffer, int offset, int size)Queries the Short buffer for more data.private voidreadHeader()Reads the Wav Header.voidreadLoop(short[] buffer)private voidresetBuffer()resets the internal buffer.voidscheduleDspCallback(long blockPeriodNanoseconds)voidstopRunning()-
Methods inherited from class br.usp.ime.dspbenchmarking.streams.AudioStream
createBuffer, getCallbackPeriod, getReadTicks, getSampleReadTime, reset, setBlockSize, setDspCallback
-
-
-
-
Field Detail
-
channels
private int channels
-
sampleRate
private int sampleRate
-
inputStream
private java.io.InputStream inputStream
-
dataSizeInBytes
private int dataSizeInBytes
-
HEADER_SIZE
private static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
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.IOExceptionConstructor- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
-
Method Detail
-
readHeader
private void readHeader() throws java.io.IOExceptionReads the Wav Header.- Throws:
java.io.IOException
-
initWavPcm
private void initWavPcm() throws java.io.IOExceptionPrepares 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:
-
getBufferSize
public int getBufferSize()
- Specified by:
getBufferSizein classAudioStream
-
blocks
public int blocks()
- Specified by:
blocksin classAudioStream- Returns:
-
scheduleDspCallback
public void scheduleDspCallback(long blockPeriodNanoseconds)
- Specified by:
scheduleDspCallbackin classAudioStream
-
readLoop
public void readLoop(short[] buffer)
- Specified by:
readLoopin classAudioStream
-
stopRunning
public void stopRunning()
- Specified by:
stopRunningin classAudioStream
-
getMinBufferSize
public int getMinBufferSize()
- Specified by:
getMinBufferSizein classAudioStream
-
-