프로젝트 초기화하기
 |
참고: Python 2.7을 사용할 경우, Python 2.7을 위한 Microsoft Visual C++ Compiler를 설치해야 합니다. |
어느 디렉터리에서든 상관 없이 다음 명령을 실행해 종속성을 설치하세요.
Python 2.7을 사용할 경우, 다음 명령을 실행해 추가 패키지를 설치하세요.
pip install trollius futures
프로젝트 코드
 |
참고: from waapi_uri import WAAPI_URI 라인은 API 경로의 선언을 가져옵니다.
이는 <Wwise installation path>/SDK/include/AK/WwiseAuthoringAPI/py 에 있습니다. 이 예제에서는 이 파일의 위치를 sys.path 를 확장해 Python 경로에 동적으로 추가했지만 예제 파일들과 같은 위치에 waapi.py 파일을 복사해넣어도 됩니다.
추가 파일 ak_authobahn.py 는, WAAPI로 전송되는 사용자 지정 옵션을 지원하도록 요소의 특별한 타입을 제공합니다. 이 파일은 예제 디렉터리에 있습니다.
|
Python 2.7
예제 파일은 <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/low-level/hello-wwise-wamp/main_py2.py
에 있습니다.
이 파일에는 다음 코드가 포함돼있어 Wwise Authoring API에 연결할 수 있게 해줍니다.
import os
import sys
import trollius as asyncio
from trollius import From
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?")
Python 3.6
예제 파일은 <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/python/low-level/hello-wwise-wamp/main_py3.py
에 있습니다.
이 파일에는 다음 코드가 포함돼있어 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?")
프로젝트 실행하기
다음 명령을 실행해 예제 파일을 해당 디렉터리에서 실행하세요.
Python 2.7:
Python 3.6:
Wwise Authoring API가 Wwise에 성공적으로 연결되면 다음 출력이 뜹니다.