[ntp:questions] measuring frequency

unruh unruh at invalid.ca
Mon Feb 11 23:48:26 UTC 2013

["Followup-To:" header set to comp.protocols.time.ntp.]
On 2013-02-11, Robert Scott <no-one at notreal.invalid> wrote:
> On Sat, 09 Feb 2013 17:18:25 GMT, unruh <unruh at invalid.ca> wrote:
>>On 2013-02-08, Ivan Shmakov <oneingray at gmail.com> wrote:
>>>>>>>> David Woolley <david at ex.djwhome.demon.invalid> writes:
>>> 	[Cross-posting, and setting Followup-To:, to news:comp.dsp.]
>>> [...]
>>> > In Fourier terms, the spectral width of a piano note is going to be
>>> > more than 12ppm and depend on the exact interval over which you
>>> > measure it.  I would also suspect that the zero crossing interval
>>> > changes significantly during the note, particularly at the start.
>>> 	As per my experience with guitar signals, such a waveform is
>>> 	likely to cross zero more than once per period.  Hence, by
>>> 	counting such crossings one typically gets the frequency of one
>>> 	of the note's harmonics, and not that of the pure tone.
>>> 	BTW, is there a kind of overview of a method that could allow
>>> 	for frequency measurement for such a signal?  (Preferably one
>>> 	oriented to the uninitiated.  I can probably handle complex
>>> 	math, though.)
>>Use the fourier transform to get the rought freq. Then use zero
>>crossings at around that period to narrow in on the freq. Of course if
>>the harmonics are not exact (see piano) then those sero crossings will
>>not give the freq of the fundamantal. You could filter the intput around
>>that rough frequency of the fundamental, but that mightgive you very
>>little signal ( the ear hears the fundamental pitch even if there is no
>>fundamental i n the note )
> You are refering to what is called "inharmonicity" in the piano.  The
> effect is that the overtones are not locked to the fundamental.
> Therefore when they are added on to the fundamental the effect they
> will have on the zero crossings has a good deal of randomness from
> cycle to cycle.  Whereas if they were locked to the fundamental (as in
> a pipe organ) then they will still have an effect on the timing of the
> zero crossings but at least that effect will be the same from cycle to
> cycle, so the timing of the zero crossings will be a relatively good
> measure of the fundamental frequency.
> However even in the case of a pipe organ there can be problems with
> this technique.  It is possible to imagine an overtone riding on a
> lower frequency sine wave where the cusp of the overtone sine wave is
> almost causing a zero crossing.  In that case the detection of the
> zero crossing in the presence of a small amount of noise could
> sometimes count that cusp and sometimes be delayed until the next
> overtone cusp.  So the measurement of frequency could be unreliable
> because of an arbitrarily small amount of noise or irregularity in
> amplitudes.

Yes. However what you can do is to filter out the all but the strongest
harmonic, and count which harmonic number it is. Then you know how many
zero crossings it has in an period of the fundamental and can count
Of course with the piano, since they are not harmonically related this
will give a small error. However the lowest ones are not too far out,
(and besides the ear the actually uses all of the harmonics to decide on
the pitch it will present to you).

More information about the questions mailing list