|
Note: If you are using Python 2.7, you will need to install Microsoft Visual C++ Compiler for Python 2.7. |
Run the following command from any directory to install dependencies:
pip install autobahn
If you are using Python 2.7, run the following command to install additional packages:
pip install trollius futures
|
Note: The line It is located in Note that the additional file, |
Locate the sample file <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/hello-wwise-wamp/main_py2.py
.
This file contains the following code, which allows you to connect to the Wwise Authoring API.
import os import sys import trollius as asyncio from trollius import From from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner # You may also copy-paste the waapi.py file alongside this sample sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../include/AK/WwiseAuthoringAPI/py')) from waapi import WAAPI_URI class MyComponent(ApplicationSession): def onJoin(self, details): try: res = yield From(self.call(WAAPI_URI.ak_wwise_core_getinfo)) # RPC call without arguments except Exception as ex: print("call error: {}".format(ex)) else: # Call was successful, displaying information from the payload. 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?")
Locate the sample file <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/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 # You may also copy-paste the waapi.py file alongside this sample sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../include/AK/WwiseAuthoringAPI/py')) from waapi import WAAPI_URI class MyComponent(ApplicationSession): def onJoin(self, details): try: res = yield from self.call(WAAPI_URI.ak_wwise_core_getinfo) # RPC call without arguments except Exception as ex: print("call error: {}".format(ex)) else: # Call was successful, displaying information from the payload. 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?")
Run the sample file from its directory using the following command:
Python 2.7:
python main_py2.py
Python 3.6:
python main_py3.py
If the Wwise Authoring API successfully connects to Wwise, you should see the following output:
Hello Wwise 20??.?.?
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise