This site has been permanently archived. The content on this site was last updated in 2019.
GvrAudioSurround
Stay organized with collections
Save and categorize content based on your preferences.
Binaurally renders surround sound and ambisonic soundfields.
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
|
|
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
|
|
Inherited Methods
From class
java.lang.Object
boolean
|
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Constructors
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
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
getAvailableOutputSize
()
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. |
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.
|
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003e\u003ccode\u003eGvrAudioSurround\u003c/code\u003e binaurally renders surround and ambisonic soundfields, providing spatial audio experiences.\u003c/p\u003e\n"],["\u003cp\u003eIt uses an internal buffer system where you provide input audio data via \u003ccode\u003eaddInput\u003c/code\u003e and retrieve processed binaural output using \u003ccode\u003egetOutput\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can control the listener's head orientation using \u003ccode\u003eupdateNativeOrientation\u003c/code\u003e for accurate spatialization.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGvrAudioSurround\u003c/code\u003e supports various surround formats and allows you to configure sample rate and channel counts.\u003c/p\u003e\n"],["\u003cp\u003eCall \u003ccode\u003erelease\u003c/code\u003e to free up resources when you are finished using the \u003ccode\u003eGvrAudioSurround\u003c/code\u003e instance.\u003c/p\u003e\n"]]],["The `GvrAudioSurround` class binaurally renders surround and ambisonic sound. Key actions include constructing the system with specified surround format, sample rate, and channel numbers. It adds audio data via `addInput`, retrieving available input/output sizes with `getAvailableInputSize` and `getAvailableOutputSize`. It outputs stereo buffers with `getOutput`, manages buffers with `flush`, processes pending data with `triggerProcessing`, and sets head orientation with `updateNativeOrientation`, and releases resources with `release`.\n"],null,["public class **GvrAudioSurround** \nBinaurally renders surround sound and ambisonic soundfields. \n\nNested Classes\n\n|-------|---|---|----------------------------------------------|\n| class | [GvrAudioSurround.SurroundFormat](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround.SurroundFormat) || Defines constants to define surround format. |\n\nPublic Constructors\n\n|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [GvrAudioSurround](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#GvrAudioSurround(int,%20int,%20int,%20int))(int surroundFormat, int sampleRateHz, int numInputChannels, int numFramesPerOutputBuffer) Constructs the GVR Audio surround system. |\n\nPublic Methods\n\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| int | [addInput](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#addInput(java.nio.ByteBuffer,%20int,%20int))([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer) inputBuffer, int offset, int size) Provides data to the binaural renderer. |\n| void | [flush](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#flush())() Deletes all unprocessed and processed audio buffers. |\n| int | [getAvailableInputSize](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getAvailableInputSize())() Returns the size in bytes [addInput(ByteBuffer, int, int)](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#addInput(java.nio.ByteBuffer,%20int,%20int)) is currently able to consume. |\n| int | [getAvailableOutputSize](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getAvailableOutputSize())() Returns the number of bytes of available output data that can be read via [getOutput(ByteBuffer, int, int)](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getOutput(java.nio.ByteBuffer,%20int,%20int)). |\n| int | [getOutput](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getOutput(java.nio.ByteBuffer,%20int,%20int))([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer) outputBuffer, int offset, int size) Outputs a binaural stereo buffer in interleaved little endian linear int16 format. |\n| void | [release](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#release())() Releases the GVR Spatial Media renderer system. |\n| boolean | [triggerProcessing](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#triggerProcessing())() Triggers the processing of data that has been input but not yet processed. |\n| void | [updateNativeOrientation](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#updateNativeOrientation(float,%20float,%20float,%20float))(float w, float x, float y, float z) Sets current listener head orientation. |\n\nInherited Methods \nFrom class java.lang.Object \n\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object) arg0) |\n| final [Class](https://developer.android.com/reference/java/lang/Class)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors \n\npublic\n**GvrAudioSurround**\n(int surroundFormat, int sampleRateHz, int numInputChannels, int numFramesPerOutputBuffer) \nConstructs the GVR Audio surround system. \n\nParameters\n\n| surroundFormat | The surround format. One of the constants defined in [GvrAudioSurround.SurroundFormat](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround.SurroundFormat). |\n| sampleRateHz | Sampling rate of audio buffers. |\n| numInputChannels | Number of channels in input buffers. Note this must match with the selected rendering mode. |\n| numFramesPerOutputBuffer | Number of audio frames in stereo output buffers. |\n|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\nPublic Methods \n\npublic int\n**addInput**\n([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer) inputBuffer, int offset, int size) \nProvides data to the binaural renderer.\n\nIf enough data has been provided for output to be generated then it will be immediately\navailable via [getOutput(ByteBuffer, int, int)](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getOutput(java.nio.ByteBuffer,%20int,%20int)). The input data is copied into an internal buffer which allows\nthe caller to re-use the input buffer immediately. The available space in the internal buffer\ncan be obtained via [getAvailableInputSize()](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getAvailableInputSize()). \n\nParameters\n\n| inputBuffer | Interleaved int16 input buffer. |\n| offset | Offset in input buffer (in bytes) |\n| size | Maximum number of bytes to consume from the input buffer. |\n|-------------|-----------------------------------------------------------|\n\nReturns\n\n- Number of bytes consumed. \n\npublic void\n**flush**\n() \nDeletes all unprocessed and processed audio buffers. \n\npublic int\n**getAvailableInputSize**\n() \nReturns the size in bytes [addInput(ByteBuffer, int, int)](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#addInput(java.nio.ByteBuffer,%20int,%20int)) is currently able to consume. \n\nReturns\n\n- The size in bytes. \n\npublic int\n**getAvailableOutputSize**\n() \nReturns the number of bytes of available output data that can be read via [getOutput(ByteBuffer, int, int)](/vr/reference/android/com/google/vr/sdk/audio/GvrAudioSurround#getOutput(java.nio.ByteBuffer,%20int,%20int)). \n\nReturns\n\n- The size in bytes. \n\npublic int\n**getOutput**\n([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer) outputBuffer, int offset, int size) \nOutputs a binaural stereo buffer in interleaved little endian linear int16 format. \n\nParameters\n\n| outputBuffer | Output buffer. |\n| offset | Offset in output buffer (in bytes) |\n| size | Maximum number of bytes to write into the output buffer. |\n|--------------|----------------------------------------------------------|\n\nReturns\n\n- Number of bytes written. \n\npublic void\n**release**\n() \nReleases the GVR Spatial Media renderer system. \n\npublic boolean\n**triggerProcessing**\n() \nTriggers the processing of data that has been input but not yet processed.\n\nNote after calling this method, all binaural output must be consumed before new input\nbuffers can be added. \n\nReturns\n\n- Whether any data was processed. \n\npublic void\n**updateNativeOrientation**\n(float w, float x, float y, float z) \nSets current listener head orientation. \n\nParameters\n\n| w | W component of quaternion. |\n| x | X component of quaternion. |\n| y | Y component of quaternion. |\n| z | Z component of quaternion. |\n|---|----------------------------|"]]