GuidesReferenceIssuesSupportGet API Key


Adding audio to your scenes

Viro supports three forms of audio: stereo sound, spatial sound, and ambisonic sound fields. Sprinkling environments with sound helps to add true immersion to your scenes; they draw the listener's attention and provide cues on where to look next. Viro supports three forms of sound.

Stereo Sound

Many scenes benefit from having a background sound track, either in the form of music or ambient noise like wind or ocean waves. You can add background audio to your scene by utilizing the Sound object. The audio to be played is specified with a URI, as in the following example.

Sound sound = new Sound(context, Uri.parse(""), null);

Sound can also be used for short sound effects. To replay such a sound, either set loop to true, or toggle between pause() and play(). Finally, these sounds also provide callbacks via the PlaybackListener.

Spatial Sound


Not supported on iOS

Spatial sound is currently supported on Cardboard (Android), Daydream, and Gear VR


Mono sounds only

Spatial sound only works with single-channel sounds.

Spatial sound is positioned audio that can travel throughout a scene. For example, you can create a spatial sound that animates along with a bird, chirping as it flies through the scene. To create spatial sounds, use SpatialSound. This component supports all the properties of Sound, and adds new properties that define how the sound travels.

The new properties are:

  • position indicates the position of the sound within the coordinate space of its parent node
  • distanceRolloff specifies the distance from the sound at which it starts and ends attenuating, and the curve of the attenuation

Most importantly, SpatialSounds can be attached to Nodes in the scene graph, and can be animated along with visual objects. In the example below, the 'chirp' sound follows the bird 3D object. We can do this by adding both the sound and the 3D object to the same node. Then we simply have to animate this parent node.

SpatialSound chirp = new SpatialSound(context, Uri.parse("chirp.mp3"), null);

Object3D bird = new Objec3D();
bird.loadModel(Uri.parse("bird.vrx"), Type.FBX, new AsyncObject3DListener() {
    public void onObject3DFailed(String error) {
        Log.w(TAG, "Failed to load the model");
    public void onObject3DLoaded(Object3D object, Object3D.Type type)
        // Start chirping after the bird is loaded;

Node node = new Node();

// Animate the bird to the right; this will animate the chirp sound as well
node.setPosition(new Vector(10, 0, 0));

Ambisonic Sound Fields


Not supported on iOS

Ambisonic sound fields are currently supported on Cardboard (Android), Daydream, and GearVR

Ambisonic sound fields emit environmental sound from every direction. They are the audio equivalent of a skybox or 360 image, providing atmospheric background noise. These sounds respond to the user's head rotation.

Producing ambisonic sound is beyond the scope of this document, but if you have ambisonic sound files, you can load them into Viro via the SoundField object. This object shares the same properties as Sound, and can additionally be rotated about the Z axis with the rotation property. Reverb properties for SoundField can also be set to simulate various environments and materials.