Wwise Sound System
Overview
Wwise Sound System uses the Wwise Audio Engine which is specially used to play wem format audio, allowing the sound to be modified in real time during gameplay. Wwise audio can be packaged in bank for different scenes. The 2D, 3D and action sound effects can be added by using Wwise Audio Engine in the Editor.
Sound System Configuration
Click Config -> Project Settings and select General Project Settings in the pop-up Project Settings window. Then select WWISE as Sound System in Sound Settings (Restart needed after modification).
After configuring Sound System, click button next to Settings Path in Sound Settings and select the Wwise resource in the pop-up File Browser. Use the same way to select soundbanksinfo.xml path in the Sound Bank Path.
Loading Banks
Sound Bank is a sound file package made by Wwise that needs to be imported to play. And you can create any object in the scene to import these Wwise sounds. Click Create Game Object -> Game Object to create an object, select it, then click Add Component button and select Sound Bank Component.
After creating the Sound Bank Component, configure a Bank Name in Sound Bank property and the corresponding Bank will be imported. Once imported, the sound files in the bank can be used wherever the Wwise sound effects are needed. If you want to use sound files from other banks, you can create some more sound bank components to import these banks.
Adding UI Sound Effects
There are three types of UI sound effects: Sound Effects When Mouse In, Sound Effects When Mouse Out, and Sound Effects On Click.
Opening the UI Editor
Right-click on the blank space of the Resource Preview window and select UI File, double-click the UI file to open the UI Editor.
Sound Effects When Mouse In
The bound sound effect will be played when the mouse is moved into the range of the control.
Select the control that needs to be modified in the UI Editor, then select InSound in the Properties list of the selected control. In the pop-up Select Event Bank window, select a sound file and click OK (or double-click the sound file) to set the property for the control.
Now move the mouse into the control and the sound will be triggered.
Sound Effects When Mouse Out
The bound sound effect will be played when the mouse is placed over the control and then moved out of the control's range.
Modify the OutSound property of the control to add the corresponding sound file to the control in the same way as the InSound property.
Sound Effects On Click
The bound sound effect will be played when clicking on this control.
Modify the ClickSound property of the control to add the corresponding sound file to the control in the same way as the InSound property.
Adding Scene Sound Effects
Scene sound effects can be added to scenes in the Editor in the following way:
In the Hierarchy panel, select the object that needs scene sound effects, then click Add Component and select Sound Standalone Component.
After adding the Sound Standalone Component, select LSoundStandalone, then select an imported event in Event Name property and check Loop to loop it.
Since the Wwise sound effect does not have auto-play feature currently, to play the configured sound effects, you need to get the LSoundStandalone object in the script and call the corresponding Play function. The LSoundStandalone object can be obtained in the script in the following way: Select LSoundStandalone in the Editor, and then modify the String Tag property.
In addition, continue to add a Script Component (which is LScript) and configure the corresponding script for it in the Script File.
You can use the following code in the script corresponding to the script component to get the object in the Editor using String Tag. The first parameter of the function is the object tag, the second parameter is the object type, and the function can be used to find the object with the specified String Tag from all objects of the specified type.
--Query objects by Tag
local function get_object_by_tag(tag_name, class_type_name)
local lscene = nx_value("lscene")
if not nx_is_valid(lscene) then
return nx_null()
end
if tag_name == nil then
return nx_null()
end
local tag_table = lscene:QueryObjectListByTag(tag_name, class_type_name)
local tag_count = #tag_table
if tag_count == 0 then
return nx_null()
elseif tag_count == 1 then
return tag_table[1]
elseif tag_count > 1 then
for i = 1, tag_count do
nx_log("info, get_object_by_tag, "
..nx_string(i) .." : "..nx_string(tag_table[i].StringTag))
end
return nx_null()
end
end
The on_begin_play event of the bound script will be called when the scene is started, and the on_end_play event will be called when the scene is closed. Therefore, to play the Wwise sound when entering the scene, you can call get_object_by_tag in the on_begin_play event of the script to get the LSoundStandalone component and its proxy object, and then call the Play function to play the bound event.
local box = get_object_by_tag("wwise_sound", "LSoundStandalone")
sound3d.VisBase:Load()
sound3d.VisBase:Play()
Adding Action Sound Effects
You can bind sound effects to character actions. The bound sound effect will play when the action plays to the specified action frame. Steps to add action sound effects are as follows:
Find the resource file of the character that needs sound effects.
Double-click the resource file to open the Actor Editor. The Action List on the left shows all the action entries. Among them, the action entries of Animation Sequence type (in pink) and of Montage type (in purple) can be attached with sound resources (As shown in the picture, the current action is running, which is an Animation Sequence action. Thus the sound effect will be triggered during running after the sound resource is added).
Double-click the action entry to enter the Animation Editor, right-click the blank space on the progress bar of Notify, and select Add Notify -> Play Sound to add a sound file.
After adding, click the sound file and select the corresponding event for it in the Event Name of the Details panel. Then it will play during the corresponding action.
Adding Footsteps to Ecologies
Sound effects can be added to various ecologies, allowing preset footsteps to be played when the character moves on these ecologies.
Creating Prefabs
Right-click LVoxelTerrain in the Hierarchy panel to open the Shortcut Menu and click Find Asset. The directory where the resource file of the voxel terrain is located will be displayed in the Resource Preview window of the Project panel.
Right-click the blank space in the Resource Preview window to open the Shortcut Menu and click Prefab. The Pick Parent Class will pop up. Select Physics Material type here and click OK. Then enter a name for the prefab in the pop-up Naming window (Here we take the ash ecology as an example, so the prefab here is named ashes for easy search), and click OK to create a prefab for binding footsteps.
Double-click the created prefab in the Resource Preview window to open its editing window. Enter the name of the ecology that you want to add footsteps to in the Material Name property under Name in the Details Panel (When running, it will automatically find the sound file corresponding to the Material Name to play, so the ecology name filled in here must be correct).
Binding Prefabs
Double-click the voxel terrain resource in the Resource Preview window of the Project panel to open its editing interface. Select the Ecology tab, and all ecologies used are displayed under Planetary Ecology.
Double-click the ecology that needs to add footsteps (corresponding to the Material Name of the prefab) to enter its editing interface. Drag the created prefab from the Resource Preview window in the Project panel to the Physx Reference property slot in the Edit Ecology panel.
Adding Footstep Sound Effects
Refer to the method of Adding Action Sound Effects. Find the resource file of the character that needs to add sound effects in the Resource Preview window of the Project panel first.
Double-click the resource file to open the Actor Editor. The Action List on the left shows all the action entries. Among them, the action entries of Animation Sequence type (in pink) and of Montage type (in purple) can be attached with sound resources (As shown in the picture, the current selected action is running, which is an Animation Sequence action. Thus the sound effect will be triggered during running after the sound resource is added).
Double-click the action entry to enter the Animation Editor. Right-click the blank space on the Progress Bar under Notify, and select Add Notify -> FootStep to add a sound file.
Click the sound file after adding. Then click the button next to the Event Name property in the Details Panel. The Select Event Bank window will pop up. Select Play_Player_Footsteps_Material and click OK.