menu
 
버전
2018.1.11.6987

2024.1.5.8803

2023.1.13.8732

2022.1.19.8584

2021.1.14.8108

2019.2.15.7667

2019.1.11.7296

2018.1.11.6987

2017.2.10.6745

2017.1.9.6501

2016.2.6.6153

2015.1.9.5624


menu_open
Wwise SDK 2018.1.11
Python (Autobahn) - WAMP Subscriber/Publisher

Initializing the project

info 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

Project Code

info

Note: The line from waapi 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 2.7

Locate the sample file <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/wwise-pubsub-wamp/get_ancestors_py2.py.

This file contains the following code, which allows you to connect to the Wwise Authoring API.

import sys
import os
import trollius as asyncio
from trollius import From
from autobahn.asyncio.wamp import ApplicationRunner
from ak_autobahn import AkComponent
# 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
done = False
class MyComponent(AkComponent):
def onJoin(self, details):
def on_object_created(**kwargs):
result = kwargs[u"object"]
print("The object was created in the category: {}".format(result[u"category"]))
arguments = {
"from": {"id": [result.get("id")]},
"transform": [{"select": ["ancestors"]}],
"options": {
"return": ["name"]
}
}
res = yield From(self.call(WAAPI_URI.ak_wwise_core_object_get, **arguments))
ancestors = res.kwresults[u"return"]
print(u"Ancestor of {}:".format(result[u"id"]))
for ancestor in ancestors:
print("\t{}".format(ancestor[u"name"]))
global done
if not done:
self.leave() # Disconnect
done = True
subscribe_args = {
"options": {
"return": ["id", "name", "category"]
}
}
# Subscribe to ak.wwise.core.object.created
# Calls on_object_created whenever the event is received
yield From(self.subscribe(on_object_created,
WAAPI_URI.ak_wwise_core_object_created,
**subscribe_args))
print("Create an object in the Project Explorer")
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"get_ancestors_demo")
try:
runner.run(MyComponent)
except Exception as e:
print(type(e).__name__ + ": Is Wwise running and Wwise Authoring API enabled?")

Python 3.6

Locate the sample file <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/wwise-pubsub-wamp/get_ancestors_py3.py.

This file contains the following code, which allows you to connect to the Wwise Authoring API.

import asyncio
import sys
import os
from autobahn.asyncio.wamp import ApplicationRunner
from ak_autobahn import AkComponent
# 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
done = False
class MyComponent(AkComponent):
def onJoin(self, details):
def on_object_created(**kwargs):
result = kwargs[u"object"]
print("The object was created in the category: {}".format(result[u"category"]))
arguments = {
"from": {"id": [result.get("id")]},
"transform": [{"select": ["ancestors"]}],
"options": {
"return": ["name"]
}
}
res = yield from self.call(WAAPI_URI.ak_wwise_core_object_get, **arguments)
ancestors = res.kwresults[u"return"]
print(u"Ancestor of {}:".format(result[u"id"]))
for ancestor in ancestors:
print("\t{}".format(ancestor[u"name"]))
global done
if not done:
self.leave() # Disconnect
done = True
subscribe_args = {
"options": {
"return": ["id", "name", "category"]
}
}
# Subscribe to ak.wwise.core.object.created
# Calls on_object_created whenever the event is received
yield from self.subscribe(on_object_created,
WAAPI_URI.ak_wwise_core_object_created,
**subscribe_args)
print("Create an object in the Project Explorer")
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"get_ancestors_demo")
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 2.7:

python get_ancestors_py2.py

Python 3.6:

python get_ancestors_py3.py

Create an object in the Project Explorer and the list of its ancestors will be displayed. The sample terminates the connection after the ancestors are retrieved.


이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요