public final class GvrAudioProcessor extends Object implements AudioProcessor
AudioProcessor that uses GvrAudioSurround to provide binaural rendering of
surround sound and ambisonic soundfields.AudioProcessor.UnhandledFormatExceptionEMPTY_BUFFER| Constructor and Description |
|---|
GvrAudioProcessor()
Creates a new GVR 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.
|
void |
flush()
Clears any state in preparation for receiving a new stream of input buffers.
|
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
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(ByteBuffer input)
Queues audio data between the position and limit of the input
buffer for processing. |
void |
reset()
Resets the processor to its initial state.
|
void |
updateOrientation(float w,
float x,
float y,
float z)
Updates the listener head orientation.
|
public void updateOrientation(float w,
float x,
float y,
float z)
GvrAudioSurround.updateNativeOrientation.w - The w component of the quaternion.x - The x component of the quaternion.y - The y component of the quaternion.z - The z component of the quaternion.public boolean configure(int sampleRateHz,
int channelCount,
int encoding)
throws AudioProcessor.UnhandledFormatException
AudioProcessorAudioProcessor.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 AudioProcessor.isActive() has changed as a
result of the call. If it's active, AudioProcessor.getOutputChannelCount() and
AudioProcessor.getOutputEncoding() return the processor's 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.true if the processor must be flushed or the value returned by
AudioProcessor.isActive() has changed as a result of the call.AudioProcessor.UnhandledFormatException - Thrown if the specified format can't be handled as input.public boolean isActive()
AudioProcessorisActive in interface AudioProcessorpublic int getOutputChannelCount()
AudioProcessorgetOutputChannelCount in interface AudioProcessorpublic int getOutputEncoding()
AudioProcessorgetOutputEncoding in interface AudioProcessorpublic void queueInput(ByteBuffer input)
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 AudioProcessorinput - 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 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