DSPRelated.com
Forums

Most accurate method of fundamental frequency determination ?

Started by jwes October 27, 2005
   I am looking for a very accurate method for fundamental frequency
determination. There is no realtime requirements. The input will be
high quality single note musical instrument samples. The desired output
is an estimate of frequency every few milliseconds for the length of
the sample. I have  "A high resolution fundamental frequency
determination based on phase changes in the Fourier transform" by
Judith Brown, but before I start implementing it, I would like to know
if there is open source code for this, or if there is a better method.

in article 1130460304.709654.119940@z14g2000cwz.googlegroups.com, jwes at
j.wesley.cleveland@gmail.com wrote on 10/27/2005 20:45:

> I am looking for a very accurate method for fundamental frequency > determination. There is no realtime requirements. The input will be > high quality single note musical instrument samples. The desired output > is an estimate of frequency every few milliseconds for the length of > the sample. I have "A high resolution fundamental frequency > determination based on phase changes in the Fourier transform" by > Judith Brown,
i don't think i have that one. can you tell me where to find it on the web? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Hello,

> I am looking for a very accurate method for fundamental frequency > determination. There is no realtime requirements. The input will be > high quality single note musical instrument samples. The desired output > is an estimate of frequency every few milliseconds for the length of > the sample. I have "A high resolution fundamental frequency > determination based on phase changes in the Fourier transform" by > Judith Brown, but before I start implementing it, I would like to know > if there is open source code for this, or if there is a better method. >
The way that is often done in the RF world is by timing the zero crossings. However, this requires a really pure signal with a good SNR which could be achieved by proper filtering before the zero crosser. If you roughly know the expected frequency: Phase change of the input signal versus a stored pattern would also give you a clear measure to which side the input frequency deviates and by how much. Look under "FM detection". For really, really stringent accuracy check the geologist's methods. They have to measure down to milli-Hertz deviations. I have a book but it won't help you unless you can read German (by Dr.Burkhard Buttkus, no idea if it was ever translated). Then there is, of course, the brute force method to run a very high resolution FFT and interpolate between the output bins. But this can burn a lot of processor MIPS. Regards, Joerg http://www.analogconsultants.com
jwes wrote:
> I am looking for a very accurate method for fundamental frequency > determination. There is no realtime requirements. The input will be > high quality single note musical instrument samples. The desired output > is an estimate of frequency every few milliseconds for the length of > the sample.
The problem is defining exactly what you mean by "fundamental frequency". The wrong definition might produce a result slightly sharp or flat or even octaves different from what a human would report as the pitch of the note. The definition might even change for different types of musical instruments and in different listening situations. Note that a few milliseconds of a note produced by the lowest strings of a bass guitar or piano contains less than one full cycle.
> I have "A high resolution fundamental frequency > determination based on phase changes in the Fourier transform" by > Judith Brown, but before I start implementing it, I would like to know > if there is open source code for this, or if there is a better method.
Her method looks similar to, and perhaps more computationally efficient than, using phase vocoder analysis techniques to measure frequencies between FFT bins. There is public code available for phase vocoders; but you can easily see how this technique works by observing the phase changes in the results from successive complex FFTs at known sample offsets, given a frequency input not exactly centered on any bin. IMHO. YMMV. -- rhn A.T nicholson d.O.t C-o-M
Joerg wrote:
> Then there is, of course, the brute force method to run a very high > resolution FFT and interpolate between the output bins. But this can > burn a lot of processor MIPS.
Note that if you know what two bins your frequency is between, you don't need to do a whole FFT, but only a partial DFT with the fewer frequencies in the gap between the bins you wish to interpolate. You might even be able to use successive approximation techniques to generate a converging sequence of frequencies to correlate, instead of doing a partial DFT with the whole series of all frequencies between two bins at the desired higher resolution. Might be a much more computationally efficient method to give you identical results with an extremely high resolution FFT on a single frequency peak with low enough noise to make any of this worthwhile. IMHO. YMMV. -- rhn A.T nicholson d.O.t C-o-M
rhnlogic@yahoo.com wrote:

(snip)

> The problem is defining exactly what you mean by "fundamental > frequency". The wrong definition might produce a result slightly > sharp or flat or even octaves different from what a human would > report as the pitch of the note. The definition might even change > for different types of musical instruments and in different listening > situations.
As I understand it, people can hear the fundamental even when it isn't there. That is, if you have the harmonics but no n=1 term it still sounds like it does. -- glen
"robert bristow-johnson" <rbj@audioimagination.com> schrieb im Newsbeitrag 
news:BF86F012.B9E0%rbj@audioimagination.com...
> in article 1130460304.709654.119940@z14g2000cwz.googlegroups.com, jwes at > j.wesley.cleveland@gmail.com wrote on 10/27/2005 20:45: > >> I am looking for a very accurate method for fundamental frequency >> determination. There is no realtime requirements. The input will be >> high quality single note musical instrument samples. The desired output >> is an estimate of frequency every few milliseconds for the length of >> the sample. I have "A high resolution fundamental frequency >> determination based on phase changes in the Fourier transform" by >> Judith Brown, > > i don't think i have that one. can you tell me where to find it on the > web? >
I have http://www.wellesley.edu/Physics/brown/pubs/hrFreqV94P0662-P0667.djvu in my reference manager for this one. It is very nice, though the frequency estimation method is similar to the method presented by Charpentier in "Pitch detection using the short-term phase spectrum" I like this method a lot, because it needs only one FFT-frame for its frequency estimation. (But you have to use windowing in the frequency domain.)
"jwes" <j.wesley.cleveland@gmail.com> schrieb im Newsbeitrag 
news:1130460304.709654.119940@z14g2000cwz.googlegroups.com...
> I am looking for a very accurate method for fundamental frequency > determination. There is no realtime requirements. The input will be > high quality single note musical instrument samples. The desired output > is an estimate of frequency every few milliseconds for the length of > the sample. I have "A high resolution fundamental frequency > determination based on phase changes in the Fourier transform" by > Judith Brown, but before I start implementing it, I would like to know > if there is open source code for this, or if there is a better method. >
If you want to try the phase vocoder method for the instantaneous frequency estimation (IF), have a look at www.dspdimension.com. Try the tutorial "4-Pitch Shifting Code". It includes a really nice description of the phase vocoder technique. And the pitch shifting code also includes IF estimation. Of course IF estimation does not solve the problem of the perceived pitch height, but it is a starting point :-) Good luck, Karin
Go to http://www.soundmathtech.com/pitch to get a paper and Matlab
demo.

You can also read US Patent Application 20030088401 at
www.uspto.gov/patft
(non-commercial use is fine)

Trust me, this is as good as it gets: there will be no better method
for detecting fundamental frequency/period of a signal with least
possible amount of data.

Start reading it now. You can safely put all other papers on this
subject, including the paper you mentioned, where they belong - in a
trash can :-)

I had some success with correlating a buffer with itself, once I made a few
mods to the standard algorithm.  It was used on a lekky guitar.

A beating effect was found to be caused by the arbitrary phase alignment of
the signal waveform in successive sample buffers.

I increased the size of the buffers to acommodate a little more than 2 full
cycles of the lowest anticipated frequency.  I ignored the first peak at 0
samples offset and looked for the next one.  This was used that as the
starting reference from which the next major peak was determined.

The period thus reported has a time resolution in integer steps of 1/Fs,
which was too coarse (about 0.5 semitone rounding error towards the top of
the guitar neck).

This was overcome by finding the left & right shoulders of the 1st & second
correlation peaks & doing a little arithmetic to determine the peak's
center position with fractional sample time resolution.

After that, the straight & synthesized guitar pitch were compared & found to
match within a few cents.

There were a few drawbacks though.  If the sample buffer captures the
initial attack of the string only, the DC thump & plectrum scratch can give
wild pitch determination errors (frequency from DC to light).  This is
immediately corrected when the next sample buffer is processed.

I was using a 20MHz 56002, & it took about 30mS processing time to get a
pitch, uselessly slow for live playing.

The more MIPs the better.  If you have enough of them, you can capture
overlapping buffers (size is fixed by frequency) and deliver pitch updates
more often, thereby reducing the duration of the errored pitch.

I am guessing here, but I imagine that as you use more liquid nitrogen and
asymptotically approach a complete pitch determination every sample, even
the attack noise will probably be correctly reproduced.

I found lowpass filtering above 1.5KHz was useful for noise reduction.  I
was able to find a missing fundamental, because the waveform repeats at
that period.

Have fun.
Jim Adamthwaite.