This site has been archived and remains strictly as a historical reference for developers who actively maintain apps built using the legacy Google VR SDK, which was last updated in 2019 and is no longer receiving updates.
  • All developers actively developing experiences for Google Cardboard should use the new open source Cardboard SDKs for iOS, Android NDK, and Unity XR Plugin. These new SDKs offer streamlined APIs, improved device compatibility, and built-in viewer profile QR code scanning.
  • The Daydream View VR headset is no longer available for purchase as of October 15, 2019. Existing apps on supported devices are unaffected for users who previously installed those applications. It is no longer possible to opt-in to Daydream distribution via Google Play.

GvrAudioSurround

Stay organized with collections Save and categorize content based on your preferences.
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.