Re: Extract data from AIFF file to compute FFT
Re: Extract data from AIFF file to compute FFT
- Subject: Re: Extract data from AIFF file to compute FFT
- From: "James Chandler Jr" <email@hidden>
- Date: Mon, 4 Aug 2008 10:46:48 -0400
----- Original Message -----
From: "Brian Willoughby" <email@hidden>
Subject: Re: Extract data from AIFF file to compute FFT
You would be better off calculating a precise 440 Hz sine wave into a working
buffer, and then using math similar to an FFT, but much faster, to compare
your input to that frequency. In other words, instead of calculating 1024
results, you would calculate only one complex result. ... In your case, you
only need 6 or 8 results at the most, and it would be preferable that they
were precise frequencies.
Excellent advice!
There is one single-frequency 'fft-like' alogrithm called a Goertzel. There are
probably many others. The Goertzel is good for some problems because you can
specify any arbitrary 'probe frequency' and about any arbitrary size of analysis
buffer, and it can be arranged to run pretty fast since it is an IIR (infinite
impulse response) type of calculation.
The Goertzel analysis buffer needs pre-windowing. Hamming and Blackman seem to
work OK.
I only mention it as an easy drop-in 'single frequency fast' analyzer, but it
may not be ideal as a guitar tuner. It is fast, but not REALLY FAST, and I think
you would probably need to run a loop of numerous Goertzels on each audio
buffer, at fine spacing around the expected pitch center. For instance, if
looking for the TRUE frequency in the vicinity of A 440, one might probe A440 -
50 cents, A440 - 49 cents, .... A440 + 49 cents, A440 + 50 cents. And then look
in the array of 101 measurements to find the biggest measurement. That AIN'T
gonna be fast.
It is a nice algorithm, but probably not the perfect tool for a tuner.
If Francois was determined to approach the problem with conventional FFT,
perhaps Phase Vocoder techniques could interpolate between the FFT bins and get
'close enough' to a true frequency. That is done by comparing phase-shift of
consecutive FFT analysis frames.
===
A problem of looking at just one frequency in a tuner program-- It might not
give a 'true tuning'. If a person tunes a guitar by ear against a reference
tone, the 'overall pitch' of all the harmonics in the guitar string have been
judged by the ear to be in agreement to the reference tone.
But the harmonics in a guitar string are rarely perfectly in tune with each
other. So if an auto-tuner program just simple-minded measures the fundamental
harmonic of a guitar string, then that is no guarantee that the guitar will
SOUND in tune to the ear. Higher harmonics which are out-of-tune to the
fundamental can and do make the guitar sound to the ear, a different pitch than
the guitar string's fundamental pitch.
Auto-correlation techniques can 'look at all the harmonics at the same time' in
the guitar signal, but the auto-correlation outputs can be jittery and slightly
ambiguous, so one usually has to make code to smooth the auto-correlation
outputs and reject 'bad measurements'. Phase Vocoder techniques could also 'look
at all the harmonics at the same time', IF you make the code smart enough.
A tuner program is a simple problem that gets more complicated after you think
about it for awhile.
A simpler 'starter' guitar tuner project would generate tones for the user to
manually tune against 'by ear', rather than attempting to measure the pitch.
That would be a first project much easier to complete. But even that isn't 'dead
simple'. Pure sine waves can be a challenge for many musicians to tune against,
so it is better to generate a 'rich tone' with some higher harmonics. A filtered
ramp wave can work.
But a digitally generated ramp wave tends to alias, and so the tone generator
would at least need anti-aliased tone generation. Which isn't rocket science,
but it is another hoop to jump thru to make a 'simple program'.
Am not trying to discourage. Am only mentioning some issues.
jcjr
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden