Oculus Spatializer Plugin for Unity - Requirements and Setup

The Oculus Native Spatializer Plugin (ONSP) is an plugin for Unity that allows monophonic sound sources to be spatialized in 3D relative to the user’s head location. In addition, you can use the plugin for audio propagation, which provides real-time reverb and occlusion simulation based on game geometry.

The spatializer ships as a part of Oculus’s integration package for Unity or can be downloaded and enabled as a standalone plugin.

For a detailed discussion of audio spatialization and virtual reality audio, you can review the Introduction to Virtual Reality Audio guide. If you’re unfamiliar with Unity’s audio handling, be sure to review the Unity Audio guide.

Requirements

Import and Enable the Spatializer

You can either download the spatializer as a stand-alone utility, or install the Oculus integration package, which includes the spatializer.

  • Import the Oculus Integration Package

    -OR-

  • Download the Oculus Spatializer Unity package from the Audio Packages page.

    • Extract the zip.
    • Open your project in the Unity Editor, or create a new project.
    • Select Assets > Import Package > Custom Package
    • Select OculusNativeSpatializer.unitypackage and import.
    • When the Importing Package dialog opens, leave all assets selected and click Import.

Enable the Oculus Spatializer:

Whether you use the Oculus integration package, or download only the audio package, follow these instructions to enable the spatializer.

  1. Open or create a project in Unity and go to Edit > Project Settings > Audio to open the AudioManager dialog.
  2. In the Inspector, select OculusSpatializer in the Spatializer Plugin selection box.
  3. Set Default Speaker Mode to Stereo.
  4. For Rift, set DSP Buffer Size to Best latency to set up the minimum supported buffer size for the platform, reducing overall audio latency. For mobile, set DSP Buffer Size to Good or Default to avoid audio distortion.

    The following image shows an example of the Rift setting:

Note: Be aware that CPU usage increases when early reflections are turned on, and increases proportionately as room dimensions become larger.

Update the Oculus Native Spatializer for Unity

Follow these instructions if you need to update the version of the plugin that you are using.

  1. Note the settings used in OSPManager in your project.
  2. Replace OSPAudioSource.cs (from previous OSP) on AudioSources with ONSPAudioSource.cs in {project}/Assets/OSP.
  3. Set the appropriate values previously used in OSPManager in the plugin effect found on the mixer channel. Note that the native plugin adds functionality, so you will need to adjust to this new set of parameters.
  4. Remove OSPManager from the project by deleting OSPManager*.* from {project}/Assets/OSPexcept your newly-added ONSPAudioSource.cs.
  5. Verify that OculusSpatializer is set in the Audio Manager and that Spatialization is enabled for that voice.

Use the functions on AudioSource to start, stop and modify sounds as required.