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.

댓글 달기

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

다른 글

잔향도 공간화가 필요합니다: Wwise Spatial Audio의 Room과 Portal 가이드

최근에 공간 음향에 대한 관심이 아주 뜨거워졌습니다. 하지만 사실 '공간 음향'이 의미하는 것은 매우 다양할 뿐만 아니라 사용할 수 있는 옵션이 너무 많아 어렵게 느껴질 수...

6.8.2019 - 작성자: 네이튼 해리스 (NATHAN HARRIS)

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

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

9.6.2020 - 작성자: Bradley Meyer

Wwise 저작 쿼리 언어, WAQL을 소개합니다

“Wwise는 스프레드시트(표 계산 소프트웨어) 같아요”. 이 말은 제가 사용자 환경팀으로서 자주 듣는 말입니다. 사실 Wwise는 사운드 디자인 도구이지만 사실 안을 들춰보면...

24.6.2021 - 작성자: 베르나르 로드리그 (Bernard Rodrigue)

Event-Based Packaging(이벤트 기반 패키징)이란?

Event-Based Packaging(이벤트 기반 패키징)이란 무엇일까요? 얼마 전에 Wwise 2019.2 UE4 통합은 Event-Based Packaging(이벤트 기반...

10.8.2021 - 작성자: 판 룬펑 (Fan Runpeng)

Impacter의 교차 합성 변형음 시각화하기

Impacter 플러그인 블로그 시리즈에 다시 오신 것을 환영합니다. 이전 두 블로그에서는 플러그인의 물리적 매개 변수와 이 매개 변수가 게임의 물리 시스템과 잘 통합될 수 있는...

2.2.2022 - 작성자: 라이언 돈 (RYAN DONE)

Strata 멀티트랙 SFX 라이브러리를 먼저 사용해본 사람들은 이렇게 말했습니다.

Strata의 시작 지난 40~50년 동안 SFX 라이브러리 제작자들은 거의 동일한 방식으로 콘텐츠를 제작하고 배포했습니다.디자인한 사운드를 녹음, 믹싱, 렌더링하고 테마별...

1.12.2022 - 작성자: 시몽 아슈비 (Simon Ashby)

다른 글

잔향도 공간화가 필요합니다: Wwise Spatial Audio의 Room과 Portal 가이드

최근에 공간 음향에 대한 관심이 아주 뜨거워졌습니다. 하지만 사실 '공간 음향'이 의미하는 것은 매우 다양할 뿐만 아니라 사용할 수 있는 옵션이 너무 많아 어렵게 느껴질 수...

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

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

Wwise 저작 쿼리 언어, WAQL을 소개합니다

“Wwise는 스프레드시트(표 계산 소프트웨어) 같아요”. 이 말은 제가 사용자 환경팀으로서 자주 듣는 말입니다. 사실 Wwise는 사운드 디자인 도구이지만 사실 안을 들춰보면...