Has anyone here ever tried to make one of these before? I’ve been having a go and sometimes get results but usually when I restrict the frequency to something around what I expect. I’ve noticed that my energy values seem to increase in step kinda levels with the bpm so that if there is a peak around the correct tempo at a higher tempo there will be a higher energy value. This is making me think I’m doing something wrong in my calculation, I thought I understood the paper I got the method from but maybe I don’t. It’s [url:381agle7]http://www.programmersheaven.com/articles/patin/BeatDetectionAlgorithms.pdf[/url:381agle7]

Here’s some code if anyone wants a look:

int Ti = 0, maxval = 0;
double scale = 0;

// derivation filter and half wave rectify
for(int j = 0; j < SAMPLES; j++)
ta[j] = 44100(ta[j+1]-ta[j]);
if(ta[j] <= 0)ta[j] = 0;
tb[j] = 44100
if(tb[j] <= 0)tb[j] = 0;
printf("reached horrible calculation\n");
FFT(1, POWER, ta, tb);
printf("finished horrible calculation\n");
printf("reached really evil calculation\n");
for(int bpm = MIN_BPM; bpm <= MAX_BPM; bpm++)
Ti = (6044100)/bpm;
for(int i = 0; i < SAMPLES; i++)
tl[i] = tj[i] = AMP_MAX;
tl[i] = tj[i] = 0;
FFT(1, POWER, tl, tj);
E[bpm-MIN_BPM] = 0;
for(i = 0; i < SAMPLES; i++)
// two methods being tested here as I thought the sqrt might not be necessary and give a speedup
//double temp = (sqrt(ta[i]
ta[i] + tb[i]tb[i])sqrt(tl[i]tl[i] + tj[i]tj[i]));
//E[bpm-MIN_BPM] += (temptemp);
E[bpm-MIN_BPM] += (ta[i]
ta[i] + tb[i]tb[i])(tl[i]tl[i] + tj[i]tj[i]);
// sleep used as calculation is done in thread so I can still do stuff in the program
if(E[bpm-MIN_BPM] > E[maxval])maxval = bpm-MIN_BPM;
printf("%d bpm value checked, Ti value %d\n", bpm, Ti);
printf("finished really evil calculation\n");
printf("maxvalue = %d\n", maxval+MIN_BPM);[/code:381agle7]

  • You must to post comments

No one seems to have any comments on this topic, don’t know if it would be helpful to show the results of the comb filter code in the previous post in a graphical format as it is quite hard to describe. The picture below shows it quite clearly, the calculations are done from 60-240 bpm and you can see that there is a sudden jump in energy every 20 bpm.


If no-one has any comments can anyone think of any other forums that might be more suitable to post this question, something audio programming specific, I’m sorry about posting something that isn’t necessarily fmod related.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.