By the end of Chapter 01, we'd succeeded in creating a very basic ambience for our Chinese Garden, before moving on to add sound effects/foley to the gunfire and footsteps of the first-person character.
This chapter sees us visiting the campfire situated at the center of the map, to add looping audio to the fire particle along with a realistic attenuation. The audio files we'll be using are included in the chapter_03 folder of your chosen middleware implementation, located within the Audio Showcase assets' installation directory.
Go ahead and listen to them!
Fireplace
The FMOD workflow of this chapter is also covered in the following video:
The audio files that we'll be using to create a looping audio effect for the campfire, are stored in the _Audio_Assets/FMod Studio/chapter_03/ folder of your Audio Showcase assets' installation directory as l_global_particle_fire_01.wav, l_global_particle_fire_02.wav, l_global_particle_fire_03.wav, l_global_particle_fire_04.wav and l_global_particle_fire_05.wav.
Create a new folder in the Audio Bin and Event tab of your FMOD project called Particle, and drag/drop the five audio files into them to create a new 3D multi-instrument Event. Name it l_global_particle_fire.
Select the l_global_particle_fire Event and click on the Multi-instrument timeline at the center of the screen; you should see the following playlist of audio assets that make up the Event in the bottom panel.
Playlist
Click the button to have the audio files play in a loop when the Event is triggered. To make sure the Event loops properly, activate the Async option; this ensures that the audio assets play in their entirety once triggered, especially if they aren't of the same length. You'll notice the waveforms of all five audio assets are stretched to fit the time scale on the multi-instrument; this is just a visual change as the assets sound exactly the same as before.
If you now play the Event, you'll notice two locators moving across the multi-instrument display. The smaller one inside of each track displays the playback time of that file, while the bigger locator is used for automation data. The subject of automation is addressed in Chapter 04.
We then need to create a Loop Region to specify the area of the Multi-instrument that needs to be looped. Since we'd like for the entire Multi-Instrument's timeline to loop:
Finally, add this l_global_particle_fire Event to a new Bank called Particle, before rebuilding all SoundBanks by pressing the F7 key. Switch back to the ACE and create a new Library called Particle in the Audio System Controls panel.
The audio files that we'll be using to create a looping audio effect for the campfire are stored in the _Audio_Assets/Wwise/chapter_03/ folder of your Audio Showcase assets' installation directory as l_global_particle_fire_01.wav, l_global_particle_fire_02.wav, l_global_particle_fire_03.wav, l_global_particle_fire_04.wav and l_global_particle_fire_05.wav.
Begin by creating a new Actor-Mixer called Particle in the Default Work Unit of the Actor-Mixer Hierarchy, a new Particle folder in the Events tab, and a new Particle SoundBank in Wwise. Then drag and drop all assets from the _Audio_Assets/Wwise/chapter_03/ folder into a new Random Container within the Particle Actor-Mixer, and name the Container l_global_particle_fire.
The goal is to create a looping fire particle that plays random audio files on each loop for maximum variety. To do this, a parent Random Container needs to created for our current l_global_particle_fire Container:
The Xfade (power) crossfade on Wwise allows for a smooth crossfade between the audio files of a Container, while keeping the volume constant.
Transitions
A Transition Duration of 1 second is appropriate; now, when the parent l_global_particle_fire Container is looped, it triggers the child l_global_particle_fire Container which then randomly selects one of the l_global_particle_fire_0X files. In this way, multiple different audio systems can be created simply by combining different container types in Wwise.
Switch back to the ACE and create a new Library called Particle in the Audio System Controls panel.
Audio for the campfire has been included as Play_l_global_particle_fire.ogg, under the _Audio_Assets/SDL_Mixer/chapter_03/ folder of the Audio Showcase Level assets' installation directory.
When Enable Attenuation is activated, the Max Distance field's value specifies the distance at which the trigger's sound will be completely inaudible. The Infinite Loop property meanwhile, causes the audio Trigger to loop indefinitely.
Save the created Library and reload the audio engine before proceeding to link the Trigger to the fire particle.
Particles refer to the elements that are used to create visual effects or small physical objects that can move, emit light, react to collisions and so forth. The Particle Editor provides a node based visualization of a particle's components, and will be used to add audio to the campfire's fire particle. Go ahead and open it using the Tools → Particle Editor option from the Sandbox's Main Menu.
The fire particle is located in the /Assets/Particles/Fire.pfx folder of our project's asset directory; open it by clicking the button at the top-right corner of the Particle Editor tool window, and selecting the Open option.
Particle setup
You should now be able to see the different components that make up the fire particle. To add the Play_l_global_particle_fire audio trigger created in the previous step to the particle:
Now the goal is to have the audio trigger stop when the fire particle is killed, It should also not re-trigger, since the Play_l_global_particle_fire Event from which the audio trigger is derived has already been designed to loop in our middleware setup.
As the name implies, the Stop on Death property causes an audio trigger to stop playing when the particle is disabled. The Follow Particle property meanwhile, causes the sound of an audio trigger to follow the particle as it is moved around a scene; it is hence recommended that this setting be used when the audio trigger is designed to loop.
Lastly, click the brown Life: Time feature and deactivate the Life Time property from the Inspector window. This sets the value of the particle's lifetime to infinity. Remember to save all progress by selecting the Save option from the menu of the Particle Editor, before jumping into the game to test your fire particle sound.
If using an FMOD middleware implementation, you'll have noticed that the sound of the campfire trigger reduces as the player moves farther away. This is because FMOD Studio sets a default attenuation for each 3D Event.
To view the Play_l_global_particle_fire Event's attenuation settings within your FMOD project:
Within the Spatializer Effect panel is a red curve that describes how the volume of the Event changes with distance; specific Min and Max values can be set from below the curve.
By default, a distance of 1 unit in FMOD translates to 1 meter on CRYENGINE. This distance factor can be changed by using the
Any changes made to the Min and Max values of Play_l_global_particle_fire's attenuation can be tested within FMOD's Sandbox as follows.
FMOD Sandbox
In the real world, there is not just a reduction in volume but also a loss of high frequencies as distance increases. To implement this frequency modulation in a game environment, we need to create a parameter that changes over distance.
Open the Preset Browser using the Window → Preset Browser option from your FMOD Studio project window.
We now need this Distance parameter to drive the cut-off frequency of a Low Pass filter.
First, go back to the Play_l_global_particle_fire Event in the Event Editor tab of your FMOD project, select its Master Track, and add a new Effect to it by clicking next to its SpatializerEffect panel in the bar down below. Select the Add Effect →Multiband-EQ option from the menu.
A multiband-EQ is used to reduce high frequencies over distance using a low-pass filter.
Select Parameter
You should now see the scale above the Audio 1 track change to the range of 0 - 100, which corresponds to the range of the Distance Parameter we created. By adding different points to the curve of the Multiband EQ track, you may now change the cut-off frequency of the low-pass filter at different values of the Distance Parameter as shown in the GIF above.
Add points to the Multiband EQ by left-clicking upon its red curve; points can be deleted by selecting them, and pressing the Delete key. The value of the Distance Parameter can be set either by adjusting the Distance dial above the scale, or by moving the slider in the Distance tab,
Test various cut-off frequency values in combination with different attenuation settings using the FMOD Studio Sandbox and, when satisfied, rebuild all Soundbanks, reload the audio engine in the ACE, and jump into Game Mode to hear your changes.
If you'd like to tweak the attenuation/Distance parameter values when in-game, set the s_FmodEnableLiveUpdate CVar to 1 in your project's user.cfg file, and restart CRYENGINE. Once the level is loaded again, turn on live updates by clicking the at the bottom of your FMOD Studio project window; set your IP address to localhost and then click Connect.
Also in CRYENGINE, setting the s_DrawDebug CVar to acg will activate audio debugging such that active audio triggers are marked by spheres, while their names and their distance from the listener are displayed. The s_DrawDebug CVar is capable of displaying a host of debugging information on screen; type s_DrawDebug ? in the Engine Console to view all possible display options.
You'll notice that the sound of the campfire remains constant regardless of the player's position, because it isn't 3D spatialized. To change this:
We now need to add attenuation to the sound, which defines how the sound changes over distance; Wwise gives us the option to not only change the volume of the sound, but also set low/high-pass filters and change the spread of the sound.
Aspects such as the frequency and spread of a sound are stored within an Attenuation Share Set, which can also be used by multiple other sounds.
Attenuation
The red line that you see on the Attenuation Settings graph represents the volume of the sound, which is active by default. Try setting the Max distance to 30.
Under the Curves section is a list of other parameters that can be activated; since we'd like to add a low pass filter for attenuation, change the value of the Low-pass filter to Custom in the Curves section; you should now see a blue line in the Attenuation Settings grid.
Feel free to use the GIF above for reference.
Multiple curves can be visualized on the Attenuation Settings grid by clicking the pin next to a curve's color code in the Curves section. Note however, that only the selected curve can be edited when viewing multiple curves at a time on the grid.
Attenuation settings can be previewed by pressing the spacebar in the Attenuation Editor and moving the box to simulate specific distances.
Test various attenuation settings and, when satisfied, generate all SoundBanks, reload the audio engine in the ACE, and jump into Game Mode to hear your changes.
If you'd like to tweak the attenuation settings when in-game, set the s_WwiseEnableCommSystem CVar to 1 in your project's user.cfg file, and restart CRYENGINE. Once the level is loaded again, click on the Connect to Remote Platform icon at the top of your Wwise window, select your system from the Remote Connections window, and press Connect.
Wwise should automatically identify CRYENGINE and your machine as a possible connection; for more information, press the F1 key in the Remote Connections window to be directed to Audiokinetic's documentation.
Also in CRYENGINE, setting the s_DrawDebug CVar to acg will activate audio debugging such that active audio triggers are marked by spheres, while their names and their distance from the listener are displayed. The s_DrawDebug CVar is capable of displaying a host of debugging information on screen; type s_DrawDebug ? in the Engine Console to view all possible display options.
Our level now contains a natural campfire sound, besides the tree movement ambient sounds we added in Chapter 01. In the next and final chapter, we'll work to create a dynamic ambience for the level by using a combination of sound layering, nested ambiences, and one shots.