我的吉他调音器有问题。我正在使用自相关算法来查找声音频率。它几乎可以工作。问题始于300hz以上的高频。有时它不确定是329hz还是109hz当我正在播放E4(329hz)弦时,我认为是次谐波问题。现在我问我怎么能消除那些次谐波?任何技巧?
这是我的自相关代码:
for (int i = 0; i < length; i++) {
double diff = 0;
for (int j = 0; j < length; j++) {
diff += Mathf.Abs (buffer [j] - buffer [i + j]);
}
double dx = prevDiff - diff;
if (dx < 0 && prevDx > 0) {
if (diff < (0.3 * maxDiff)) {
if (sampleLen == 0)
{
sampleLen = i - 1;
}
}
}
prevDx = dx;
prevDiff = diff;
maxDiff = Mathf.Max ((float)diff, (float)maxDiff);
}
答案 0 :(得分:0)
This is the standard octave uncertainty problem with respect to an unchanging pitch. If one period is an close match to the next in a stationary signal, then N periods will also be an close match to the next N periods, thus resulting in a nearly identical autocorrelation at several submultiples of the frequency pitch and/or octaves down. Slight changes in the amount of noise can cause one pitch submultiple to correlate better or worse than another, even though a human might not hear any difference in pitch.
To "fix" this, you have to choose one from among many nearly identical correlation peaks. You can do this by weighting one peak candidate with the exact same autocorrelation as more likely than another peak candidate. For instance, you can require a lower autocorrelation peak candidate to be at least x% higher than any peak representing a frequency multiple higher before you select the lower peak, where x% might be determined by experiment (e.g. how much before a human blind test panel would actually hear the lower pitch). This value likely varies with the type of musical instrument or timbre and the octave played.
Another trick is to look at the harmonic evolution of the sound, as the overtones of low notes on big strings may decay differently than the harmonics of higher strings or notes.