public final class SilenceSkippingAudioProcessor extends java.lang.Object implements AudioProcessor
AudioProcessor that skips silence in the input stream. Input and output are 16-bit
PCM.AudioProcessor.UnhandledFormatExceptionEMPTY_BUFFER| Constructor and Description |
|---|
SilenceSkippingAudioProcessor()
Creates a new silence trimming audio processor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
configure(int sampleRateHz,
int channelCount,
int encoding)
Configures the processor to process input audio with the specified format and returns whether
to
AudioProcessor.flush() it. |
void |
flush()
Clears any state in preparation for receiving a new stream of input buffers.
|
java.nio.ByteBuffer |
getOutput()
Returns a buffer containing processed output data between its position and limit.
|
int |
getOutputChannelCount()
Returns the number of audio channels in the data output by the processor.
|
int |
getOutputEncoding()
Returns the audio encoding used in the data output by the processor.
|
int |
getOutputSampleRateHz()
Returns the sample rate of audio output by the processor, in hertz.
|
long |
getSkippedFrames()
Returns the total number of frames of input audio that were skipped due to being classified as
silence since the last call to
flush(). |
boolean |
isActive()
Returns whether the processor is configured and will process input buffers.
|
boolean |
isEnded()
Returns whether this processor will return no more output from
AudioProcessor.getOutput() until it
has been AudioProcessor.flush()ed and more input has been queued. |
void |
queueEndOfStream()
Queues an end of stream signal.
|
void |
queueInput(java.nio.ByteBuffer inputBuffer)
Queues audio data between the position and limit of the input
buffer for processing. |
void |
reset()
Resets the processor to its unconfigured state.
|
void |
setEnabled(boolean enabled)
Sets whether to skip silence in the input.
|
public SilenceSkippingAudioProcessor()
public void setEnabled(boolean enabled)
isActive().enabled - Whether to skip silence in the input.public long getSkippedFrames()
flush().public boolean configure(int sampleRateHz,
int channelCount,
int encoding)
throws AudioProcessor.UnhandledFormatException
AudioProcessorAudioProcessor.flush() it. After calling this method, if the processor is active, AudioProcessor.getOutputSampleRateHz(), AudioProcessor.getOutputChannelCount() and AudioProcessor.getOutputEncoding()
return its output format.configure in interface AudioProcessorsampleRateHz - The sample rate of input audio in Hz.channelCount - The number of interleaved channels in input audio.encoding - The encoding of input audio.AudioProcessor.flush() the processor.AudioProcessor.UnhandledFormatException - Thrown if the specified format can't be handled as input.public boolean isActive()
AudioProcessorisActive in interface AudioProcessorpublic int getOutputChannelCount()
AudioProcessorAudioProcessor.configure(int, int, int) and is undefined if the instance is
not active.getOutputChannelCount in interface AudioProcessor@C.Encoding public int getOutputEncoding()
AudioProcessorAudioProcessor.configure(int, int, int) and is undefined if the instance is not
active.getOutputEncoding in interface AudioProcessorpublic int getOutputSampleRateHz()
AudioProcessorAudioProcessor.configure(int, int, int) and is undefined if the instance is not
active.getOutputSampleRateHz in interface AudioProcessorpublic void queueInput(java.nio.ByteBuffer inputBuffer)
AudioProcessorbuffer for processing.
buffer must be a direct byte buffer with native byte order. Its contents are treated as
read-only. Its position will be advanced by the number of bytes consumed (which may be zero).
The caller retains ownership of the provided buffer. Calling this method invalidates any
previous buffer returned by AudioProcessor.getOutput().queueInput in interface AudioProcessorinputBuffer - The input buffer to process.public void queueEndOfStream()
AudioProcessorAudioProcessor.queueInput(ByteBuffer) may not be called until after the next call to
AudioProcessor.flush(). Calling AudioProcessor.getOutput() will return any remaining output data. Multiple
calls may be required to read all of the remaining output data. AudioProcessor.isEnded() will return
true once all remaining output data has been read.queueEndOfStream in interface AudioProcessorpublic java.nio.ByteBuffer getOutput()
AudioProcessorgetOutput in interface AudioProcessorpublic boolean isEnded()
AudioProcessorAudioProcessor.getOutput() until it
has been AudioProcessor.flush()ed and more input has been queued.isEnded in interface AudioProcessorpublic void flush()
AudioProcessorflush in interface AudioProcessorpublic void reset()
AudioProcessorreset in interface AudioProcessor