I'm using minim BeatDetect object to analyze the incoming microphone signal. BeatDetect uses FFT. In the BeatDetect class, there are 4 functions of interest. isHat(), isKick(), isSnare() and isRange(int, int, int). The first three are customized versions of isRange(). What I'm trying to do is recognize more than just hat, kick and snare drums. In order to do this, I need to understand the math in the methods isHat(), isKick() and isSnare(). I'm hoping someone here can help me. Here is the code for the 4 functions.
`
public boolean isKick()
{
if (algorithm == SOUND_ENERGY)
{
return false;
}
int upper = 6 >= fft.avgSize() ? fft.avgSize() : 6;
return isRange(1, upper, 2);
}
public boolean isSnare()
{
if (algorithm == SOUND_ENERGY)
{
return false;
}
int lower = 8 >= fft.avgSize() ? fft.avgSize() : 8;
int upper = fft.avgSize() - 1;
int thresh = (upper - lower) / 3 + 1;
return isRange(lower, upper, thresh);
}
public boolean isHat()
{
if (algorithm == SOUND_ENERGY)
{
return false;
}
int lower = fft.avgSize() - 7 < 0 ? 0 : fft.avgSize() - 7;
int upper = fft.avgSize() - 1;
return isRange(lower, upper, 1);
}
public boolean isRange(int low, int high, int threshold)
{
if (algorithm == SOUND_ENERGY)
{
return false;
}
int num = 0;
for (int i = low; i < high + 1; i++)
{
if (isOnset(i))
{
num++;
}
}
return num >= threshold;
}
` I want to be able to recognize beats accurately across a range of instruments by manipulating the methods above. Can anybody help teach me what I need to recognize? Currently, I understand that the functions return true if a beat is detected within a specified range of frequency bands. What I don't understand is why the values for the parameters [low, high, threshold] in the functions correlate to specific instruments. Thanks for reading and please respond.