HEY! Listen – Audio Programming


At the end of last year, I worked as part of a team of nine to create a demo scene for the final first-year project. Together, over a period of eight weeks, we created a physics-based game in which the aim was to use a ray gun to either shrink or enlarge objects and a jack-in-the-box punching glove to defeat enemies. As a team we focused mainly on the physics of the project rather than the audio aspects as it was assumed that this would take less time to put together.

I have never had to attempt to learn something as technical or as difficult as that last week of the project, the majority of it was spent researching how sound works and how it affects the game. Unity has a uniquely easy concept of making simple sounds work, however, getting timed audio, or overlapping audio, becomes hard to handle very quickly within the confines of Unity.

Figure 1: How the audio source component appears in the inspector when attached to a gameobject. The default settings have 3D Sound Settings on by default for 2019.3

Unity handles sound files as audio clips which can be applied to any audio source component on any GameObject. Depending on the type of game that is being made or played, the audio has two distinct architectures. 2D Sounds are used for sounds that are directionless or ongoing sounds eg. background music (Ferrone 2019).

However, 3D sounds allow for location and distance to play from sounds. It is done by adding an AudioListener, a component that can be added to GameObject/s or cameras and can allow for the perception of directional sound and for how loud the sound show be in relation to where the listener is (Audio Listener 2019; Audio Source 2019).

An example to explain this is how a car driving away from you gradually sounds quieter as it is further from you, or how the sound coming from a radio may be quieter than having a conversation with someone.

In more recent years, Unity has also added the audio mixer feature. Its properties can be manipulated by both developers and users to mix all the different sounds into categories and allow for mixing and adjustments of groups. It is viewed as the same concept as audio engineers working with a master track for an album (Audio Mixer 2019).

References:

Audio Listener 2019.3, accessed 25 May 2020, https://docs.unity3d.com/Manual/class-AudioListener.html

Audio Source 2019.3, accessed 25 May 2020, https://docs.unity3d.com/Manual/class-AudioSource.html

Audio Mixer 2019.3, accessed 25May 2020, https://docs.unity3d.com/Manual/AudioMixer.html

Ferrone, H 2019, Learning C# by Developing Games with Unity 2019: Code in C# and build 3D games with Unity, Packt Publishing Ltd.

Leave a comment