提取基頻時,半倍頻普遍出現,對此必須做好半倍頻規整
inline float normalize_pitch(float pitch, float temp)
{
float half = fabs(pitch - 12 - temp);
float twice = fabs(pitch + 12 - temp);
float self = fabs(pitch - temp);
if (half < twice && half < self)
{
return pitch - 12;
}
else if (twice < half && twice < self)
{
return pitch + 12;
}
}