Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes

I've managed to change audio output using wwise in unity, but am now getting a lot of errors:

code:
https://imgur.com/ezIEuxE

    private void OutputDropdownValueChanged(OutputRef output) {
        // this is the correct device name
        string audioDevice = output.name;
        uint audioOutId = AkSoundEngine.GetDeviceIDFromName(audioDevice);
        
        if (AkBasePathGetter.GetPlatformName() == "Windows") {
            AkWindowsSettings akWindowsSettings = (AkWindowsSettings)AkWwiseInitializationSettings.ActivePlatformSettings;
            if (akWindowsSettings) {
                Debug.Log($"audioDevice={audioDevice},audioOutId={audioOutId}, m_DeviceID=" +
                    $"{akWindowsSettings.UserSettings.m_MainOutputSettings.m_DeviceID}");
                akWindowsSettings.UserSettings.m_MainOutputSettings.m_DeviceID = audioOutId;                
            }
        } else {
            Debug.Log($"audioDevice={audioDevice},audioOutId={audioOutId}, m_DeviceID=" +
                $"{AkWwiseInitializationSettings.ActivePlatformSettings.AkInitializationSettings.initSettings.settingsMainOutput.idDevice}");
        }
        AkInitializationSettings akInitializationSettings = AkWwiseInitializationSettings.ActivePlatformSettings.AkInitializationSettings;
        akInitializationSettings.initSettings.settingsMainOutput.idDevice = audioOutId;

        // so far so good

        /*
        var cam = Camera.main;
        AkGameObj akGameObj = cam.GetComponent<AkGameObj>();
        AkRoomAwareObject akRoomAwareObject = cam.GetComponent<AkRoomAwareObject>();
        AkRoomAwareManager.UnregisterRoomAwareObject(akRoomAwareObject);
        AkSoundEngine.UnregisterGameObj(akGameObj.gameObject);
        akGameObj.enabled = false;
        akRoomAwareObject.enabled = false;
        cam.GetComponent<AkAudioListener>().enabled = false;
        cam.GetComponent<AkSpatialAudioListener>().enabled = false;
        */

        if (AkSoundEngine.IsInitialized()) {
            Debug.Log("terminating AkSoundEngine so we could re-init it");
            AkSoundEngine.Term();
            // works fine ^
        }
        var success = AkWwiseInitializationSettings.InitializeSoundEngine();
        Debug.Log($"InitializeSoundEngine success={success}");
        // also works fine (returns success) but i still get the errors even when the section above is uncommented :(

    }


errors:
https://imgur.com/h7mQx5x

Wwise: Unknown game object ID. Make sure the game object is registered before using it and do not use it once it was unregistered.: 2 (GameObject: Avatar: ido (UnityEngine.GameObject)) (Instance ID: 18446744073709548102)

The above happens even if i unregister/disable all AkGameObjects as in the commented out lines. Is there something else I need to do to un- & re-register everything after outout device change?
in General Discussion by Ido Y. (100 points)
edited by Ido Y.

Please sign-in or register to answer this question.

...