Version
Wwise Unreal Integration Documentation
|
When you work with External Sources, it is important to remember that External Sources and their media are decoupled by default. The designer (or developer) must explicitly establish the mapping between an External Source Cookie, which is essentially a ShortID, and the media to play. External Source media can be generated alongside SoundBanks and streaming media, but the designer must also track the media files and their metadata.
The Simple External Source Manager provides features you can use to track External Source media and map them to External Sources. This is done through the use of Data Tables (.csv files) that describe the External Source media to use in the game as well as an API and Blueprint functions to assign media to External Sources.
Note: Example usage of this SubModule is available in the WwiseDemoGame. |
By default, the Simple External Source Manager module is disabled. To enable it, add the following lines to the DefaultEngine.ini
file in your Unreal project:
This code overrides the WwiseFileHandlerModule
with a module that uses the Wwise Simple External Source Manager submodule to handle loading External Sources.
There are two Data Tables and a Directory to set in the Wwise Simple External Source Manager Settings:
Entries in the media info table have the following properties:
AkCodecId
enum in AkGameplayTypes.h
.Entries in the default media table have the following properties:
ExternalSourceCookie
. Used for lookup in the table.ExternalSourceMediaInfoId
in the Media Info Table.When the Simple External Source Manager is instantiated, it reads the Media Info Table to populate its list of media metadata. At the same time, a map of media names to media IDs is populated for use with the External Source Manager Blueprint Functions.
Next, the External Source Default Media is read, and External Source Cookie / media ID pairs are added to a map. This optional Data Table sets "default" media for External Sources to use in the game. This system reduces the number of Blueprint and function calls to the SetExternalSourceMedia
methods: if the default media are already defined, it is only necessary to use these methods for External Sources that dynamically change their media.
When the External Source Manager loads an External Source (usually triggered by an AkAudioEvent
being loaded), a state structure that tracks the number of assets that reference the External Source is created and this map is checked. If a media pairing exists in the map, a state structure for the media is created or updated if it already exist. Depending on the information read from the Media Info Table, the media is either loaded into memory from disk or, if it is streamed, the created state is registered to handle incoming streaming requests from the SoundEngine.
If an External Source Cookie / media ID pair is set during gameplay (for example, by the External Source Manager Blueprint Functions), and if the External Source is already loaded, the media is loaded immediately. If the Exteral Source was already mapped to a different media, the reference count of that media is decremented. If the reference count is 0, it is unloaded after it stops playing.
All PostEvent
calls that pass through the AkAudioDevice, including PostEvent calls from the Integration's Blueprint functions, call the External Source Manager's PrepareExternalSourceInfos
method. This method selects the media to post on the passed External Source cookies. After the operation succeeds (or fails), the BindPlayingIdToExternalSources
method is called to bind all the selected media onto the posted event's Playing ID. Similarly, when Events finish playing, the OnEndOfEvent
method is called, which informs the External Source Manager that the media are no longer used by that Playing ID.
Finally, the Cook
method supports the packaging of External Source media. When any Event that uses External Sources is packaged, the Cook
method is called for each External Source. When this method is called, the Simple External Source Manager stages every media file in its Media Info Table for packaging. Because this only needs to happen once, a flag is set and subsequent calls to Cook
do nothing.
Note: If you post events with External Sources directly through the WwiseSoundEngine API, ensure that you implement the External Source Manager's PrepareExternalSourceInfos , BindPlayingIdToExternalSources , and OnEndOfEvent at the appropriate times. Otherwise, if you switch the media an External Source uses while it is playing, the previous media might be unloaded prematurely, which could cause the SoundEngine to crash. At a lower level, you can also override the I/O Hook and handle the file management yourself. |
When the Data Tables on disk are modified and the Unreal Editor is open, their contents are re-parsed. Afterwards, all loaded Wwise Events Assets are unloaded, then reloaded. This brute force approach is the simplest way to ensure that the External Source Manager's state is properly updated.
To update the mapping between External Sources and media, the module provides Blueprint functions to set external source media.
There are three Blueprint functions that take names or IDs, depending on your preference:
MediaID
to specify the media.MediaName
in the Media Info Table to specify the media.Cookie
to specify the External Source and the MediaID
to specify the media.When you set an External Source media with strings, the Cookie
is determined by a hash of the name string (as in Wwise Authoring). The MediaID
is retrieved by looking up the the media name in a map that is populated when the Media Info Table is parsed.
Note: Blueprints can only use signed short integers. To circumvent this restriction, we use a FAkUniqueID variable to set the External Source cookie value. |
Developers can set External Sources through code in two ways: they can call the Blueprint functions described in the previous section, or they can retrieve the External Source Manager instance and call its methods directly. Most methods in the Wwise Simple External Source Manager are virtual, so developers can extend this manager in a new module to use their own data structures and logic to track media and pair with External Sources.
The main limitation of the Simple External Source Manager design is the inflexibility of the Media Info Table with respect to multi-platform games. Different platforms use different codecs to decode media, but the structure of the Media Info Table does not support this. One potential solution in an extension of the manager is to create platform-specific Media Info Tables and package the correct one depending on the build target.
When streaming, External Sources have more limitations than internally packaged media. Zero Latency is not possible with External Sources, and the prefetched data is only provided to the SoundEngine when it is requested for playback. There is a playback delay between the initial PostEvent and the actual sample processing, as would occur with any media that do not have Zero Latency.
Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !
Visitez notre page d'AideEnregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !
Partir du bon pied avec Wwise