public class AudioDispatcher
extends java.lang.Object
implements java.lang.Runnable
Constructor and Description |
---|
AudioDispatcher(TarsosDSPAudioInputStream stream,
int audioBufferSize,
int bufferOverlap)
Create a new dispatcher from a stream.
|
Modifier and Type | Method and Description |
---|---|
void |
addAudioProcessor(AudioProcessor audioProcessor)
Adds an AudioProcessor to the chain of processors.
|
TarsosDSPAudioFormat |
getFormat() |
boolean |
isStopped() |
void |
removeAudioProcessor(AudioProcessor audioProcessor)
Removes an AudioProcessor to the chain of processors and calls its
processingFinished method. |
void |
run() |
float |
secondsProcessed() |
void |
setAudioFloatBuffer(float[] audioBuffer) |
void |
setStepSizeAndOverlap(int audioBufferSize,
int bufferOverlap)
Set a new step size and overlap size.
|
void |
setZeroPadFirstBuffer(boolean zeroPadFirstBuffer)
if zero pad is true then the first buffer is only filled up to buffer size - hop size
E.g.
|
void |
setZeroPadLastBuffer(boolean zeroPadLastBuffer)
If zero pad last buffer is true then the last buffer is filled with zeros until the normal amount
of elements are present in the buffer.
|
void |
skip(double seconds)
Skip a number of seconds before processing the stream.
|
void |
stop()
Stops dispatching audio data.
|
public AudioDispatcher(TarsosDSPAudioInputStream stream, int audioBufferSize, int bufferOverlap)
stream
- The stream to read data from.audioBufferSize
- The size of the buffer defines how much samples are processed
in one step. Common values are 1024,2048.bufferOverlap
- How much consecutive buffers overlap (in samples). Half of the
AudioBufferSize is common (512, 1024) for an FFT.public void skip(double seconds)
seconds
- public void setStepSizeAndOverlap(int audioBufferSize, int bufferOverlap)
audioBufferSize
- The size of the buffer defines how much samples are processed
in one step. Common values are 1024,2048.bufferOverlap
- How much consecutive buffers overlap (in samples). Half of the
AudioBufferSize is common (512, 1024) for an FFT.public void setZeroPadFirstBuffer(boolean zeroPadFirstBuffer)
zeroPadFirstBuffer
- true if the buffer should be zeroPadFirstBuffer, false otherwise.public void setZeroPadLastBuffer(boolean zeroPadLastBuffer)
zeroPadLastBuffer
- public void addAudioProcessor(AudioProcessor audioProcessor)
audioProcessor
- The AudioProcessor to add.public void removeAudioProcessor(AudioProcessor audioProcessor)
processingFinished
method.audioProcessor
- The AudioProcessor to remove.public void run()
run
in interface java.lang.Runnable
public void stop()
public TarsosDSPAudioFormat getFormat()
public float secondsProcessed()
public void setAudioFloatBuffer(float[] audioBuffer)
public boolean isStopped()