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 int
channels
(package private) java.nio.ShortBuffer
dataBuffer
private int
dataSizeInBytes
(package private) java.util.concurrent.ScheduledFuture<?>
dspTask
(package private) java.lang.Runnable
fileDspCallback
Listener for when using AUDIO_SOURCE_FILEprivate static int
HEADER_SIZE
private java.io.InputStream
inputStream
private boolean
readFromInput
private int
sampleRate
(package private) java.util.concurrent.ScheduledExecutorService
scheduler
-
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 int
blocks()
private void
checkFormat(java.lang.Boolean b, java.lang.String msg)
java.nio.ShortBuffer
getBuffer()
int
getBufferSize()
int
getDataSizeInBytes()
Returns the WAV size in Bytes.int
getDataSizeInShorts()
Returns the WAV size in Shorts.int
getMinBufferSize()
int
getSampleRate()
Returns the sample rate.private void
initWavPcm()
Prepares the Short buffer for reading the wav file.void
read(short[] buffer, int offset, int size)
Queries the Short buffer for more data.private void
readHeader()
Reads the Wav Header.void
readLoop(short[] buffer)
private void
resetBuffer()
resets the internal buffer.void
scheduleDspCallback(long blockPeriodNanoseconds)
void
stopRunning()
-
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.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:
-
getBufferSize
public int getBufferSize()
- Specified by:
getBufferSize
in classAudioStream
-
blocks
public int blocks()
- Specified by:
blocks
in classAudioStream
- Returns:
-
scheduleDspCallback
public void scheduleDspCallback(long blockPeriodNanoseconds)
- Specified by:
scheduleDspCallback
in classAudioStream
-
readLoop
public void readLoop(short[] buffer)
- Specified by:
readLoop
in classAudioStream
-
stopRunning
public void stopRunning()
- Specified by:
stopRunning
in classAudioStream
-
getMinBufferSize
public int getMinBufferSize()
- Specified by:
getMinBufferSize
in classAudioStream
-
-