用Minim定义频段

时间:2016-01-25 03:49:39

标签: java fft minim

我正在使用Minim BeatDetect对象来分析传入的麦克风信号。 BeatDetect使用FFT。

在BeatDetect类中,有四个感兴趣的函数:isHat()isKick()isSnare()isRange(int, int, int)。前三个是isRange()的自定义版本。我要做的就是认识到的不仅仅是帽子,踢腿和军鼓。

为了做到这一点,我需要理解方法isHat()isKick()isSnare()中的数学运算。我希望有人可以帮助我。这是4个函数的代码。

/**
 * In frequency energy mode this returns true if a beat corresponding to the
 * frequency range of a kick drum has been detected. This has been tuned to
 * work well with dance / techno music and may not perform well with other
 * styles of music. In sound energy mode this always returns false.
 * 
 * @return boolean: true if a kick drum beat has been detected
 * 
 * @example Analysis/FrequencyEnergyBeatDetection
 * 
 * @related BeatDetect
 */
public boolean isKick()
{
    if (algorithm == SOUND_ENERGY)
    {
        return false;
    }
    int upper = 6 >= spect.avgSize() ? spect.avgSize() : 6;
    return isRange(1, upper, 2);
}

/**
 * In frequency energy mode this returns true if a beat corresponding to the
 * frequency range of a snare drum has been detected. This has been tuned to
 * work well with dance / techno music and may not perform well with other
 * styles of music. In sound energy mode this always returns false.
 * 
 * @return boolean: true if a snare drum beat has been detected
 * 
 * @example Analysis/FrequencyEnergyBeatDetection
 * 
 * @related BeatDetect
 */
public boolean isSnare()
{
    if (algorithm == SOUND_ENERGY)
    {
        return false;
    }
    int lower = 8 >= spect.avgSize() ? spect.avgSize() : 8;
    int upper = spect.avgSize() - 1;
    int thresh = (upper - lower) / 3 + 1;
    return isRange(lower, upper, thresh);
}

/**
 * In frequency energy mode this returns true if a beat corresponding to the
 * frequency range of a hi hat has been detected. This has been tuned to work
 * well with dance / techno music and may not perform well with other styles
 * of music. In sound energy mode this always returns false.
 * 
 * @return boolean: true if a hi hat beat has been detected
 * 
 * @example Analysis/FrequencyEnergyBeatDetection
 * 
 * @related BeatDetect
 */
public boolean isHat()
{
    if (algorithm == SOUND_ENERGY)
    {
        return false;
    }
    int lower = spect.avgSize() - 7 < 0 ? 0 : spect.avgSize() - 7;
    int upper = spect.avgSize() - 1;
    return isRange(lower, upper, 1);
}

/**
 * In frequency energy mode this returns true if at least
 * <code>threshold</code> bands of the bands included in the range
 * <code>[low, high]</code> have registered a beat. In sound energy mode
 * this always returns false.
 * 
 * @param low
 *           int: the index of the lower band
 * @param high
 *           int: the index of the higher band
 * @param threshold
 *           int: the smallest number of bands in the range
 *           <code>[low, high]</code> that need to have registered a beat
 *           for this to return true
 * @return boolean: true if at least <code>threshold</code> bands of the bands
 *         included in the range <code>[low, high]</code> have registered a
 *         beat
 *         
 * @related BeatDetect
 */
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;
}

我希望通过操纵上述方法,能够在一系列乐器中准确识别节拍。任何人都可以帮我教我需要认识到的东西吗?

目前,据我所知,如果在指定的频段范围内检测到节拍,则函数会返回true。我不明白的是为什么函数中参数[low,high,threshold]的值与特定工具相关。感谢您的任何意见。

0 个答案:

没有答案