Blog: Game Audio Scripting With Unity - Part 2

Working with reverb      29/04/14

Buying Choices

Adam Mclellan Writes: Welcome to the second part in my two part series about audio scripting in Unity. In my first post I introduced Unity terminology and walked through the process of importing and triggering audio clips. Today I'll be covering more advanced topics, including Reverb Zones, advanced triggering scenarios and the additional audio effects available in Unity Pro. If you haven't already, be sure to check out the previous post as I'll be referencing some of the things I covered there as well as expanding upon the example project.

Reverb Zones
reverbBy default when you play an Audio Clip in a scene it's played completely dry--no processing is applied apart from pitch, panning, and volume (and doppler effects for 3D sounds, but this is handled by the engine).

But what if you wanted to simulate the sound of different spaces? A cave? A small room? While you could add reverb to the original audio files this would be impractical--in a world with multiple environments you would need to prepare multiple versions of every audio asset and dynamically trigger them based on the environment.

The solution to this problem is Reverb Zones. Reverb Zones work in conjunction with the Audio Listener: when an Audio Listener is within a Reverb Zone any Audio Sources within audible range are affected based on the Reverb Zone's reverb settings.

You can think of a Reverb Zone as two concentric spheres: the inner sphere applies full reverb while the outer sphere applies partial or "gradient" reverb. The latter is useful for creating transitions between different environments, say, an outdoor space into a cave, or a small room into a larger room.

Important to note is that a Reverb Zone has no awareness of which Audio Sources are contained within, therefore Audio Sources outside of the current Reverb Zone will be affected if they are within audible range of the Audio Listener.

Let's continue the example from last week by adding a Reverb Zone to our "Sphere" GameObject:

Add Component -> Audio -> Audio Reverb Zone

Here you can see the "Full Reverb" (inner) and "gradient" reverb (outer) spheres:

reverb zone

Play the Scene and you'll notice that the "Sphere" GameObject's Audio Source has a generic reverb applied to it. But so does the music. Let's fix that. Bring up the Inspector for the "music" GameObject and check "Bypass Reverb Zone" on the Audio Source:

Edit zone

In most cases you'll want to bypass Reverb Zones for things like music, UI sounds, etc.

So far we've been triggering Audio Clips via Audio Sources attached to GameObjects. While this is fine in many cases, in other cases we may want to trigger an Audio Clip on the fly. This is especially true for short-lived GameObjects such as projectiles.

For example, think of a gun firing a bullet and that bullet ricocheting off of a metal surface. While we'd have a GameObject for both the gun and the bullet and could therefore attach Audio Sources, we wouldn't necessarily have a corresponding GameObject for the ricochet sound. In cases like this we can use scripting to dynamically trigger an Audio Clip.



More From: UNITY
Even more news...


More Videos

Friday Fun: Pittsburgh Modular SV-1 Synth Jam 

NAMM 2018: Waldorf Quantum Sounds 

More details, shipping quite soon

NAMM 2018: Waldorf STVC 

Vocoder and Streichfett in a Keyboard

NAMM 2018: Qu-bit Electronix Nebulae 2, Scanned and Synapse 

Three new modules make up this years announcements