The Unity audio systems allows us to access the music data – via the AudioSource.GetSpectrumData(...) method. This gives us the opportunity to use that data to present Run-Time visualization of the overall sound being heard (from the AudioListener), or the individual sound being played by individual AudioSources.
The screenshot shows lines drawn using a sample script provided by Unity (https://docs.unity3d.com/ScriptReference/AudioSource.GetSpectrumData.html):
However, in that sample code, their use of Debug.DrawLine() only appears in the Scene panel when running the game in the Unity Editor (not for final builds), and so cannot be seen by the game player. In this recipe, we'll take that same spectral data, and use it to create a Run-Time audio spectral visualization in the Game panel. We'll do this by creating a...