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

Hey, I'm experimenting with waapi to get a better understanding of its features and find its use in my day to day development. So far I've been successful in integrating it as an engine API and retrieving items selected in Wwise authoring and subscribing to authoring onSelectionChanged events. Unfortunately I cannot find a way to push a ui command back to wwise authoring using the waapi. Regardless of what I try, it always results in std::future throwing exceptions regarding the results of the attempted action. Since there's no example of passing such a command through waapi in the sample waapi client, I've been trying and failing to make it work for me, but to no result.

Could you give me an example of how a ui command can be passed?

Here's how I'm attempting to get this done:

AkJson args(AkJson::Map
{
    {
        "command", AkVariant("FindInProjectExplorerNoSyncGroup")
    },
    {
        "objects", AkJson::Array
        {
            AkVariant( (std::string)GUID.AsChar() ),
        },
    }
});
m_waapiConnectionClient->Call( ak::wwise::ui::commands::execute, args, AkJson( AkJson::Map() ), AkJson( AkJson::Map() ) );
I've also tried a variant with passing in a reference for the results map, but the result was the same.
I would appreciate an example of using this functionality. Thanks!
in General Discussion by Adrian Jakubiak (140 points)

1 Answer

0 votes
 
Best answer

Here is the example to do what you need:
https://gist.github.com/decasteljau/00aa842b6985aefc2e3772c7aad00ce8

(make sure you pass an uninitialized AkJson variable as the result, as the result object is also being used for errors)

 

using namespace AK::WwiseAuthoringAPI;

void PrintApiError(const char* in_functionName, AkJson in_json)
{
    std::cout << "Failed to call '" << in_functionName << "' with error: " << std::string(RapidJsonUtils::GetAkJsonString(in_json)) << std::endl;
}

void HelloWorld()
{
    Client client;

    // Connect to Wwise Authoring on localhost.
    if (!client.Connect("127.0.0.1", 8080))
    {
        std::cout << "Could not connect to Wwise Authoring on localhost." << std::endl;
        return;
    }

    AkJson selectedResult;
    if (!client.Call(ak::wwise::ui::getSelectedObjects, AkJson::Map{}, AkJson::Map{}, selectedResult))
    {
        PrintApiError(ak::wwise::ui::getSelectedObjects, selectedResult);
        return;
    }

    if (selectedResult["objects"].GetArray().size() >= 1)
    {
        AkJson args(AkJson::Map
        {
            { "command", AkVariant("FindInProjectExplorerNoSyncGroup") },
            { "objects", AkJson::Array{
                selectedResult["objects"].GetArray()[0]["id"] } }
        });
        AkJson executeResult;
        if (!client.Call(ak::wwise::ui::commands::execute, args, AkJson(AkJson::Map()), executeResult))
        {
            PrintApiError(ak::wwise::ui::commands::execute, executeResult);
            return;
        }
    }
}
by Bernard R. (Audiokinetic) (35.8k points)
edited by Bernard R. (Audiokinetic)
Thanks a lot for a quick response! Turned out my code worked just fine - I compiled it today and it's all good. I will mark this as an answer, hopefully somebody else will find this interesting when they struggle to get command passing to work.
...