バージョン

menu_open
Wwise SDK 2021.1.14
Python (low-level) - WAMP

プロジェクトの初期化

注釈: Python 2.7を使う場合は、Microsoft Visual C++ Compiler for Python 2.7をインストールする必要があります。

依存関係をインストールするには、任意のディレクトリから次のコマンドを実行します。

pip install autobahn

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
# 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_uri 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?")

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
# 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_uri 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?")

プロジェクトの実行

次のコマンドを使用して、ディレクトリからサンプルファイルを実行します:

Python 2.7:

python main_py2.py

Python 3.6:

python main_py3.py

Wwise Authoring APIがWwiseに正常に接続すると、次の出力が表示されます:

Hello Wwise 20??.?.?

このページはお役に立ちましたか?

サポートは必要ですか?

ご質問や問題、ご不明点はございますか?お気軽にお問い合わせください。

サポートページをご確認ください

あなたのプロジェクトについて教えてください。ご不明な点はありませんか。

プロジェクトを登録していただくことで、ご利用開始のサポートをいたします。

Wwiseからはじめよう