Rift Audio
When setting up audio for the Rift, you need to determine whether the Rift headphones are active and pause the audio when your app doesn’t have focus.
The user can enable the Rift headphones and microphone in the Oculus App or use the default Windows audio devices. Configuration is made in the Oculus App in Devices. The following screenshot shows the Rift headphones disabled and the microphone enabled:

The headphone setting is handled automatically by the function ovr_GetAudioDeviceOutGuid
(located in OVR_CAPI_Audio.h
), which returns the GUID for the device to target when playing audio. Similarly, use ovr_GetAudioDeviceInGuid
to identify the microphone device used for input.
FMOD D for Native Rift Development
If you detect that the Rift headphones are enabled, use code similar to the following for FMOD:
ERRCHECK(FMOD::System_Create(&sys));
GUIDguid;
ovr_GetAudioDeviceOutGuid(&guid);
intdriverCount=0;
sys->getNumDrivers(&driverCount);
intdriver=0;
while(driver<driverCount)
{
charname[256]={0};
FMOD_GUIDfmodGuid={0};
sys->getDriverInfo(driver,name,256,&fmodGuid,nullptr,nullptr,nullptr);
if(guid.Data1==fmodGuid.Data1&&
guid.Data2==fmodGuid.Data2&&
guid.Data3==fmodGuid.Data3&&
memcmp(guid.Data4,fmodGuid.Data4,8)==0)
{
break;
}
++driver;
}
if(driver<driverCount)
{
sys->setDriver(driver);
}
else
{
// error rift not connected
}
For instructions on using FMOD with Unreal Engine, see “Unreal and FMOD” below.
Wwise for Native Rift Development
If you detect that the Rift headphones are enabled, use code similar to the following for Wwise:
AkInitSettings initSettings;
AkPlatformInitSettings platformInitSettings;
AK::SoundEngine::GetDefaultInitSettings( initSettings );
AK::SoundEngine::GetDefaultPlatformInitSettings( platformInitSettings );
// Configure initSettings and platformInitSettings...
WCHAR outStr[128];
if (OVR_SUCCESS(ovr_GetAudioDeviceOutGuidStr(outStr)))
{
initSettings.eMainOutputType = AkAudioAPI::AkAPI_Wasapi;
platformInitSettings.idAudioDevice = AK::GetDeviceIDFromName(outStr);
}
For instructions on using Wwise with Unity 5, see “Unity 5 and Wwise” below. For instructions on using Wwise with Unreal Engine, see “Unreal and Wwise” below.
Audio input and output automatically use the Rift microphone and headphones unless configured to use the Windows default audio device by the user in the Oculus App. Events OVRManager.AudioOutChanged
and AudioInChanged
occur when audio devices change, making audio playback impossible without a restart.
To configure Wwise to use to configured audio device in Unity 5, pass the user-configured audio device name/GUID (set in the Oculus App) into the function AkSoundEngine.GetDeviceIDFromName()
, located in AkInitializer.cs
.
To get the audio device GUID from libOVR, you must include the Oculus Utilities unitypackage, which exposes that string through the class OVRManager
.
The following function should be called before AkSoundEngine.Init(...
):
void SetRiftAudioDevice(AkPlatformInitSettings settings)
{
string audioDevice = OVRManager.audioOutId;
uint audioOutId = AkSoundEngine.GetDeviceIDFromName (audioDevice);
settings.idAudioDevice = audioOutId;
}
Pass AkPlatformInitSettings
into the function above and use it to initialize the Ak sound engine.
VR Audio Output in Rift Store > Settings > Devices > Rift Headset may be used to configure which input mic to use within the Ak sound engine. The GUID for this is exposed through OVRManager.audioInId.
Audio input and output automatically use the Rift microphone and headphones, unless configured to use the Windows default audio device by the user in the Oculus app.
The Rift’s microphone is not used by default when calling Microphone.Start(null,..)
. Find the entry in Microphone.devices that contains the word Rift and use it.
When Unreal PC applications are launched, if the OculusRift plugin is enabled and the Oculus VR Runtime Service is installed, then the application will automatically override the default Windows graphics and audio devices and target the Rift. The Oculus VR Runtime Service is installed with the Oculus App.
Unless your application is intended to run in VR, do not enable the OculusRift plugin. Otherwise, it is possible that audio and/or video will be incorrectly targeted to the Oculus Rift when the application is run.
Alternatively, users can disable loading all HMD plugins by specifying -nohmd
on the command line.
Note: The link above links to build Wwise 2016.1 build 5775 for use with Unity 4.12. Be sure to select the appropriate build for your Unity version in the upper-left.

For an illustration of how to target the Oculus Rift headphones using FMOD in Unreal Engine, see the FMOD section above.
To target the Oculus Rift headphones using FMOD in Unity 5, use the following code snippet:
FMOD.System sys;
FMODUnity.RuntimeManager.StudioSystem.getLowLevelSystem(out sys);
int driverCount = 0;
sys.getNumDrivers(out driverCount);
string riftId = OVRManager.audioOutId;
int driver = 0;
while (driver < driverCount)
{
System.Guid guid;
int rate, channels;
FMOD.SPEAKERMODE mode;
sys.getDriverInfo(driver, out guid, out rate, out mode, out channels);
if (guid.ToString() == riftId)
{
break;
}
++driver;
}
if(driver < driverCount)
{
sys.setDriver(driver);
}
Oculus Audio Spatialization
The Oculus Audio SDK, available from our Downloads page, provides free, easy-to-use spatializer plugins for engines and middleware. Our spatialization features support both Oculus Rift and Mobile development.
For a detailed discussion of audio spatialization and virtual reality audio, we recommend beginning with our Introduction to Virtual Reality Audio and Oculus Audio SDK guides.
For additional information on using Oculus spatializer plugins with Unity and Unreal, see Unity Audio and Unreal VR Audio.
VR Sound Level Best Practices
Audio is an important part of the virtual reality experience, and it is important that all VR apps provide a comfortable listening level for users. Developers should target a reasonable sound level that is consistent between different experiences. To achieve this, consider the following best practices.
Second, measure your experience against the audio levels in published Oculus Rift experiences, especially the ambient audio in Home and the Dreamdeck experience. Set overall system volume so that Dreamdeck and Home sound comfortable, and then adjust your experience’s mix to this volume.
Finally, mix your application using the Rift headphones. This ensures that the sounds you’re creating and mixing have a frequency content appropriate for the headphones most users will use.