A Step-by-Step WAAPI Example

오디오 프로그래밍 / 신규 출시 / Wwise에 대한 팁과 도구

image5.png

In my previous article, we reviewed a few of the various possibilities where the Wwise Authoring API (WAAPI) can be used to integrate Wwise with other applications, and also to add custom functionalities to Wwise. In a nutshell, WAAPI allows any applications or scripts to remote-control, query, or modify the Wwise project data. WAAPI, therefore, opens all kinds of possibilities.

Today, we will walk through an example of putting WAAPI to use. We will look at the implementation of a simple web application which, with a single movable point, provides an X-Y pad to control two game parameters at the same time within a 2-dimensional area. The application connects to the currently opened project and displays the available Game Parameter objects.

This sample will demonstrate the following functionalities:

  • Retrieving objects from a project
  • Setting object property values
  • Updating on property value change

Creating a Wwise Project

The nice thing about this demonstration is that it works with any Wwise project. But for this article, we will create a simple Wwise project that implements a Theremin musical instrument.


Create a new project

image8.png

Create the Theremin Sound

In the Project Explorer:

  • Create a new Sound SFX object.
  • Name it Theremin.

image9.png

  • Select the newly created object.
  • In the Contents Editor, Click the Add Source >> button.
  • Select Wwise Synth One.

image11.png

  • In the Property Editor for the Theremin object, enable Loop.

image1.png

Associate Game Parameters

  • Go to the RTPC tab of the Theremin object.
  • Assign two new Game Parameters “Volume” and “Pitch” to the Voice Volume and Voice Pitch properties.
  • Modify the Voice Pitch curve as shown below.

image13.png

That’s it. Now save your project!

Enable WAAPI in Wwise

Before you start using WAAPI, make sure you enable WAAPI in the User Preferences:

    • Click menu Project > User Preferences.
    • Click Enable Wwise Authoring API.
    • Click OK.
    • Restart Wwise.

image10.png

The WAAPI client

Now let’s take a look at the actual web application.

image14.png

This application shows a blue dot, which allows to modify two distinct game parameter values while connected to Wwise. Once connected, the sample will retrieve the list of game parameters from the project. In our example, it retrieved the Pitch and Volume game parameters. From there, we can hit Play in Wwise and move the little blue point to get our theremin working.

The source code

OK, let’s look at how this has been implemented with WAAPI.

For reference, you will be able to find the complete source code of this application in the Wwise 2017.1 SDK samples:
SDK/samples/WwiseAuthoringAPI/js/xy-pad.

Please take a moment to look at the readme.md file to learn how you can install dependencies and how to run the sample. This is crucial because the sample won’t work if you don’t install dependencies.

Most of the code for the application is located in js/app.js.

Connecting to WAAPI

Connecting to WAAPI is fairly simple. This example is using autobahn.js, which provides a complete WAMP implementation in JavaScript. The most important element is the URL to connect to WAAPI. Keep in mind the WAAPI server is built into the Wwise Authoring application, so make sure Wwise is running before you try to connect. Here, we create the connection object to localhost on port 8080.

image6.png

From there, we can connect:

image4.png

Once the connection is established, WAMP has two mechanisms by which it communicates:

  • Remote Procedure Call (RPC): Execute a function remotely, with arguments, and obtain results.
  • Subscribe/Publish (Pub/Sub): Register to a specific topic, and get notified when something is published about that topic.

Calling an RPC function with autobahn.js is also very straightforward. You need to specify the following elements:

  • URI: The unique name of the RPC function
  • Args: Arguments for the function, described as a JSON object. The Wwise SDK documentation describes all arguments required for every RPC call.
  • Options: Options for the function. Can be an empty object.

Then, the call function will return a promise object, which can be used to specify a success callback to receive the results, and an error callback to receive the errors.

A typical call would look this this:

image7.png

Obtaining the Game Parameters

One of the first calls made by the sample is to retrieve all game parameters of the project:

image3.png

This remotely calls the URI ak.wwise.core.object.get, which takes a query object as arguments, and returns a list of objects with the specified options. In this scenario, the query specifies a source (from all objects of type “GameParameter”), which returns all game parameters.

Then the option component specifies what to return from these objects. This allows you to capture plenty of information from a single query.

Setting Properties

When the blue dot is moved in the user interface, it calls the RPC URI ak.wwise.core.object.setProperty, which allows for any property of any Wwise object to be modified. In this scenario, we specify the ID of the object, the property to modify, and the new value to set:

image12.png

Getting notified when a property changed

Modifying the Game Parameter simulation value directly inside Wwise will also update the x-y pad application automatically, because we subscribed to the topic ak.wwise.core.object.propertyChanged. The blue dot is two-way bound to the actual Game Parameter value.

Subscribing to a topic is simple: you provide the topic URI and the subscription options. In this case, we need to specify which object and property we are interested in. We can even specify what to return in the callback:

image2.png

Conclusion

This sample only covers the tip of the iceberg in terms of functionality for WAAPI. Take a look at the WAAPI documentation to find out more about all functions available, what arguments they require, and what they return.

Keep in mind that WAAPI is language and platform independent, which means you can implement clients in many different languages, and on virtually any platform. The WAMP protocol, which is used for convenience and performance, is also an optional communication protocol. Bare HTTP is also supported. Someone could actually use WAAPI on HTTP with cURL on the command line: 

curl -H "Content-Type: application/json" -X POST -d "{\"args\":{},\"options\":{},\"uri\":\"ak.wwise.core.getInfo\"}" http://localhost:8090/waapi

 

Homework

Modify the sample

Here are some exercises for you to do in this sample:

  • Add a Play/Stop button (look at the transport example)
  • Show a grid in the x-y viewport

To learn more

Implementing Javascript client applications can either be a lot of fun or, perhaps, scary if you are an old-school C++ developer. Here are a few subjects you can read about on the web:

  • Javascript, promises, asynchronous code.
  • Node.js: execute JavaScript at command line, run web servers.
  • Typescript: do safe JavaScript.
  • Javascript client frameworks: React, Angular.js, Vue.js, aurelia.




Subscribe

Bernard Rodrigue

Director, Wwise Experience

Audiokinetic

Bernard Rodrigue

Director, Wwise Experience

Audiokinetic

Bernard Rodrigue is Director, Wwise Experience at Audiokinetic. He joined Audiokinetic in 2005 and actively participated in developing the foundations of Wwise. Today, Bernard continues to lead several projects related to the advancement and expansion of Wwise.

 @decasteljau

댓글

Ben Nix-Bradley

July 15, 2019 at 05:23 pm

I'm trying to find help generating visualization from wwise. Like making a VU meter in unity or other visual feedback that could be derived from spectral analysis. How do I do that with this tool? It's a very difficult thing to find with the language that I know. I've been looking through the documentation and integration guides for a couple weeks and don't have so much information about the audio buffer or even a similar entry point that I could roll other FFT operations from scratch... losing train of thought.. please help.

댓글 달기

이메일 주소는 공개되지 않습니다.

다른 글

새로운 기능 개요 2019.2

Profiler Filtering (프로파일러 필터링) Capture 세션을 보면, 주어진 시간 안에 생기는 많은 캡처 데이터를 어렵지 않게 발견할 수 있습니다. 이는...

14.2.2020 - 작성자: Audiokinetic

Wwise State-based Mixing의 새로운 기능 - 온갖 파라미터들!

2017.1 이전에는 States 탭에서는 볼륨, 피치, 저역-통과 필터, 하이패스 필터 및 메이크업 게인과 같은 비교적 적은 수의 파라미터에만 액세스할 수...

9.6.2020 - 작성자: Bradley Meyer

누구나 사용할 수 있는 WAAPI - 제 1부: 개요

안녕하세요. 저는 왕양 (汪洋) 이라고 합니다 (혹은 ‘씨 예’, 溪夜라고도 불립니다). 저는 작년 하반기에 WAAPI에 대해 알게 되었습니다 (Wwise 저작 API). 저같이...

30.3.2021 - 작성자: 토마스 왕 (THOMAS WANG, 汪洋)

Wwise Spatial Audio 2023.1의 새로운 기능 | Reverb Zone (리버브 존)

Reverb Zone 소개 Wwise 2023.1은 Wwise Spatial Audio에 Reverb Zone (리버브 존)이라는 새로운 도구를 추가했습니다. Reverb...

9.5.2025 - 작성자: 토마스 한슨 (Thomas Hansen)

Wwise Time Stretch 플러그인을 활용한 인게임 시네마틱 제어

소개 이 글은 제이터 (루오하오) 쉬(Jater (Ruohao) Xu)가 역붕괴: 베이커리 작전(Reverse Collapse: Code Name Bakery)에서 진행한 작업을...

9.7.2025 - 작성자: Ruohao (Jater) Xu (루오하오 (제이터) 쉬)

Wwise 2025.1: Media Pool(미디어 풀)과 Similar Sound Search(유사 사운드 검색)

Media Pool (미디어 풀)

22.8.2025 - 작성자: Audiokinetic (오디오키네틱)

다른 글

새로운 기능 개요 2019.2

Profiler Filtering (프로파일러 필터링) Capture 세션을 보면, 주어진 시간 안에 생기는 많은 캡처 데이터를 어렵지 않게 발견할 수 있습니다. 이는...

Wwise State-based Mixing의 새로운 기능 - 온갖 파라미터들!

2017.1 이전에는 States 탭에서는 볼륨, 피치, 저역-통과 필터, 하이패스 필터 및 메이크업 게인과 같은 비교적 적은 수의 파라미터에만 액세스할 수...

누구나 사용할 수 있는 WAAPI - 제 1부: 개요

안녕하세요. 저는 왕양 (汪洋) 이라고 합니다 (혹은 ‘씨 예’, 溪夜라고도 불립니다). 저는 작년 하반기에 WAAPI에 대해 알게 되었습니다 (Wwise 저작 API). 저같이...