Audio synchronization
We're almost there building our own version of Audio Shield, we just need to add synchronizing the fireball shots with music!
Unity provides an API for sampling audio source data, including AudioSource.GetSpectrumData and GetOutputData. Extracting actual beats in the music from this data is not trivial and requires a lot of math and some understanding of how music encoding works.
Fortunately, we found an open source script that does this for us, called Unity-Beat-Detection (https://github.com/allanpichardo/Unity-Beat-Detection). It conveniently provides Unity Events for onBeat, which we'll use. (It also provides onSpectrum events, with music frequency bands per frame, which you could use too, for example, to change ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access