バージョン

menu_open
Wwise SDK 2023.1.3
エラーを監視する

Most of the SDK functions return an error code when an issue occurs. しかし、サウンドエンジンは、独自のスレッドで実行されているため、エラーが発生しても直接通知を受け取らない可能性があります。 Before being printed to the user, error codes are parsed by translators that will change the code into a meaningful message and resolve numerical identifiers to object names. By default, messages only go through the DefaultErrorMessageTranslator. 詳細は、 Error Message Translators を参照してください。

There are several ways to detect errors in the Sound Engine. 次のいずれかを行うことができます:

  • SDKの関数が返したエラーコードを確認する。
  • 同期コールで特定されたコールバックで送られたエラーコードを確認する。これは非同期関数を使用している時のみに適用できます。
  • AK::Monitor::SetLocalOutput() 関数を呼び出して、メッセージとエラー監視のローカル出力を、有効/無効にする。For this use case, be sure that the monitoring thread is started. Otherwise, the AkMonitor won't dispatch its notification and nothing will be sent to the local output. To start the monitoring, simply call AkMonitor::Instance()->StartMonitoring(). In the case where you don't want a separate thread running, make sure AkMonitor::Instance()->InitMonitoring() has been called and then manually call AkMonitor::Instance()->DispatchNotification().
  • DEBUG もしくは PROFILE セットアップのいずれかを使用して、Wwiseオーサリングアプリケーションをゲームに接続します。Before doing so, make sure communications are properly initialized. 詳細は 通信の初期化 を参照してください。
  • Monitor messages posted by the game using the functions AK::Monitor::PostString() and AK::Monitor::PostCode().

Error Message Translators

Before sending error messages to the user, the Sound Engine sends an error code to the error message translators. The error message translators attempt to parse tags contained in the error code in order to create a more detailed error message. This page explains how to implement the translators in your project.

Implementing Translators

The following sections describe the two components needed when using error message translators.

Callback Function

First, a callback function must be set to receive the monitoring messages. This function has to follow the signature of AK::Monitor::LocalOutputFunc and will be the function receiving the error message after the translation. It is in this function that you should define what you want to do with an error message. For example, in IntegrationDemo, LocalErrorCallback is the callback function. In the demo, when an error message is received, the current page content is modified to show the error message in red. To set the callback function, call AK::Monitor::SetLocalOutput() and pass the callback function pointer to be used.

Error Message Translators

The Sound Engine has one default translator which transforms the error codes in readable messages. However, this translator simply prints the information it receives, such as IDs, directly in the error message, without trying to transform them into useful information, such as object names. It is highly recommended that you add other translators to the project in order to receive more detailed error messages. The translators are located in the folder SDK/tools/AkWwiseErrorHandler.

注釈: Some translators may require that other libraries are added to the project. Refer to the documentation of each translator for details.

Once the translators you want to use are added to the project, create an instance of them and install them in the monitor by calling AK::Monitor::AddTranslator(). It's important to keep track of the newly created instance in order to be able to delete it.

Translator Types

There are four translator types:

  • Default: Translates error codes into messages, but prints numerical identifiers for Game Objects, Events, Audio Nodes, etc.
  • XML: Translates error codes into messages and uses the information found in SoundBanks.xml to resolve identifiers for Event, Audio Node and Media into meaningful names. Game Objects and some other entities are left in numeric format.
  • WAAPI (AkAutobahn.lib must be added in the linker->input project option): Translates error codes into messages and connects to the Wwise project (through a live Wwise instance) to resolve all identifiers into meaningful names.
  • Unity: Same as WAAPI, but also uses information from Unity. Usable only in Unity projects.

Only the Default translator can handle standard printf-style tags (i.e., those that start with %). Each translator type can redefine how Wwise tags ($) should be handled. It's not necessary to handle every tag in a given translator. fallback translator can be defined, which is called after a translation attempt fails. A translator stack can then be created in order to chain multiple translators together until the translation is successful. The translator at the end of the stack is always a Default translator.

Supported Tags

Translators use a tag system similar to the printf() function. The following tags are supported:

  • Standard tags:
    • %i: Integer
    • %f: Float
    • %u: Unsigned Integer (32 bits)
    • %llu: Unsigned Integer (64 bits)
    • %s: Strings
  • Wwise tags:
    • $b: Bank Id
    • $g: GameObject Id
    • $m: Media Id
    • $p: Plugin Id and ShareSet Id
    • $s: Switch/State Id
    • $w: WwiseObject Ids, such as an Event Id
    • $$: Escape character

Creating a New Error Message Translator

If needed, it's possible to create a new error message translator. Simply create a new class that inherits from the AssistedErrorMessageTranslator interface.

This class has two abstract methods:

  • InitConnection(): Makes sure the connection to the external source was successful (i.e., ensures the translator is ready to be used)
  • GetInfoFromExternalSource(): Determines what to do with a given tag

Your new translator doesn't need to handle all tags. It can rely on the next translator in the stack.

注釈: If the new translator implements a way to handle the $p tag, make sure it handles both arguments: Plugin Id and ShareSet Id. See the ParseWwiseTag example in AkDefaultErrorMessageTranslator.cpp.

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

サポートは必要ですか?

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

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

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

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

Wwiseからはじめよう