Version

menu_open
Target Platform(s):
Wwise Unity Integration Documentation
Android-Specific Information

Building for Android

SoundBanks for Android included in the APK can be directly accessed through the LoadBank() APIs. SoundBanks placed under the StreamingAssets folder are included in the Assets folder of the APK when building the Unity project. The Low-Level IO handles the access to SoundBanks from the APK transparently.

The Low-Level IO can also access SoundBank files in the Android file system, such as from an SD card. To access the native file system, you need to call AkUnitySoundEngine.AddBasePath(YourPath). This new path takes precedence over the default APK files. If a file has the same name in the external path and in the APK, the external path is used. Accessing external files can be useful if you are adding DLCs or patches to audio content after the APK is built.

Background Mode

When the app is put in background, we recommend that you call AkUnitySoundEngine.Suspend(). When the app returns to the foreground, restore the sound with AkUnitySoundEngine.WakeupFromSuspend(). This is currently implemented in AkInitializer, but you can move or replicate it to other parts of your game if it makes sense.

Muting Background Music

Wwise Authoring contains an option to mute background music on Audio Busses. You can use this option to mute game music when a player's music starts (refer to Replacing Music with a Player's Own Music). However, if you use enable this option and also enable Unity Audio on Android, music that passes through the bus is always muted.

You must therefore decide whether to use the Wwise setting to mute background music or enable Unity Audio, because the two in combination are incompatible.

Using OBB Files

Overview of the OBB and Wwise IO

For the Android platform, when checking the Unity option Player Settings > Publishing Settings > Split Application Binary, APK Expansion Files are used for bundling the project assets. This effectively creates a zip file with the .obb extension that contains the StreamingAssets folder, including the SoundBanks. The default Android SoundBank loading support assumes that SoundBanks are located in either the APK file or OBB file.

If you are constructing your own OBB file externally, note that the inner path given to AkUnitySoundEngine.SetBasePath must be the same in the OBB. OBB files must be uncompressed and unencrypted for the default I/O system to work. If this is not the case, then you will need to uncompress the OBB in the persistent data path. The CPU cost to uncompress is too high to uncompress on the fly.

Loading banks in memory

Alternatively, you can use in-memory loading of banks. An example is provided in AkMemBankLoader.cs. This script tries to load the specified SoundBank at the start time of the scene, and unload it when the scene is destroyed. The following changes need to be made to use this example:

  1. Add the script as a component to any game object that needs to load a SoundBank.
  2. In the Inspector, enter the file name of the SoundBank into the Bank Name field of the script component.
  3. In the Inspector, select the Is Localized Bank option if the SoundBank is localized. It will use the global language defined in AkInitializer.cs.
  4. Disable any other SoundBank-loading methods and save the scene.

Two methods AkMemBankLoader.LoadNonLocalizedBank() and AkMemBankLoader. LoadLocalizedBank() can also be called directly in code for the non-localized and localized SoundBanks.

Limitations

  • The in-memory method cannot load the streamed SoundBanks. As a better but more difficult alternative, low-level IO hooks can be implemented to decompress the zip file on the fly to support both streamed and non-streamed SoundBanks. This example, however, will be left for future work. Users are free to implement such hooks and rebuild the Integration.
  • For simplicity, the example script loads only one SoundBank per script component, but one can easily extend it to a collection-based version that can batch-load a list of SoundBanks.
  • The example only wraps the simplest in-memory SoundBank-loading API; there is another callback-based version which you can easily add when you need. The API binding is already available in the Integration.
See also

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise