Version
Wwise Unreal Integration Documentation
|
External Sources are a type of source that developers can associate with a Wwise sound object to dynamically change the media associated with a source. External Sources provide sound data at runtime.
For this reason, developers will likely want to implement their own systems determining which media should be loaded and how (and when) this loading should occur. The External Source Manager was designed with this in mind, it provides a highly extensible base class which provides most of the boilerplate implementation for tracking the states of External Sources and their media, but requires extension to define the actual loading behavior.
The integration includes a sample extension of the Wwise External Source Manager called the Wwise Simple External Source Manager. It supports basic External Source management and provides a reference for developers who want to implement their own manager. Refer to Using the Wwise Simple External Source Manager for more information.
The generation path for External Sources is set in Wwise Authoring, in the External Sources tab in the Project Settings dialog. Refer to Specifying the Input/Output Locations for External Sources for more information.
An External Source is an empty container. The game has to fill it and inform the Sound Engine about what it contains.
An External Source uses a Cookie, similar to a ShortId, as an identifier. To obtain the Cookie, hash the name specified for the External Source plugin in the source's Contents Editor. Refer to Contents Editor: Wwise External Source for more information.
When an Event that uses External Sources is posted to the SoundEngine, an array of AkExternalSourceInfo structures that identify the media to use for each Cookie must be passed with it. This media can be in-memory or streamed, and the game must ensure that these resources are ready when the Event is posted.
For more information about External Sources, refer to the following topics:
For more details about External Source conversion, refer to Integrating External Sources.
External Sources have several notable characteristics:
Given the complex relationship between Events, External Sources, and Media, the Wwise External Source Manager has several responsibilities:
AkExternalSourceInfo
structures for calls to PostEvent.To implement a custom Wwise External Source Manager, you must first create a new Unreal module. At a minimum, the module must contain two classes:
FWwiseExternalSourceManager
, which handles the responsibilities listed in the previous section.FWwiseExternalSourceManager
contains the pure virtual interface required to define External Sources. For special cases, a project can define this as its inheritance point and fully control the External Source pipeline.FWwiseExternalSourceManagerImpl
has all the functions necessary for the runtime to load and unload the media used by External Sources. It has a map of External Source cookies to media IDs, handles the I/O operations, and keeps track of the media lifetime. Inheriting this class simplifies the implementation of custom tracking operations and packaging. The FWwiseExternalSourceManagerImpl
class handles complex I/O details itself.FWwiseSimpleExtSrcModule
as a parent class because it is extendable.FWwiseFileHandlerModule
, which overrides InstantiateExternalSourceManager
in order to return an instance of the first class.Afterwards, to enable the module you can set the WwiseFileHandlerModuleName
to the name of the new module in the [Audio]
section of the DefaultEngine.ini
file. Refer to Enabling the Simple External Source Manager for more information.
The Wwise External Source Manager is an interface in the WwiseFileHandler
module. When Wwise Event assets that use External Sources are loaded, the WwiseResourceLoader
module passes the External Source information in the Event's CookedData
(refer to Wwise Unreal Assets) to the WwiseFileHandler
, which then delegates resource loading to the Wwise External Source Manager Implementation. What happens next depends on the implementation.
In the default implementation, the External Source Manager creates a FWwiseExternalSourceState structure that tracks the External Source. Depending on the implementation and the information available at the time, the media is either loaded or prepared for streaming. Similarly, when an Event asset is unloaded, the External Source Manager is notified and updates the state of the External Source accordingly. This behavior, which fulfills the External Source Manager's first responsibility (tracking the state of External Sources), is implemented in the following functions:
AkExternalSourceInfo
necessary to play the External Sources.LoadExternalSourceImpl
in the manager's execution queue.UnloadExternalSourceImpl
in the manager's execution queue.LoadExternalSourceMedia
.UnloadExternalSourceMedia
is called.The second responsibility (filling AkExternalSourceInfo structures) is handled by PrepareExternalSourceInfos
, which returns the PostEvent
External Source parameter. It retrieves the data in the CookieToMedia
, uses that information to define the different file states, and provides the AkExternalSourceInfo
structure necessary to post the event. You can override it if you want to use a more complex selection algorithm.
In the Wwise Simple External Source Manager extension, a fixed MediaInfo
DataTable identifies all External Source media in the project as well as their relevant metadata. A more advanced system could dynamically update the list of known media. Because there are many different ways to implement such a system, all operations are virtualized. You can create code with random containers that change every single PostEvent, or structures that change based on external states, such as a language change.
In order to perform the next set of responsibilities (tracking the state of loaded media, tracking their mapping to External Sources, and loading them from disk), the FWwiseExternalSourceManagerImpl
class tracks known External Source media and the information necessary to load them. This state tracking is done internally through the ExternalSourceStatesById
map.
After you implement the system and structures mentioned above, we recommend that you implement the following virtual functions:
FWwiseFileHandlerBase
to track media loading states and FWwiseExternalSourceFileState structures to manage media resources.The SetExternalSourceMedia
functions assume that each External Source media has a unique ID and, in the case of SetExternalSourceMediaByName
, that it is possible to retrieve a media ID from its name. We recommend that you use Simple Wwise External Source Manager as a reference for these functions, because it is likely that your implementation will only differ in how you store, update, and retrieve your External Source to media mapping. Remember that dynamic changes to the mapping between External Sources and media files can lead to resources being loaded and unloaded.
The current implementation treates these as blocking functions, which potentially run through the Game Thread. However, this is not a requirement.
Warning: Forcibly unloading External Source media while it is playing causes the SoundEngine to crash. The FWwiseExternalSourceFileState can handle this automatically through the BindPlayingIdToExternalSources and OnEndOfEvent methods to increment and decrement their play count. |
After you finish the implementation of the various functions discussed so far, the most complex part of the External Source manager is complete. If everything works properly, loading an Event Asset (or however your system implements External Source preparation) loads the media used by its External Sources in memory or prepares it for streaming.
Finally, you must package the External Source media. A simple method consists of generating External Source media inside your Unreal project in a directory that is set to always cook. To implement more complex packaging logic, override the External Source Manager's Cook method, which is called by the Wwise Resource Cooker for each External Source contained in cooked Wwise Assets.
The following overridable functions are also available:
By default, three Blueprint functions are exposed in WwiseExternalSourceStatics :
These functions call the corresponding functions defined in the External Source Manager extension. Refer to External Source Manager Blueprint Functions for more information.
Structure used by default in WwiseExternalSourceManagerImpl
to reference count loaded External Sources.
State structure used by the Wwise Simple External Source Manager to handle media resources. The state tracks its reference count as well as whether it is currently being played. Unloading External Source media while it is playing causes the SoundEngine to crash. Two subclasses are available to handle in-memory or streaming media:
FWwiseFileHandlerBase
base class of the External Source Manager. When requests to stream media are passed to the External Source Manager, the registered FileState is retrieved and it handles the subsequent I/O requests. 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