I'm new to using Wwise but I'm looking at using it with my Unity-based project and looking at using the Oculus Spatializer plugin too. I'm using Wwise 2018.1, Unity 2019.3 and the latest spatializer plugin and seem to have the basics working with a Wwise test event triggering playback. The problem is that it's playing audio via the Windows default audio device instead of via the headset's headphones (testing with a Rift S), whereas the built-in Unity Audio Listener correctly outputs to the HMD headphones as expected.
which imply some people are resorting to editing the Wwise C# code in order to configure the Oculus output device but I'm reluctant to do that unless that's really the only practical way. It sounds surprising that it should really be necessary to have to do that, since it will presumably become a hassle to manage updates to the Wwise integration if always having to merge in custom changes.
I wonder if anyone here with more experience working with Wwise + Unity can give any tips / recommendations for how to configure the output device appropriately for Oculus in a maintainable way?
Hmm, I'm losing more time battling formatting bugs in this forum trying to post an answer to my question than I did in the end figuring out a way to solve my problem. 😕 This post editor won't let me quote my code and I think it's got into a confused/broken state now so I'm posting this dummy reply to try and unwedge it.
ok, I give up - the 'Quote' and 'Code' formatting features for this forum don't seem to work 😕 (code quote just shows one line and regular quote adds extra blank lines between everything - maybe it's not expecting Windows linefeed endings, I don't know) 😕 The preview also shows a strange indent with a red line at the beginning and I have no idea what that's about but it doesn't show up in the final post.
Anyway, I found that instead of modifying AkWwiseInitializationSettings.cs it was possible to create a separate OculusWwiseInitialize Component that would setup the appropriate output device on Windows:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class OculusWwiseInitialize : MonoBehaviour { void Awake() { if (AkBasePathGetter.GetPlatformName() == "Windows") { Debug.LogError("Initializing output device..."); AkWindowsSettings akWindowsSettings = (AkWindowsSettings)AkWwiseInitializationSettings.ActivePlatformSettings; if (akWindowsSettings) { string audioDevice = OVRManager.audioOutId; uint audioOutId = AkSoundEngine.GetDeviceIDFromName(audioDevice); akWindowsSettings.UserSettings.m_MainOutputSettings.m_DeviceID = audioOutId; } } } }
Under Project Settings -> Script Execution Order I've then tweaked the order to be like:
OculusWwiseInitialize OVRManager
AkInitializer
It think it would really help if the documentation under https://developer.oculus.com/documentation/unity/audio-osp-wwise/ could show an example of how to do this or there could be some other documentation that would solve this problem in a different / better way.
I'd still love to know if there is some other simpler / nicer way of handling this since I have the impression that this is a very common combination of tools and this seemed like quite a fiddly / undocumented detail that I was only able to resolve by digging through the Wwise C# initialization code.
Following on from this I've had quite a lot of difficulty working with Wwise in Unity when testing with an Oculus Quest + Link cable.
With a Rift S when you aren't in play mode at least you can hear sound through the headset, but also if you unplug the headset then Wwise will automatically re-initialize and you can hear audio through your default audio device. (E.g. if you press the 'Play' buttons attached to AkAmbient or AkEvent components)
With the Quest + Link cable then once the headset goes idle then sound directed to the Oculus Virtual Audio Device goes nowhere but it also seems that you can't simply disconnect the headset to revert to the default device. Once you've initialized the audio with the link cable it will stay in that state.
I ended up adding a button to the inspector to force Wwise to shutdown so it can be re-initialized with a non-oculus device....
using UnityEditor;
[CustomEditor(typeof(OculusWwiseInitialize))] public class OculusWwiseInitializeInspector : Editor { public override void OnInspectorGUI() { DrawDefaultInspector();
if (GUILayout.Button("Terminate Wwise")) { AkWindowsSettings akWindowsSettings = (AkWindowsSettings)AkWwiseInitializationSettings.ActivePlatformSettings; if (akWindowsSettings) { var oculusWwise = (OculusWwiseInitialize)target; var akInitializer = oculusWwise.gameObject.GetComponent<AkInitializer>(); var engineController = AkSoundEngineController.Instance; if (engineController != null) { engineController.Terminate(); } } } } }
I now also have a property for the OculusWwiseInitialize component that lets me disable setting the Oculus device as the Wwise output device.
I also have a hack for being able to explicitly specify the Windows MMDevice ID for an alternative audio end point to use so I can explicitly control which device I want to output to from the editor but for now it's not very practical when you need a separate program to determine what those device IDs are.
Urgh, nah, I'm just going mad here - this stuff just doesn't work 😞 I can't find any sense to why Wwise audio output sometimes works and sometimes doesn't - it was working last night, and I haven't changed anything but now it doesn't work again. My hack for force terminating the Wwise engine doesn't work for me currently and I'm not sure its even trying to output to the the oculus virtual audio device currently.
Would still really love to hear from anyone that's using Wwise with Unity + the Oculus Spatializer plugin - I'm worrying now that maybe very few people actually use this stuff (it's hard to imagine many people jumping through so many hurdles) so it could be a bad idea to start depend on it.
Maybe the real issue is that the Oculus Spatializer really needs to be fixed to work with the latest Wwise 2019 and Wwise 2018 has poor integration which I'm hitting?