1

我正在使用 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] 的值与特定仪器相关。感谢您的任何意见。

4

0 回答 0