4 ms·
I suppose that made sense because of the very limited resources, but note that it's not ideal because it doesn't estimate pitch at all, it only tells you if the
by pierrec 7y ago
I suppose that made sense because of the very limited resources, but note that it's not ideal because it doesn't estimate pitch at all, it only tells you if there's any content inside a frequency bin you provide. A guitar tuner is expected to have an arrow pointing up/down to tell you which way you should adjust, and this algorithm can't give you that. Getting the direction of that arrow accurately can be challenging because of harmonic content (which guitars have a lot of).
These days it would make more sense to use an algorithm that takes harmonics into account and gives you an estimated fundamental frequency, like Miller Puckette's pitch detection algorithm.
- kragen 7y agoThis is true. Without reaching for state-of-the-art psychoacoustics research, though, even the second autocorrelation peak will take harmonics into account. And you can compute it without the STFT latency, which matters here. It is possible to estimate where a signal is inside the frequency bin; that's how phase vocoders work.
- CamperBob2 7y agoCouple of ways to do it. If you don't want to deal with the latency required to take the block-to-block phase difference (which somehow ended up with the $50 nomenclature "phase vocoder"), you can just do a parabolic fit on the magnitudes of the central bin and its adjacent pair. 99% of the time, the latter is sufficient. With only three points the math is super trivial [1]. For sharp/flat indication, I'd be inclined to look at the adjacent-bin magnitudes. But it's been explained to me numerous times that tuning an instrument isn't just a matter of measuring its frequency, and while I can't argue with that, I don't think I'm ever going to truly grok it. 1: https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation_Spectral_Peaks.html https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation...
- kragen 7y agoMaybe that does give you less latency (if it doesn't require narrower bins for equivalently good results), but it also requires you to compute three frequency bins, which requires 3× the computation with Goertzel (or Minsky), though still far less than a full autocorrelation function. An amusing thought, which surely JOS has explored: if you use a Karplus–Strong delay line as your resonating element instead of a sinusoid, you can take the overtones into account for free. Maybe that reduces to the ACF, minus some kind of normalization. I'm not sure.
- jacquesm 7y ago> But it's been explained to me numerous times that tuning an instrument isn't just a matter of measuring its frequency, and while I can't argue with that, I don't think I'm ever going to truly grok it. It depends on the instrument. If the instrument has only a few , single physical elements per tone generated and the instrument is frequently tuned then you are correct (say a guitar), there is nothing to be done beyond setting the center frequency correctly depending on how you want to tune. But tuning a piano or harpsichord is a different matter. First of all, there are many different ways of tuning, for instance there is 'stretch' tuning which deals with inharmonicity (sp?) in the higher regions. It gets more complex when you have multiple physical resonating elements (such as strings), for instance depending on where you are on the piano keyboard you might have one, two or three strings per note called a 'unison' (sound together). The strings in a single unison not only need to sound good right after tuning, they need to continue to sound good together afterwards and that means that all of them need to degrade gracefully over time as well and that in turn means that they need to lower in tension in a similar way. Good tuners are able to ensure that the string tension is distributed equally between the 'sounding' part of the string (the middle part) and the non-sounding parts (the ends). The amount of tension on the strings and the friction of the pin block and the pins (stick slip) can make this a lot harder than you might think. Finally, just turning the pins until the frequency matches is going to result in a piano that de-tunes very quickly, the best approach is to go a bit too high and then to slowly lower the pitch while hitting the keys quite hard so that the tension of the string gets distributed evenly. Added complexity is that the combined 18,000 KG of tension on the frame will cause the tuning of one section of the strings to affect all the others. If a piano is off very far from being properly tuned you may have to make multiple passes to get the job done.
- CamperBob2 7y agoSome great points there, for sure. Pianos are often mentioned when the subject of tuning-as-art-form comes up.
- kragen 7y agoEven a guitar string has inharmonicity, so the pitch you measure by measuring the lowest resonant frequency is somewhat too low: a sine wave at that frequency will sound lower than the string does. I thought that was CamperBob2 meant. It's certainly what pierrec was talking about, and it's an advantage of ACF-based pitch estimation algorithms.
- MobileVet 7y agoYes, I remember the harmonics were an issue. We were excited when the iPhone came out and had the resources to tune all the strings at once. I can’t remember what we did, but we did provide sharp / flat indication. It definitely worked just like a normal tuner you would find, letting you dial it in quite precisely. Maybe I will crack open the code and look at it...