Okay first things first:
- I'm not an English speaker so forgive me if i write something wrong.
- Read this first
There is TWO modules in here:
- Simple
- With Subbands
I'll explain to you what it does in both cases
Scripts:
- SimpleBeatDetection
- ExampleUse
Simple Beat Detection computes the instant energy of the song each frame. Then it calculates the average instant energy and a variance energy which later we can ask if there is a beat at that time or not.
Easy to say but quite hard to understand at first. The code is commented and it is not very long.
Scripts:
- SubbandBeatDetection
- CubesManager
- CubeSound
In the Simple Beat Detection we compute the instant energy of all the samples array. Instead of that, we are going to divide that array in small subbands. Each subband does what the simple beat detection do.
The number of subbands is up to us. 64 Subbands is a nice number because it provides us with a good precision.
CubesManager creates several cubeSounds. Each on of them will subscribe to several subbands.