Initializing the project
Run the following command from any directory to install dependencies:
# Windows
py -m pip install autobahn
# macOS, Linux
python3 -m pip install autobahn
Project Code
| Note: The line from waapi_uri import WAAPI_URI imports a declaration of the API paths.
It is located in <Wwise installation path>/SDK/include/AK/WwiseAuthoringAPI/py . The location of this file was added to Python's path dynamically by extending sys.path in this sample, but you can also copy-paste the waapi.py file along-side the sample files.
Note that the additional file, ak_authobahn.py , provides a special type of component which supports custom options to be sent to WAAPI. This file is provided in the sample's directory.
|
Python 3.7+
Locate the sample file <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/low-level/hello-wwise-wamp/main_py3.py
.
This file contains the following code, which allows you to connect to the Wwise Authoring API.
import os
import sys
import asyncio
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../../include/AK/WwiseAuthoringAPI/py'))
from waapi_uri import WAAPI_URI
class MyComponent(ApplicationSession):
def onJoin(self, details):
try:
res = yield from self.call(WAAPI_URI.ak_wwise_core_getinfo)
except Exception as ex:
print("call error: {}".format(ex))
else:
print("Hello {} {}".format(res.kwresults['displayName'], res.kwresults['version']['displayName']))
self.leave()
def onDisconnect(self):
print("The client was disconnected.")
asyncio.get_event_loop().stop()
if __name__ == '__main__':
runner = ApplicationRunner(url=u"ws://127.0.0.1:8080/waapi", realm=u"realm1")
try:
runner.run(MyComponent)
except Exception as e:
print(type(e).__name__ + ": Is Wwise running and Wwise Authoring API enabled?")
Running the project
Run the sample file from its directory using the following command:
Python 3.7+:
# Windows
py main_py3.py
# macOS, Linux
python3 main_py3.py
If the Wwise Authoring API successfully connects to Wwise, you should see the following output: