Skip to content

Commit

Permalink
Improved beat detection algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Remy Porter committed Jun 13, 2015
1 parent 765bff2 commit b10787c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions beatDetect.ck
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class ListenForBeat {
3 => int cooldown;
20 => int low;
10000 => int high;
//This will "age out" older samples
//this prevents music with changes in dynamics from
//misdetecting beats
0.999 => float agingFactor;
10 => int agingInterval;
float step;
BPF banded[256];
FFT ffts[256];
Expand Down Expand Up @@ -55,6 +60,7 @@ public class ListenForBeat {
UAnaBlob d;
rmses[i].upchuck() @=> d;
d.fval(0) +=> runningMeans[i];
if (frames % agingInterval == 0) agingFactor *=> runningMeans[i];
if (d.fval(0) - threshold > runningMeans[i] / frames && d.fval(0) > 0.00005) {
highBands++;
}
Expand Down
4 changes: 2 additions & 2 deletions osctest.ck
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ d.takeoff();
2::second => now;
d.light("snakeGreenRed", 5, 20000);
2::second => now;
d.forward(1);
d.up(0.5);
d.forward(0.25);
d.up(1.0);
4::second => now;
d.clockwise(0.5);
0.5::second => now;
Expand Down

0 comments on commit b10787c

Please sign in to comment.