バージョン
- 必要条件
Wwise Unreal Integration Documentation
|
External Sources are a type of source that developers can associate with Wwise sound objects to provide sound data at runtime. You can use External Sources to load media dynamically, especially if there are many different media files associated with an Event, such as multiple lines of dialogue.
You can use the External Source Manager to implement your own system that determines which media to load, as well as when and how to load it. The External Source Manager provides a highly extensible base class that contains a basic implementation to track states of External Sources and their media, but you must extend it to define the actual loading behavior.
In the Wwise Unreal Integration, the External Source system consists of three parts:
To use External Sources, you must first set the generation path in Wwise Authoring, in the External Sources tab in the Project Settings dialog. See Specifying the Input/Output Locations for External Sources for more information.
An External Source is an empty container. The game has to fill it in and inform the sound engine about its contents.
An External Source uses a Cookie as an identifier, similar to a ShortId. To obtain the Cookie, hash the name specified for the External Source plugin in the source's Contents Editor. See Contents Editor: Wwise External Source for more information.
When an Event that uses External Sources is posted to the sound engine, 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, see the following topics:
External Sources have several notable characteristics:
To manage the relationship between Events, External Sources, and media, the External Source Manager:
AkExternalSourceInfo
structures for calls to PostEvent
.The default implementation of the Wwise External Source Manager attempts to answer PostEvent
calls (PrepareExternalSourceInfos
, BindPlayingIdToExternalSources
, and OnEndOfEvent
) as quickly as possible. It requests PrepareExternalSourceInfos
in order to "use" the specified media until OnEndOfEvent
indicates that the playing media is no longer needed. The Simple External Source Manager provides the cookies that identify the media to load. You can override the default implementation if desired.
To implement a custom Wwise External Source Manager, you must first create an 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
(see Wwise Unreal Assets) to the WwiseFileHandler
, which then delegates resource loading to the Wwise External Source Manager Implementation. Subsequent behavior 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 default implementation answers PostEvent
calls (Prepare
, Bind
) as quickly as possible.
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.
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 treats these as blocking functions, which potentially run through the game thread. However, this is not a requirement.
![]() | 警告: Forcibly unloading External Source media while it is playing causes the sound engine to crash. The FWwiseExternalSourceFileState can handle this automatically through the BindPlayingIdToExternalSources and OnEndOfEvent methods to increment and decrement their play counts. |
After you implement the desired functions, the most complex part of External Source manager development 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 the Wwise Resource Cooker calls for each External Source contained in cooked Wwise Assets.
The following functions, which you can override, are also available:
By default, three Blueprint functions are exposed in WwiseExternalSourceStatics :
These functions call the corresponding functions defined in the Simple 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 sound engine 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.