I recently tried to implement the beat detection code found here, namely the derivation and unwinding algorithm # 1 :: http://archive.gamedev.net/reference/programming/features/beatdetection/page2.asp
I'm not too sure that I have successfully implemented it, as I am not getting good results. I was wondering if anyone had done this successfully or only to good people who want to help in general. Here is my implementation:
for (int i = (int)mintempo; i <= maxtempo; i += 10)
{
curtempo = i;
fftPulse.Clear();
offset = 0;
energy = 0;
short[] prevBuffer = null;
ti = (60 / curtempo) * 44100;
ti = Math.Round(ti, 0);
for (int j = 0; j < pulseTrain.Length; j++)
{
if ((j % ti) == 0)
pulseTrain[j] = short.MaxValue;
else
pulseTrain[j] = 0;
}
while (offset < pulseTrain.Length)
{
short[] fftPulseBuffer = new short[po.blocksize / 2];
index = 0;
for (int j = offset; j < (offset + (po.blocksize / 2)) && j < pulseTrain.Length; j++)
{
fftPulseBuffer[index] = pulseTrain[j];
index++;
}
if (prevBuffer == null)
prevBuffer = new short[po.blocksize / 2];
fftPulse.Add(CalculateFFT(fftPulseBuffer,prevBuffer));
prevBuffer = fftPulseBuffer;
offset += (po.blocksize / 2);
}
for (int j = 0; j < intendomainarr.Count; j++)
{
double[] signalarr = intendomainarr[j];
double[] pulsearr = fftPulse[j];
for (int x = 0; x < signalarr.Length; x++)
{
energy += Math.Abs(signalarr[x] * pulsearr[x]);
}
}
if (energy > maxenergy)
{
chosentempo = curtempo;
maxenergy = energy;
}
}
The results that I get are always very high, usually around 190 and 200 BPM, which should NOT be, since my .wav files have rates only between 60-120BPM.
, .WAV(44.1Khz, 16-bit, Mono), (, ) . , - ? FFT, .
!