public interface AudioProcessor
Modifier and Type | Interface and Description |
---|---|
static class |
AudioProcessor.UnhandledFormatException
Exception thrown when a processor can't be configured for a given input audio format.
|
Modifier and Type | Field and Description |
---|---|
static java.nio.ByteBuffer |
EMPTY_BUFFER
An empty, direct
ByteBuffer . |
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.
|
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.
|
boolean |
isActive()
Returns whether the processor is configured and active.
|
boolean |
isEnded()
Returns whether this processor will return no more output from
getOutput() until it
has been flush() ed and more input has been queued. |
void |
queueEndOfStream()
Queues an end of stream signal.
|
void |
queueInput(java.nio.ByteBuffer buffer)
Queues audio data between the position and limit of the input
buffer for processing. |
void |
release()
Releases any resources associated with this instance.
|
static final java.nio.ByteBuffer EMPTY_BUFFER
ByteBuffer
.boolean configure(int sampleRateHz, int channelCount, int encoding) throws AudioProcessor.UnhandledFormatException
isActive()
returns whether the processor needs to handle buffers; if not, the
processor will not accept any buffers until it is reconfigured. Returns true
if the
processor must be flushed, or if the value returned by isActive()
has changed as a
result of the call. If it's active, getOutputChannelCount()
and
getOutputEncoding()
return the processor's output format.sampleRateHz
- The sample rate of input audio in Hz.channelCount
- The number of interleaved channels in input audio.encoding
- The encoding of input audio.true
if the processor must be flushed or the value returned by
isActive()
has changed as a result of the call.AudioProcessor.UnhandledFormatException
- Thrown if the specified format can't be handled as input.boolean isActive()
int getOutputChannelCount()
int getOutputEncoding()
void queueInput(java.nio.ByteBuffer buffer)
buffer
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 getOutput()
.buffer
- The input buffer to process.void queueEndOfStream()
queueInput(ByteBuffer)
may not be called until after the next call to
flush()
. Calling getOutput()
will return any remaining output data. Multiple
calls may be required to read all of the remaining output data. isEnded()
will return
true
once all remaining output data has been read.java.nio.ByteBuffer getOutput()
boolean isEnded()
getOutput()
until it
has been flush()
ed and more input has been queued.void flush()
void release()