[music-dsp] measuring partial frequencies

robert bristow-johnson rbj at surfglobal.net
Tue Jan 13 15:01:02 EST 2004


> From: "Peter Thom" <peter at sonicreef.com>
> To: <music-dsp at shoko.calarts.edu>
> Subject: RE: [music-dsp] measuring partial frequencies
> Date: Tue, 13 Jan 2004 10:26:55 -0800
> Reply-To: music-dsp at ceait.calarts.edu

On 01/13/2004 10:26:55 -0800, Peter Thom at <peter at sonicreef.com> wrote:
> 
> Yeah, I'm looking for frequencies other than the fundamental.
> FFT isn't accurate enough, I want to measure frequencies within 0.01Hz.

then, in my opinion, you want to seriously look at that Wavetable Synthesis
paper (and remember "true" or classic wavetable synthesis is not the same
thing as sampling "synthesis" which really isn't synthesis at all).  a
frequency deviation of 0.01 Hz is essentially a slow changing of phase.

> Would a bandpass filter and zero crossing counting do, or is that not
> accurate enough? How about autocorrelation?

you might use something like that to precisely measure the period of a tone
(which is useful for "pitch detection" or measuring f0), but it does not
separate the partials which you will need to do somehow.

> BTW, the tone is a piano tone, so it should be a relatively periodic
> tone.

really, Peter, i don't know how deeply you want to dive into the math (the
paper was done that way, with continuous-time, because it was the easiest
way to be rigorous), but conceptually it is *not* that bad.

in terms of implementation, i presume these piano tones are WAV or AIFF
files, right?  and you have the means to open and parse them, right?  what
language are you planning to do this in?  C?  Matlab?

> Any help is greatly appreciated.

besides the means to put your sound file into an array of PCM data that you
can do math on, you will need:

    1.  a good pitch detection and pitch *riding* algorithm (autocorrelation
        might work, but i think ASDF will work a little better).  this
        algorithm also needs to measure how periodic the tone is at some
        time within it so that you know when you crawled over the initial
        transient or "attack" portion into the quasi-periodic portion.

    2.  a good intersample interpolation utility.

    3.  a DFT or FFT utility.

    4.  lotsa memory, which shouldn't be a problem nowadays.

what comes out will be a collection of phase-aligned, single period,
wavetables and after FFTing them, you will have the instantaneous amplitude
and instantaneous phase of each harmonic for that wavetable snapshot.  if
the phase changes in time, that means the harmonic is actually detuned away
from its exact integer multiple of the fundamental.  so if you know the
fundamental frequency (from the pitch detector), the index number of the
harmonic (from the bin number of the FFT), and the rate of change of phase
(from comparing the phase of some particular harmonic of two neighboring
wavetables), you have all of the information for a precise measurement of
the instantaneous frequency of the harmonic.

r b-j





More information about the music-dsp mailing list