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:

[code:381agle7]

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*(tb[j+1]-tb[j]);

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 = (60

*44100)/bpm;*

for(int i = 0; i < SAMPLES; i++)

{

if((i%Ti)==0)

tl[i] = tj[i] = AMP_MAX;

else

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]

for(int i = 0; i < SAMPLES; i++)

{

if((i%Ti)==0)

tl[i] = tj[i] = AMP_MAX;

else

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]

*tb[i])*sqrt(tl[i]

*tl[i] + tj[i]*tj[i]));

//E[bpm-MIN_BPM] += (temp

*temp);*

E[bpm-MIN_BPM] += (ta[i]ta[i] + tb[i]

E[bpm-MIN_BPM] += (ta[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

Sleep(0);

}

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]

- identitycrisisuk asked 14 years ago

- You must login 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.

[img:tl31cao8]http://www.imagestation.com/picture/sraid102/p37766ecfce2f6b7898ed5ca06d21a509/f9ba841a.jpg[/img:tl31cao8]

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.

- identitycrisisuk answered 14 years ago

- You must login to post comments

**Your Answer**

Please login first to submit.