Community Q&A

Welcome to Audiokinetic’s community-driven Q&A forum. This is the place where Wwise and Strata users help each other out. For direct help from our team, please use the Support Tickets page. To report a bug, use the Bug Report option in the Audiokinetic Launcher. (Note that Bug Reports submitted to the Q&A forum will be rejected. Using our dedicated Bug Report system ensures your report is seen by the right people and has the best chance of being fixed.)

To get the best answers quickly, follow these tips when posting a question:

  • Be Specific: What are you trying to achieve, or what specific issue are you running into?
  • Include Key Details: Include details like your Wwise and game engine versions, operating system, etc.
  • Explain What You've Tried: Let others know what troubleshooting steps you've already taken.
  • Focus on the Facts: Describe the technical facts of your issue. Focusing on the problem helps others find a solution quickly.

+1 vote

I'm on Wwise version 2021.1.5.7749. I'm looking for a way to validate a switch state ID after setting it.

Switch groups are sometimes set to their default value because of spelling mistakes in the target switch state string. In the Wwise profiler you see the "SetSwitch" call and instead of the requested value you see "Default". (If a default exists it obviously makes sense to apply this value when an invalid value is requested). I'd like to be able to catch those instances.

At the point of setting the switch we call AK::SoundEngine::SetSwitch:

        // Inputs are:
        AkSwitchGroupID targetSwitchGroupID;
        AkSwitchStateID targetSwitchStateID;
        AkGameObjectID gameObjectID;

        // Attempt to change the switch. Note: AK documentation states we *always* returns AK_Success from SetSwitch.
        const AKRESULT result = AK::SoundEngine::SetSwitch(targetSwitchGroupID, targetSwitchStateID, gameObjectID);


SetSwitch pushes the request into the command queue. We record this request ourselves and mark it against the current audio thread frame. At some point the audio thread calls AK::SoundEngine::RenderAudio() and processes the queue. The audio frame counter is incremented. On the next tick (any thread other than the audio thread) we process the list of requests we made and look for anything we haven't yet validated. Any requests recorded against a previous frame can be validated because that frame's command queue has been processed.

Naively I expected to be able to request the currently applied switch state using AK::SoundEngine::GetSwitch:

#if !_RELEASE

        // Verify that the switch we requested was actually applied.
        AkSwitchStateID appliedSwitchState{ 0 };
        AK::SoundEngine::Query::GetSwitch(targetSwitchGroupID, gameObjectID, appliedSwitchState);
        if (appliedSwitchState != targetSwitchStateID)
        {
            LOG("The switch was not as expected.");
            return;
        }
#endif // !_RELEASE

Unfortunately this fails because "targetSwitchStateID" (the state we recorded to validate against) always matches the switch state returned from AK::SoundEngine::Query::GetSwitch. Instead of returning the currently applied state, which could be either "Default" or the requested state, we are always returned the requested state.

Is there a way to get the the switch state that is actually applied, rather than the (invalid) state we requested?

in General Discussion by Gareth M. (120 points)
edited by Gareth M.

Please sign-in or register to answer this question.

...