This week, a day just before our presentation to cohort2, we finally changed the line equalizer into a bar equalizer. It was still far from our first idea: draw it in the groove. Nevertheless, it was more appealing than the line.
The new equalizer
Furthermore, we also got the enemy spawn based on the music. Well, the criteria was not precise and correct one. It was just based on the equalizer - with one frequency range. We need to tweak it for the final game. Now, it was enough for prototype.
I wasn't sure that my equalizer algorithm was right. What I did was I took 1024 bits of the spectrum data from Unity. Since the sound was sampled at 48K Hz, the spectrum I got is the average sound level of the last 21.3 ms which is 1024/48000. Between these 1024 bits data, I found the highest frequency for my reference then I divided it into 16 sections.
I wasn't sure why the first 64-bits data section was always high. I felt these data wasn't accurate thus I 'threw' it away. For the rest of the sections, I found each the highest frequency and compared it with my highest frequency for the whole data. Using this section-highest frequency and data-frequency, I scaled each equalizer. That's all!
I used this equalizer as well to spawn the statics. My criteria was whenever one the left 15 bars exceed half of the maximum height, the enemy would be spawn. It worked nice for music with high beats but not for slow music. Well... this was just prototype.
No comments:
Post a Comment