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.

+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.
...