2
$\begingroup$

Please verify my understanding that pitch detection precision is dynamic across a pitch range, whereas relatively higher pitches can be measured to increasingly higher precision, and vice versa. Based on this, I would like to conclude that pitch detection precision described as ± x cents is a technical simplification.

Given the logarithmic nature of pitch, the linear distance (in Hz frequency) between two adjacent semitones increases as you go up in pitch, and decreases as you go down. In other words, the resolution between notes is dynamic.

The logarithmic unit cent is used to cut the semitone into one hundred smaller pieces, which are "logarithmically equally spaced," but again take on different linear resolution based on the actual pitch.

The linear span between cents at lower pitches becomes smaller, and therefore relatively more difficult to measure. Likewise, the resolution of 1 cent at higher pitches is higher. As a rough visualization, it's like watching your lowest octave at 144P video quality and seeing it progess up the octaves to 4k video quality.

As the range of applicable pitches being measured by the hardware increases, so does this difference in precision across the range.

Is my understanding correct that hardware pitch detection precision is dynamic according to the pitch being detected, and that statements of precision as ± x cents are a simplification?

$\endgroup$

2 Answers 2

2
$\begingroup$

I realize this thread is about a year old, but having recently designed a robust monophonic instrument tuner, I feel somewhat qualified to comment on this. First, let’s consider a time domain approach using cross-correlation. This is common as far as I can tell, at least in the published literature. Let’s make the following assumptions for the sake of illustration: an Fs of 48000, and a desired tuning range of 30.9Hz (B0) to say 880Hz (A5). Rounding, there are then 1559 samples/period at B0, and 54.5 samples/period at A5. This appears to show higher resolution for low frequencies as there are more samples per period. In practice you would calculate the cross-correlation with enough lags to include at least 1559 samples, and probably a bit more to have some margin. Within that time period, you would have 28.6 periods of A5, so you could identify 28 peaks that would occur, and divide the last peak location (in samples) by 28 to get a time resolution almost as good as the lower frequency. So, I would say that using the cross-correlation approach, the precision is roughly constant, in the sense of the question posed.

1 cent is ~578ppm. Translating the above into cents gives .90 samples/cent at B0 and .032 samples/cent at A5. Interpolation is clearly needed, even if multiple peaks are used to increase the resolution for the higher frequencies. I think the two main problems with the cross-correlation approach are 1) the cost of calculation the lags and 2) getting accurate results on the lowest frequencies when the tones are very pure. 1) can be addressed using and FFT/IFFT approach as an alternative to direct form convolution to calculate the lags. 2) is a stickier problem. Tones with more complex overtones have better defined peaks because the fingerprint that slides through the correlation is more complex, resulting in higher output when matching and lower output when mismatching.

Let’s now consider a frequency domain approach using an FFT. This is not common as far as I can tell. All the sources that I’ve found say that in practice you can’t get enough resolution to make this work. Using a FFT of size 16384, there are 10.5 frequency bins/cycle at B0 and 300 bins/cycle at A5. Going to cents, we get .0061 bins/cent at B0 and .174 bins/cent at A5. There is clearly more resolution at the higher frequencies, and is in keeping with the OP’s understanding as the question was posed.

Trying to use quadratic interpolation with these low levels of initial precision does not work well at all. However, I have found a way to easily get around this problem. Let’s consider that the highest frequency we are trying to measure is indeed the A5 at 880Hz. With an Fs of 48000, the Nyquist frequency is 24KHz, but we don’t need all of that. We can use a single biquad IIR lowpass set to 900Hz to filter a time slice of 8096 samples. Then we can decimate by a factor 25, leaving just 324 time samples (every 25th one). We can then zero pad those to a length 16384 and take an FFT. This results in another resolution boost of 2 (8K->16K) for a total resolution boost factor of 50. With these methods, our resolution becomes 0.3 bins/cent at B0 and 8.7 bins/cent at A5. This is way more than we need in the higher range, and just a bit shy in the lower range, so we can use a quadratic interpolator and make short work of it. Another benefit of this approach is that pure tones work perfectly. More complex tones do as well, but in the real-world cases where the harmonics can be louder than the fundamental, it’s not as simple as just looking for the tallest bin magnitude. A bit more shenanigans is required to discern which spectral peak represents the fundamental tone. It turns out to be much easier to do this in the frequency domain vs. in the time domain trying to sort out the peaks in the lags.

So, to sum up the answer to the OP's question - it might be dynamic or it might not be dynamic, depending on the approach taken. And if it is, it might not be visible to a user if the resolutions across frequencies are all below the minimum that would matter.

$\endgroup$
5
  • $\begingroup$ Hi. This is exciting. In your pitch detector, if you're zeroing in on a peak that's not the first peak, and then dividing by the number of peaks in between, that gives you great resolution for high pitches as well as low. Long ago, like 1992, I was doing a pitch detector that took those 28 peaks (I think I had a lot less) and fitted a straight line, using least-squares fitting to it and the slope of that line was the period. But if, for whatever reason, I miscounted the peaks in between, it was a fuckup. Later I just quadratically interpolate between the discrete autocorrelation points. $\endgroup$ Commented Nov 20 at 1:35
  • $\begingroup$ The other big issue was delay. My pitch detector was a real-time thingie intended for live guitar effects or pitch-to-MIDI. The first good peak was what I used. I interpolated the "true" peak location using a quadratic parabola, but I didn't wait around for the second peak usually. $$ $$ And welcome to SE. In the olden days, it was comp.dsp. Now here is the place for DSPers to hang out. $\endgroup$ Commented Nov 20 at 1:37
  • 1
    $\begingroup$ Thanks for the welcome Robert. I'm a fan of your work. Regarding your real time reference, my tuner is real time (enough) in that the 4K blocks come in about 6 times per second. I can update the tuner display based on the current block well before the next block is ready for processing. This is an embedded system with an audio buffer 32 samples deep. $\endgroup$
    – James May
    Commented Nov 20 at 19:51
  • $\begingroup$ I understand. In my case, the delay limits (or speed requirements) were much nastier. I needed to track vibrato and glissando. And after the attack of the note, I needed good pitch information in 15 ms or less. There is a patent that was used to the AXON guitar synth (I can't remember the engineer's name) that was like 13 ms response time, which is amazing since the low E on a guitar has a period of 12.1 ms. It's hard to know the period of a periodic signal until at least one period has completed. $\endgroup$ Commented Nov 20 at 20:37
  • $\begingroup$ Gotcha. Pitch tracking is another beast altogether. $\endgroup$
    – James May
    Commented Nov 20 at 23:11
0
$\begingroup$

In my sorta meatball experience with pitch detection for audio and musical purpose was that I was using autocorrelation of some form which returns the estimated period length in terms of samples (to a fractional precision) of period length.

So, in terms of cents, longer periods (lower pitch) had better precision than shorter periods (higher pitch) because, ostensibly they both have the same precision in terms of samples in the period.

$\endgroup$
3
  • $\begingroup$ Interpreting your writing, I see how the constant sample rate equates to higher precision of the longer period. However, in a tuning sense also consider the gap in cycles per second between adjacent semitones. The gap, or room for error, is smaller at lower pitches. This seems it would offset the increased precision for lower periods, right? And vice versa at higher pitches (less precision, but a bigger room for error). At the very least, your observations support my understanding that precision is dynamic according to the pitch. Thank you $\endgroup$
    – bazz
    Commented Oct 27, 2023 at 3:23
  • $\begingroup$ after some ruminating, I now think tuning precision specified in cents is constant across octaves. My confusion arised from traversing between linear and logarithmic space. semitone ratios are constant despite octave, and I ruminated on that. So measuring with a precision of .01hz at some low octave would be the same as measuring every 20hz at some high octave (these are made up numbers just to make the point). Depending on the pitch range and samplerate selected, perhaps there might be notable negative effects on precision for increasingly higher pitches, as you mentioned. $\endgroup$
    – bazz
    Commented Oct 27, 2023 at 4:07
  • $\begingroup$ //"So measuring with a precision of .01hz at some low octave would be the same as measuring every 20hz at some high octave"// So the low octave could be around 10 Hz and the high octave could be around 20 kHz and it would be about 1.73 cents in either case ----- //"(these are made up numbers just to make the point)"// My point is that however you describe pitch, there can be integer+fractional values of samples in the period length, or there can be integer+fractional cycles completed in a second. So pitch can have high precision in an expression. $\endgroup$ Commented Oct 27, 2023 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.