Version
Wwise Unity Integration Documentation
|
Most Wwise SDK functions are available in Unity through the AkSoundEngine
class. Think of it as the replacement of C++ namespaces AK::SoundEngine
, AK::MusicEngine
, and so on. See API Limitations for changes made in the API binding compared to the original SDK. For more complex situations, you'll need to call Wwise functions from code. In the API, the GameObjectID
in all functions is replaced by the Unity flavor of the GameObject. At runtime, an AkGameObj component is automatically added to this GameObject, unless you have already manually added it before.
The native Wwise API allows you to use strings or IDs to trigger events and other named objects in the Wwise project. You can still do this in the C# world by converting the file Wwise_IDs.h
to Wwise_IDs.cs
. Click Assets > Wwise > Convert Wwise SoundBank IDs. You need to have Python installed to make this work.
MIDI can be sent to Wwise by filling the AkMIDIPost
members of AkMIDIPostArray
class and calling any of the following methods:
AkMIDIPostArray.PostOnEvent()
AkSoundEngine.PostMIDIOnEvent()
AK.Wwise.Event.PostMIDI()
The following is a basic script that sends MIDI messages to the sound engine:
The Unity integration exposes the offline rendering feature within the Wwise SDK and simplifies how audio samples can be retrieved.
Caution: Care must be taken to ensure that only the asynchronous AkSoundEngine.LoadBank and AkSoundEngine.UnloadBank APIs are used from the main thread when offline rendering is enabled. See Custom Scheduling of Audio Rendering for details. |
AkSoundEngine.StartDeviceCapture
sets up a specific output audio device for capture so that the number of available samples can be determined by calling AkSoundEngine.UpdateCaptureSampleCount
and the audio samples can be retrieved by calling AkSoundEngine.GetCaptureSamples
.
The following example illustrates how to use the Unity integration to perform offline audio rendering in conjunction with Unity's screen capture functionality. With this functionality implemented, one can easily perform a multiplexing post-processing step to combine the captured audio samples and video frames into a movie.
The audio input source plug-in can be used via C# scripting. See Audio Input Source Plug-in from the Wwise SDK documentation.
The following is a basic script that sends a test tone to the audio input source plug-in:
By default, the AkGameObj
component is attached to a specific Unity gameObject
and uses its transform (with an optional offset) for full positioning. This is usually adequate for many games, such as first-person shooters. However, games with custom camera angles, such as many third-person games, may find it difficult to accommodate the two aspects of positioning (distance attenuation and spatialization) by simply attaching the audio listener to one game object, such as the main camera in Unity. Other games may want players to experience other custom positioning.
To this end, the AkGameObj
component class provides overridable positioning to Unity users. Through the three virtual methods GetPosition()
, GetForward()
, and GetUpward()
, users can derive a subclass from AkGameObj
and use that subclass component to customize any number of Unity gameObjects'
positioning.
Here is a simple example of how to use a custom component to override the default AkAudioListener
behavior. With a third-person project integrated with Wwise, remove the existing AkAudioListener
and its associated AkGameObj
. Then attach the following script to the MainCamera object, attach AkAudioListener
, and finally specify the target Unity gameObject
(such as the player avatar) that the audio listener's position will follow. After this, the distance attenuation of all the emitters will rely on the selected target Unity gameObject's
position as the listener position (an on-screen distance listener), while the orientation of all the emitters is still based on the main camera orientation as the listener orientation (an off-screen orientation listener).
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