AerRacers

Audio integration into a C++ game engine

AerRacers

Audio integration into a C++ game engine

Introduction

Context

In my third year of Game Programming at SAE Institute we were tasked of building a game using a custom C++ engine, which can be played on the Nintendo Switch and to do so we developed the AerRacer project.

Problematic

The main goal of this task was to implement an audio system that can be used inside the C++ game engine. To do so, we used FMOD to generate our sound bank that will be integrated inside the engine.

What need to be integrated

Inside the project there where many sounds that needed to be integrated, each with specific purpose and needs.

The menu sounds:

  • Bleep
  • Select

In the menu, the Bleep sound is used when the player change its current selected menu option, the Select sound is played when the player press the select button or press the return button.

The game sounds:

  • Engine
  • Collision1
  • Collision2
  • Lap
  • Music

During the game, the engine sound is played by each ship and modified by the speed value of the ship, as the ship goes faster, the pitch value of the sound increase, giving the impression that the engine speeds up to accelerate.

Collision1 and Collision2 are two variants of the same sound, each played during a contact of the ship against the walls/obstacle or against another ship.

The Lap sound is played when a player complete a lap.

The music is played from the menu to the end of the game and loop when finished.

How a sound is played?

For each sound we first need to create an audioEntity that will be the anchor of our audio parameters, when created, we will add a transform component to place the entity into the world and an audioSource component to be able to play sounds.

Each entity will have the following parameters:

  • SetPlayOnWakeUp : Tell the audioManager if the sound need to be played at the start
  • SetEventName : Tell the audioManager which sound the source need to play
  • SetMaxDistance : Used to give a maximum distance of earing
  • SetVolume : Used to set a volume

We will then ask the audioManager to play the sound attached to the audioEntity.

Conclusion

What has been done

The audio is correctly implemented inside the game and each sound is triggered and played when needed.

What did I learned

By doing this task I learned how to use FMOD to implement sounds into a C++ game engine.

I also learned how to structure my code better so it will be more readable and efficient.

What would I do differently

For now each sound need to have a different entity, an improvement can be done, by using only one entity and changing the type of sound played would be more efficient and will need less entities to be created.