From: tgf@fys.uio.no (TordenGrell)
Subject: Re: Need help to find fundamental frequency
Followup-To: comp.music
Organization: -m-o|o-m-
Date: Thu, 30 Jul 1992 09:17:00 GMT

In article <1992Jul30.005853.25524@rat.csc.calpoly.edu>,
shorio@polyslo.csc.calpoly.edu (Shigenori Horio) wrote:
> 
> Hello!  I recently started learning signal processing algorithms for my thesis.
>......
>......
> port. Right now I am playing an electoric guitar and sending the signal to the
> port. Hopefully, I would like to find a sequence of the fundamental frequencies
> from the input singal in real-time.  
> 
> Now, my questions are:
> 
> 	Is there any fast algorithms written in any programming language that
> retrieves the fundamental frequency without going through FFT algorithm?
>
I'll answer this just because it doesn't have to do with what synth you
should buy.

As for a fast method one could apply 'lag analysis', and this could be done
very cheap and still function reasonably well.  You can find information on
this in many books on signal processing , data analysis or noise. In Hal
Chamberlin's book "musical applications of microprocessors" You also find a
short description of the technique and a very cheap ( time wise ) way of
doing it. It can work reasonably well. It is of course advantagous if you
can limit the possible range of fundamental frequencies. This translates to
how large time window do you need for finding correlations over. The
smaller the faster.  In a struck note the first cycle will be the most time
consuming (normally ) then after that the tracking of the note can be made
with a smaller window.

One need to look upon the tools and methods in the context of the goal. 
Why do one want to find the fundamental? I think that is worth several
pages in the introduction of your thesis, don't you think?

You know that pitch tracking (<>fundamental?) has been done in real time
and also for the case you are experimenting with at the moment, guitar
notes. The guitar synth controller does not work too well. I don't know
exactly how the various guitar controllers work, and I don't want the
discussion to turn into that, and forget about the sonars and specialized
controllers. They do not work purely in the digital domain, they need help
from analogue circuitry.  I think that a fft algorithm or a lag analysis
also would be unaceptable to the performer if the pupose was controlling a
synth.  One should ask why. One should ask how does the human perception
work and then things start getting interesting but not easy to answer. In
any case it is easy to see that we can hear a part of a sound before
ourself or a computer-algorithm can find the pitch.

Then your question really was about the fundamental frequency, and not
about pitch. So you need to sort out the difference. In my vocabulary the
fundamental frequency is a purly technical term ( as we use to say - you
can measure ) whereas the pitch is a scale you use for measuring
psychological sensations. Periodicity, fundamental frequency and pitch are
not easily related quantities.   
 
> 
> I have gotten some of the DFT alorithms written in C such as fft() and realfft()
> which inputs a data array(size sixteen) and returning an output array which is
> also the size sixteen, x[16].  Now, to find the fundamental frequency out of
> the output array, do I have to go through all the elements in the array and find
> the maximum value in x[k]? (Does it need N times comparisons for the window
>
I may be confused by not having the definition of your symbols but you know
of course that the fundamental do not need to be the partial with the
largest Fourier coefficient? The fundamental may even have zero energy.  So
you need to look at the frequency difference between partials to determine
the fundamental. With special input (sych as a synthesizer) A lot of
partials could be missing and your algorithm could guess wrong
fundamental,, but so can your ears if they are asked.  

terje