Version

menu_open
Wwise SDK 2024.1.0
SoundBank Integration Samples

The following sections contain sample integrations of various SoundBank management strategies. These strategies are described in Strategies for Managing SoundBanks in the Wwise help.

Note: The use of PrepareEvent is incompatible with LoadBank, using in-memory data.


The All-in-one SoundBank

With this strategy, all event content, sound structure data, and media files are stored in one SoundBank. For a discussion of this strategy and its implementation in Wwise Authoring, see The All-in-one SoundBank in the Wwise Help.

Since there is only one SoundBank for this game, load it when initializing the game. As always, the sound engine must be initialized first.

...
// Initialize the sound engine here.
...
// Load the Init bank and the all-in-one bank.
AkBankID bankID; // not used in this sample.
AKRESULT eResult = AK::SoundEngine::LoadBank( L"Init.bnk", bankID );
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"MyAllInOneBank.bnk", bankID );
}
...

Multiple Complete SoundBanks

This strategy works well for single player games, where all possible sounds depend on the location of the player in the game. For a discussion of this strategy and its implementation in Wwise Authoring, see Multiple Complete SoundBanks in the Wwise Help.

In the game, load the correct bank at the correct time. For example, the game could load the general bank at the beginning and then load the other banks based on the player's actual location in the game. Note that some games will need to have enough memory to load more than one "level" at a time to allow for transitions between levels.

As an alternative to LoadBank(), you could prepare your SoundBanks using AkBankContent_All. This has the advantage of avoiding duplicating media in memory. See Preparing Banks.

...
// Initialize the sound engine here.
...
// Load Init bank and Common bank.
AkBankID bankID; // Not used in this sample.
AKRESULT eResult = AK::SoundEngine::LoadBank( L"Init.bnk", bankID );
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"CommonEvents.bnk", bankID );
}
...
// And at various places in the code, based on the actual needs:
eResult = AK::SoundEngine::LoadBank( L"Level_1.bnk", bankID );
...
eResult = AK::SoundEngine::LoadBank( L"Level_2.bnk", bankID );
...
eResult = AK::SoundEngine::LoadBank( L"Level_3.bnk", bankID );
...
eResult = AK::SoundEngine::UnloadBank( L"Level_1.bnk", NULL );
...
eResult = AK::SoundEngine::UnloadBank( L"Level_2.bnk", NULL );
...
eResult = AK::SoundEngine::UnloadBank( L"Level_3.bnk", NULL );

Micromanaging Media

Consider this strategy for complex games with many assets. For a discussion of this strategy and its implementation in Wwise Authoring, see Micromanaging Media in the Wwise Help.

In the game, load the common SoundBanks at the beginning of your game then load the other SoundBanks when they are required. For example, the game could load the Event SoundBank and the common footsteps SoundBank at the beginning, then load the other SoundBanks based on the player's location in the game.

// Load Init and the EventBank
AkBankID bankID; // Not used in this sample.
AKRESULT eResult = AK::SoundEngine::LoadBank( L"Init.bnk", bankID );
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"EventBank.bnk", bankID );
}
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"Common_Footstep_bank.bnk", bankID );
}
...
// And at various places in the code, possibly based on the location:
eResult = AK::SoundEngine::LoadBank( L"Winter_Footstep_bank.bnk", bankID );
...
eResult = AK::SoundEngine::LoadBank( L"Desert_Footstep_bank.bnk", bankID );
...
eResult = AK::SoundEngine::UnloadBank( L"Winter_Footstep_bank.bnk", NULL );
...
eResult = AK::SoundEngine::UnloadBank( L"Desert_Footstep_bank.bnk", NULL );

Preparing Action Events

Consider this strategy if you require a high level of media granularity to keep memory usage low and do not want to manage the structure and media related to Events. For a discussion of this strategy and its implementation in Wwise Authoring, see Preparing Action Events in the Wwise Help.

In the game, load the Events' SoundBank at the beginning of the game, then prepare the Events when they are required in game. The corresponding structures and media will be loaded automatically.

// Initializing the sound engine.
AkInitSettings initSettings;
AkPlatformInitSettings platformInitSettings;
// Set the required settings
...
// Set PrepareEvent related settings
initSettings.bEnableGameSyncPreparation = false; // Not used in the current sample.
AKRESULT eResult = AK::SoundEngine::Init( initSettings, platformInitSettings );
if( eResult != AK_Success )
{
// Handle error.
}
// Load Init bank and the event/structure bank.
AkBankID bankID; // Not used in this sample.
AKRESULT eResult = AK::SoundEngine::LoadBank( L"Init.bnk", bankID );
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"Events.bnk", bankID );
}
...
// And then, at various points in the code:
const char * pEventsNameArray[1] = { "My_Event_Name" };
// Preparing an event:
eResult = AK::SoundEngine::PrepareEvent( Preparation_Load, pEventsNameArray, 1 ); // 1 is the array size
// Unpreparing an event:
eResult = AK::SoundEngine::PrepareEvent( Preparation_Unload, pEventsNameArray, 1 ); // 1 is the array size

Preparing Events and Game Syncs (Switches and States)

This strategy is like Preparing Action Events, but with more control over the media that gets loaded when Events are prepared. For a discussion of this strategy and its implementation in Wwise Authoring, see Preparing Events and Game Syncs (Switches and States) in the Wwise Help.

The order in which you call AK::SoundEngine::PrepareEvent and AK::SoundEngine::PrepareGameSync is not important. Each time the state changes, the media pool is updated by crossmatching the Events and the game syncs.

// Initializing the sound engine.
AkInitSettings initSettings;
AkPlatformInitSettings platformInitSettings;
// Set the required settings.
...
// Set PrepareEvent related settings.
////////////////////////////////////////////////////////////////
// The flag bEnableGameSyncPreparation is set to true to activate
// the prepare gamesync mechanism. When set to false, the media
// associated with all game syncs is loaded and there is no need
// to call AK::SoundEngine:PrepareGameSyncs.
//
// When set to true, no media that is game sync dependent will be
// loaded unless the game sync is activated by calling AK::SoundEngine:PrepareGameSyncs
////////////////////////////////////////////////////////////////
initSettings.bEnableGameSyncPreparation = true;
AKRESULT eResult = AK.SoundEngine.Init( initSettings, platformInitSettings );
if( eResult != AK_Success )
{
// Handle error.
}
// Load Init and the event/structure bank.
AkBankID bankID; // Not used in this sample.
AKRESULT eResult = AK::SoundEngine::LoadBank( L"Init.bnk", bankID );
if( eResult == AK_Success )
{
eResult = AK::SoundEngine::LoadBank( L"Events.bnk", bankID );
}
// ... At this point,
// the two events are loaded, but not prepared. No media is currently loaded.
const char * pNameArray[1];
// Prepare the main character footstep event.
pNameArray[0] = "Play_Maincharacter_FootSteps";
eResult = AK::SoundEngine::PrepareEvent( Preparation_Load, pNameArray, 1 ); // 1 is the array size
// ... At this point,
// one event has been prepared, but no media has been loaded yet.
// Now since concrete is always available in the game.
pNameArray[0] = "Concrete";
eResult = AK::SoundEngine::PrepareGameSyncs( Preparation_Load, in_eType, "GroundTexture", pNameArray, 1 );
// ... At this point,
// the 3 sounds, Sound_Concrete_main_1, Sound_Concrete_main_2, and Sound_Concrete_main_3 are loaded.
// Now, let's say that the main character enters a land where there is snow.
pNameArray[0] = "Snow";
eResult = AK::SoundEngine::PrepareGameSyncs( Preparation_Load, in_eType, "GroundTexture", pNameArray, 1 );
// ... At this point,
// 3 more sounds just got loaded : Sound_Snow_main_1, Sound_Snow_main_2 and Sound_Snow_main_3
// Then let's say that a Monster suddenly appears.
pNameArray[0] = "Play_Monster_Footsteps";
eResult = AK::SoundEngine::PrepareEvent( Preparation_Load, pEventsNameArray, 1 ); // 1 is the array size
// ... At this point,
// 6 more sounds just got loaded ( Sound_Concrete_Monster_1.2.3 and Sound_Snow_Monster_1.2.3 )
// And now our player decides to run away from the monster, and the monster goes after them.
// They run so far that they arrive at a place where there is no snow anymore.
pNameArray[0] = "Snow";
eResult = AK::SoundEngine::PrepareGameSyncs( Preparation_Unload, in_eType, "GroundTexture", pNameArray, 1 );
// ... At this point,
// The 6 sounds that were related to snow ( Sound_Snow_Monster_1.2.3 and Sound_Snow_main_1.2.3 ) are unloaded from memory.
...
See also
AKSOUNDENGINE_API AKRESULT PrepareEvent(PreparationType in_PreparationType, const char **in_ppszString, AkUInt32 in_uNumEvent)
Definition of data structures for AkAudioObject.
AKSOUNDENGINE_API AKRESULT PrepareGameSyncs(PreparationType in_PreparationType, AkGroupType in_eGameSyncType, const char *in_pszGroupName, const char **in_ppszGameSyncName, AkUInt32 in_uNumGameSyncs)
AKSOUNDENGINE_API AKRESULT Init(AkInitSettings *in_pSettings, AkPlatformInitSettings *in_pPlatformSettings)
AkUInt32 AkBankID
Run time bank ID.
Definition: AkTypes.h:75
AKRESULT
Standard function call result.
Definition: AkTypes.h:134
AKSOUNDENGINE_API AKRESULT LoadBank(const char *in_pszString, AkBankID &out_bankID, AkBankType in_bankType=AkBankType_User)
@ Preparation_Unload
PrepareEvent() will unload required information to play the specified event.
#define NULL
Definition: AkTypes.h:46
@ AK_Success
The operation was successful.
Definition: AkTypes.h:136
AKSOUNDENGINE_API void GetDefaultInitSettings(AkInitSettings &out_settings)
@ Preparation_Load
PrepareEvent() will load required information to play the specified event.
AKSOUNDENGINE_API AKRESULT UnloadBank(const char *in_pszString, const void *in_pInMemoryBankPtr, AkBankType in_bankType=AkBankType_User)
AKSOUNDENGINE_API void GetDefaultPlatformInitSettings(AkPlatformInitSettings &out_platformSettings)

Cette page a-t-elle été utile ?

Besoin d'aide ?

Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !

Visitez notre page d'Aide

Décrivez-nous de votre projet. Nous sommes là pour vous aider.

Enregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !

Partir du bon pied avec Wwise