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와 REAPER의 연결: Part 2 - ReaOpen

ReaOpen은 오디오 파일을 선택하고 원래의 REAPER 프로젝트를 쉽게 열 수 있는 무료의 가벼운 프로그램입니다. Windows와 Mac 모두에서 실행되며 Wwise,...

7.4.2020 - 작성자: 니콜라 루키치 (NIKOLA LUKIĆ)

보이스 제어 방법- CPU에 최적화하기(제 1부)

프로젝트 개발 과정 동안 성능 문제가 일어나는 것은 꽤나 흔한 일입니다. 문제의 원인은 다양하지만 대부분의 경우 동시 재생되는 사운드의 수와 직접 관련된 경우가 많죠. 볼륨만...

12.5.2020 - 작성자: 마튜 장 (Mathieu Jean)

Wwise+GME 게임 음성 솔루션: 다양한 음성 플레이 대방출, 생생한 몰입감 선사

AppAnnie2021 모바일 게임 리포트는 강력한 소셜 인터랙션 속성을 가진 배틀 그라운드, 슈팅 및 온라인 MOBA가 플레이어들의 사랑을 많이 받았으며 게임 시간 증가를...

12.1.2022 - 작성자: Tencent Cloud

대사 | Wwise와 Unreal Engine에서의 나레이션

현대 게임의 필수 요소 중 하나인 보이스오버 대사는 플레이어가 캐릭터를 특정 목소리와 연관지을 수 있을 뿐만 아니라 전반적인 억양을 통해 캐릭터의 감정을 더 잘 이해할 수 있게...

11.4.2023 - 작성자: Jake Gamelin (제이크 겜린)

Wwise 2023.1의 WAAPI

Wwise 2023.1은 2017년 API 도입 이후 가장 방대한 Wwise Authoring API (WAAPI) 업데이트를 포함하고 있습니다. 아직 Wwise 2023.1...

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

ReaWwise를 사용한 ReaScript(Lua)에서의 WAAPI

ReaWwise에서 잘 알려지지 않은 기능 중 하나는 원시적 WAAPI 함수를 REAPER에 노출하여 사용자 정의 ReaScript에서 사용할 수 있다는 것입니다. 이 블로그...

20.11.2024 - 작성자: 앤드류 코스타 (Andrew Costa)

다른 글

Wwise와 REAPER의 연결: Part 2 - ReaOpen

ReaOpen은 오디오 파일을 선택하고 원래의 REAPER 프로젝트를 쉽게 열 수 있는 무료의 가벼운 프로그램입니다. Windows와 Mac 모두에서 실행되며 Wwise,...

보이스 제어 방법- CPU에 최적화하기(제 1부)

프로젝트 개발 과정 동안 성능 문제가 일어나는 것은 꽤나 흔한 일입니다. 문제의 원인은 다양하지만 대부분의 경우 동시 재생되는 사운드의 수와 직접 관련된 경우가 많죠. 볼륨만...

Wwise+GME 게임 음성 솔루션: 다양한 음성 플레이 대방출, 생생한 몰입감 선사

AppAnnie2021 모바일 게임 리포트는 강력한 소셜 인터랙션 속성을 가진 배틀 그라운드, 슈팅 및 온라인 MOBA가 플레이어들의 사랑을 많이 받았으며 게임 시간 증가를...