We will first quickly review what these functions do, and then we will look at how they work together.
AK::SoundEngine::LoadBank()
AK::SoundEngine::LoadBank() loads events, audio structures (from Actor-Mixer Hierarchy and Interactive Music Hierarchy) and/or audio data (converted WAV files) in memory (depending on what the bank contains – this is defined in the SoundBank Editor).
Events and audio structures are ref-counted objects so if they are loaded from multiple soundbanks, they will just have a bigger ref count. Each unload will decrease their ref count until it reaches 0, at which point they will be deleted from memory.
Audio data on the other hand is loaded as a single block of memory for each bank. If the same audio data is present in multiple banks that are currently loaded, this data is duplicated in memory (see http://kb.gowwise.com/questions/107 for information on avoiding data duplication).
AK::SoundEngine::PrepareEvent()
AK::SoundEngine::PrepareEvent() works differently. After loading a SoundBank that contains Events, you can "prepare" these events. This will "find" the audio structures and audio data in the various soundbanks and will load them. Once an event is "prepared", it is ready to be posted.
Audio structures are loaded in the same manner as with LoadBank(), that is, objects that are already loaded simply see their ref count incremented and other objects are loaded from SoundBanks. Unpreparing an event will decrement the refcount on the objects that were referenced by that event.
Audio data is different. One of the idea behind PrepareEvent() is to efficiently make sure you can post an event without having to load everything in memory, so this mechanism picks the audio data it needs and loads it, instead of loading the whole bank that contains that data. This data is loaded in the memory pool specified in AkInitSettings::uPrepareEventMemoryPoolID during initialization of the sound engine. Unlike audio data loaded with LoadBank(), audio data loaded with PrepareEvent() is not duplicated when multiple calls to PrepareEvent() require this data. A ref count is kept for "prepared" data so multiple PrepareEvent() calls will merely increase that ref count. Note that playback of this data also increments the ref count, so if a sound is currently playing and you unprepare the event, the audio data will stay in memory until playback is finished (that is, playback will not stop if you unprepare an event, and memory will be freed at the end of playback).
AK::SoundEngine::PrepareBank()
AK::SoundEngine::PrepareBank() is identical to PrepareEvent(), but it prepares all sound structures and/or media of a given bank in one operation. Thus, it is more efficient than preparing a whole bunch of events, in particular regarding I/O: soundbanks are read and parsed contiguously.
How they work together
As far as audio structures are concerned, this is pretty simple. Every LoadBank() and prepare event will increase the ref count on objects, and every UnloadBank() and unprepare event will decrease it. When the ref count reaches 0, the object is deleted.
On the audio data side it is different. Each LoadBank() will load audio data as a single memory block, and each prepare event will load the required audio data in a dedicated pool (the "prepare pool", specified by AkInitSettings::uPrepareEventMemoryPoolID), so audio data is duplicated when it is loaded by both LoadBank() and PrepareEvent(). If you wish to load some common assets in one block, and later use PrepareEvent(), it could be a good idea to use PrepareBank() instead of LoadBank(), because PrepareBank() stores audio data in the "prepare pool", thus avoiding duplication of media in memory.
This means that you can safely use LoadBank(), UnloadBank() and PrepareEvent() together. If you prepare an event and you then load/unload a bank that contains objects that were "prepared", they will still work after unloading the bank – that is, the event will still be "prepared" to be posted.