Preface
Generally speaking, the sound module is relatively independent in the process of game development. So there will be some editors to assist sound designer in design, and these editors will provide some API s to facilitate integration into the engine. At present, most of the games I've been exposed to are Wwise and FMod. Since Wwise and UE4 are used in recent projects, I will expand this article on how Wwise is used in UE4 as a record, which may be used again in the future.
Integrating Wwise into UE4
Wwise is integrated in UE4 as a plug-in. The Wwise integration downloaded from Wwise Launcher has a consistent structure of UE4 plug-ins:
So copy this folder into the plugins directory.
Where are the source code and static libraries of the SDK on which Wwise relies?
New folder ThirdParty under the same level of directory as *. uplugin. Take VS2017 under Win64 as an example, ThirdParty should have structure:
---- ThirdParty
|-- include
|-- x64_vc150
The subfolders include and x64_vc150 are from. Wwise 2019.1.0.6947 SDK\
More details can be found in the AkAudio.Build.cs file in the plugin and the Installation section in the document Wwise_UE4_Integration, which will not be discussed here.
Subsequently, the project is rebuilt and compiled. Then when you run UE4Editor, open the Project Setting and pull it down to see the Wwise related settings:
In the corresponding platform, the default initial value of the platform can be set, which is the default value under Windows:
One thing to note here is that the presupposition here should depend on the situation. In official documents Audio Output on Platform In the section, the sampling rate and the number of channels of the output of each common platform are introduced.
It can be seen that the console platform has its standardized output, that is, the sampling rate is fixed at 48000 Hz. Different platform settings have different descriptions. Specific reference can be made to the sound engine header file under Wwise 2019.1.0.6947 SDK include AK Sound Engine Platforms for example, this is Windows:
struct AkPlatformInitSettings { // Direct sound. HWND hWnd; ///< Handle to the window associated to the audio. ///< Each game must specify the HWND that will be passed to DirectSound initialization. ///< The value returned by GetDefaultPlatformInitSettings is the foreground HWND at ///< the moment of the initialization of the sound engine and may not be the correct one for your game. ///< It is required that each game provides the correct HWND to be used. // Threading model. AkThreadProperties threadLEngine; ///< Lower engine threading properties AkThreadProperties threadOutputMgr; ///< Ouput thread threading properties AkThreadProperties threadBankManager; ///< Bank manager threading properties (its default priority is AK_THREAD_PRIORITY_NORMAL) AkThreadProperties threadMonitor; ///< Monitor threading properties (its default priority is AK_THREAD_PRIORITY_ABOVENORMAL). This parameter is not used in Release build. // Memory. AkUInt32 uLEngineDefaultPoolSize;///< Lower Engine default memory pool size AkReal32 fLEngineDefaultPoolRatioThreshold; ///< 0.0f to 1.0f value: The percentage of occupied memory where the sound engine should enter in Low memory mode. \ref soundengine_initialization_advanced_soundengine_using_memory_threshold // Voices. AkUInt16 uNumRefillsInVoice; ///< Number of refill buffers in voice buffer. 2 == double-buffered, defaults to 4. AkUInt32 uSampleRate; ///< Sampling Rate. Default is 48000 Hz. Use 24000hz for low quality. Any positive reasonable sample rate is supported. However be careful setting a custom value. Using an odd or really low sample rate may result in malfunctionning sound engine. AkAudioAPI eAudioAPI; ///< Main audio API to use. Leave to AkAPI_Default for the default sink (default value). ///< If a valid audioDeviceShareset plug-in is provided, the AkAudioAPI will be Ignored. ///< \ref AkAudioAPI bool bGlobalFocus; ///< Corresponding to DSBCAPS_GLOBALFOCUS. If using the AkAPI_DirectSound AkAudioAPI type, sounds will be muted if set to false when the game loses the focus. ///< This setting is ignored when using other AkAudioAPI types. IXAudio2* pXAudio2; ///< XAudio2 instance to use for the Wwise sound engine. If NULL (default) Wwise will initialize its own instance. Used only if the sink type is XAudio2 in AkInitSettings.outputType. };
Use of Wwise in UE4
According to the instructions in the document, Workflow using Wwise in UE4 is divided into the following steps:
1) Creating Wwise Project
After creating the Wwise project, you need to configure the project path under Wwise-Integration Settings in the project settings of UE4.
2) Add AkAudioEvent to UE4
Wwise objects can be created by right-clicking in Content Browser, and there are other actors: AkAoustic Portal, AkReverbVolume, AkSpatial AudioVolume, AkSpot Reflector, AkAmbientSound.
One thing to note is that the name of Wwise Event referenced in UE4 must be the same as the name in the Wwise project.
3) Referring to the object AkAudioEvent in the checkpoint
Event created in the previous step can be dragged directly to the level, and by default it exists in the level as AkAmbientSound.
After the SoundBank is generated, the sound can be played through PostEvent.
4) Add AkAudioBank
The steps in 2) are similar, but unlike Event, the name of the SoundBank created here can be different from the name of the SoundBank in the Wwise project.
5) Set the reference SoundBank for AkAudioEvent
Specify the reference SoundBank for Event in the Event tab.
6) Generating SoundBank
Generate SoundBank under the Build menu. The default path of the generated SoundBank is under Content/WwiseAudio/{PLATFORM}, which can be specified under Project Setting-> Wwise-> Integration Settings.
Platforms here are from UE4 project settings, Available Banks is from UE4 Assets in Content, different from SoundBank in Wwise project, so the number and name of SoundBank generated in Wwise and SoundBank generated by plug-ins in UE4 may be different.
Note
Wwise helps us separate audio design from game design. In this part of the game, what we care about is when to play the sound and what sound to play. In audio design, that is, Wwise, more emphasis is laid on some specific parameters of audio, such as channel, sampling rate and encoding format. Of course, in Wwise, Switch, GameObject can also be used to deal with more game-related sound design.
So if the sound in the game is unchanged, that is, when the uasset of UE4 resource objects such as Event and SoundBank is unchanged, but the sampling rate of the original sound is changed.
Do not turn on the Iterative Cook option when cooking data, otherwise the sound data in the final packaged game will not be modified.