As we have seen, we are calling GetSpectrumData
in the Update
method, not once but twice. Now that you understand some of what is happening under the covers, you can likely appreciate that those calls are quite expensive, which they are. Of course, there are some things we can do to make those calls run quicker, but as always there are trade-offs and your visualizations could suffer. Although, if your game scene is running at a poor frame-rate that really is not much better.
Note
If you wanted to run an audio visualization through a game you built for a mobile platform, such as phone, you would likely want to turn the number of samples down to 64.
Let's look at some settings we can tweak to improve the performance of the visualizer and the effect they have on the audio visualizations by following the instructions given here:
- Go to Unity and set the
AudioClip
of theAudio Source
component to the music track we started with. Then, press play to run the scene...