GvrAudioSurround

public class GvrAudioSurround

Binaurally renders surround sound and ambisonic soundfields.

Nested Classes

class GvrAudioSurround.SurroundFormat Defines constants to define surround format. 

Public Constructors

GvrAudioSurround(int surroundFormat, int sampleRateHz, int numInputChannels, int numFramesPerOutputBuffer)
Constructs the GVR Audio surround system.

Public Methods

int
addInput(ByteBuffer inputBuffer, int offset, int size)
Provides data to the binaural renderer.
void
flush()
Deletes all unprocessed and processed audio buffers.
int
getAvailableInputSize()
Returns the size in bytes addInput(ByteBuffer, int, int) is currently able to consume.
int
getAvailableOutputSize()
Returns the number of bytes of available output data that can be read via getOutput(ByteBuffer, int, int).
int
getOutput(ByteBuffer outputBuffer, int offset, int size)
Outputs a binaural stereo buffer in interleaved little endian linear int16 format.
void
release()
Releases the GVR Spatial Media renderer system.
boolean
triggerProcessing()
Triggers the processing of data that has been input but not yet processed.
void
updateNativeOrientation(float w, float x, float y, float z)
Sets current listener head orientation.

Inherited Methods

Public Constructors

public GvrAudioSurround (int surroundFormat, int sampleRateHz, int numInputChannels, int numFramesPerOutputBuffer)

Constructs the GVR Audio surround system.

Parameters
surroundFormat The surround format. One of the constants defined in GvrAudioSurround.SurroundFormat.
sampleRateHz Sampling rate of audio buffers.
numInputChannels Number of channels in input buffers. Note this must match with the selected rendering mode.
numFramesPerOutputBuffer Number of audio frames in stereo output buffers.

Public Methods

public int addInput (ByteBuffer inputBuffer, int offset, int size)

Provides data to the binaural renderer.

If enough data has been provided for output to be generated then it will be immediately available via getOutput(ByteBuffer, int, int). The input data is copied into an internal buffer which allows the caller to re-use the input buffer immediately. The available space in the internal buffer can be obtained via getAvailableInputSize().

Parameters
inputBuffer Interleaved int16 input buffer.
offset Offset in input buffer (in bytes)
size Maximum number of bytes to consume from the input buffer.
Returns
  • Number of bytes consumed.

public void flush ()

Deletes all unprocessed and processed audio buffers.

public int getAvailableInputSize ()

Returns the size in bytes addInput(ByteBuffer, int, int) is currently able to consume.

Returns
  • The size in bytes.

public int getAvailableOutputSize ()

Returns the number of bytes of available output data that can be read via getOutput(ByteBuffer, int, int).

Returns
  • The size in bytes.

public int getOutput (ByteBuffer outputBuffer, int offset, int size)

Outputs a binaural stereo buffer in interleaved little endian linear int16 format.

Parameters
outputBuffer Output buffer.
offset Offset in output buffer (in bytes)
size Maximum number of bytes to write into the output buffer.
Returns
  • Number of bytes written.

public void release ()

Releases the GVR Spatial Media renderer system.

public boolean triggerProcessing ()

Triggers the processing of data that has been input but not yet processed.

Note after calling this method, all binaural output must be consumed before new input buffers can be added.

Returns
  • Whether any data was processed.

public void updateNativeOrientation (float w, float x, float y, float z)

Sets current listener head orientation.

Parameters
w W component of quaternion.
x X component of quaternion.
y Y component of quaternion.
z Z component of quaternion.