DSPRelated.com
Forums

Pitch detection

Started by altmeyermartin March 21, 2005
    Hi dsp programmin gurus all over the world....


I�m looking for a rock-stable algorithm to do some pitch detection for a
chromatic tuner.
(should work with bad-signal input, like pitch detection through a telephone
line...)

any ideas ?

with compliments, and best thanx to any answer
martin





in article d1mctv$rmb$00$1@news.t-online.com, altmeyermartin at
martin-altmeyer@t-online.de wrote on 03/21/2005 06:58:

> Hi dsp programmin gurus all over the world.... > > > I�m looking for a rock-stable algorithm to do some pitch detection for a > chromatic tuner. > (should work with bad-signal input, like pitch detection through a telephone > line...) > > any ideas ?
lotsa different spins on the theme, but in some way or another, nearly any time-domain pitch detection algorithm will have some relationship to the Average Magnitude (or Squared) Difference Function (AMDF or ASDF). i would google those terms. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
In article <d1mctv$rmb$00$1@news.t-online.com>,
altmeyermartin <martin-altmeyer@t-online.de> wrote:
>I'm looking for a rock-stable algorithm to do some pitch detection for a >chromatic tuner. >(should work with bad-signal input, like pitch detection through a telephone >line...)
What instrument, for how long a sound, and pitch recognition/detection to what accuracy? It's a very different problem for a sustained tone consisting of mostly the fundamental frequency (flute) versus a short slightly inharmonic plink with a completely missing fundamental (a quick tap of the bottom key on a piano as filtered through a cheap telco microphone), and for nearest semitone versus 0.1 cent pitch accuracy. IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
in article d1rgrc$8gs$1@blue.rahul.net, Ronald H. Nicholson Jr. at
rhn@mauve.rahul.net wrote on 03/23/2005 05:36:

> > What instrument, for how long a sound, and pitch recognition/detection > to what accuracy? It's a very different problem for a sustained tone > consisting of mostly the fundamental frequency (flute) versus a short > slightly inharmonic plink with a completely missing fundamental (a > quick tap of the bottom key on a piano as filtered through a cheap telco > microphone), and for nearest semitone versus 0.1 cent pitch accuracy.
the AMDF or ASDF (or auto-correlation which application to pitch detection is derived from ASDF) does not care about a missing fundamental (it *would* care if all of the odd harmonics were missing, which sometimes creates an "octave error"). as long as there is some short term periodic behavior (i call that property "quasi-periodic"), you can use AMDF or ASDF or autocorrelation with some interpolation to get the period length to whatever (sub-sample) precision you want. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
In article <BE6750BD.588E%rbj@audioimagination.com>,
robert bristow-johnson  <rbj@audioimagination.com> wrote:
>in article d1rgrc$8gs$1@blue.rahul.net, Ronald H. Nicholson Jr. at >rhn@mauve.rahul.net wrote on 03/23/2005 05:36: >> What instrument, for how long a sound, and pitch recognition/detection >> to what accuracy? It's a very different problem for a sustained tone >> consisting of mostly the fundamental frequency (flute) versus a short >> slightly inharmonic plink with a completely missing fundamental (a >> quick tap of the bottom key on a piano as filtered through a cheap telco >> microphone), and for nearest semitone versus 0.1 cent pitch accuracy. > >the AMDF or ASDF (or auto-correlation which application to pitch detection >is derived from ASDF) does not care about a missing fundamental
However AMDF or ASDF does care if the "harmonics" are close to but not exact multiples of the missing fundamental and one of the weaker harmonics is the one you care about (e.g. what the human ear/brain might recognize as the musical "pitch" under some conditions). Most techniques similar to auto-correlation will lock onto the strongest harmonic (e.g. not necessarily the local maxima you want, or possible even some super low sub-harmonic related to the true least common multiple e.g. the mathematical fundamental frequency, completely unrelated to the slightly inharmonic physical or audible frequency content of interest). Others here have mentioned using long zero-padded fft's as one alternative for certain types of pitch detection/measurement. IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
Didn't I tell everybody here that pitch detection problem is solved ?

It seems that some people are unable to learn, or they are deliberatly
trying to mislead general public asking questions here.

Go to http://www.soundmathtech.com/p=ADitch for more information.

Also, US Patent Application at http://www.uspto.gov/patft
(Pub. No. 20030088401)

And one more time: FORGET ABOUT USING FFT for pitch detection !!!

Dmitry Terez

dt@soundmathtech.com wrote:
> Didn't I tell everybody here that pitch detection problem is solved ?
Don't hold your breath. PID loops were obsolete since about 1975, but nobody seems to have noticed.
> It seems that some people are unable to learn, or they are deliberatly > trying to mislead general public asking questions here. > > Go to http://www.soundmathtech.com/p&#4294967295;itch for more information.
Not Found The requested URL /p&#4294967295;itch was not found on this server Something funny with the link as it appeared. http://www.soundmathtech.com/pitch/ works.
> Also, US Patent Application at http://www.uspto.gov/patft > (Pub. No. 20030088401)
http://appft1.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PG01&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.html&r=1&f=G&l=50&s1=%2220030088401%22.PGNR.&OS=DN/20030088401&RS=DN/20030088401
> And one more time: FORGET ABOUT USING FFT for pitch detection !!! > > Dmitry Terez
Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
in article d2tb8d$fvh$1@blue.rahul.net, Ronald H. Nicholson Jr. at
rhn@mauve.rahul.net wrote on 04/05/2005 02:29:

> In article <BE6750BD.588E%rbj@audioimagination.com>, > robert bristow-johnson <rbj@audioimagination.com> wrote: >> in article d1rgrc$8gs$1@blue.rahul.net, Ronald H. Nicholson Jr. at >> rhn@mauve.rahul.net wrote on 03/23/2005 05:36: >>> What instrument, for how long a sound, and pitch recognition/detection >>> to what accuracy? It's a very different problem for a sustained tone >>> consisting of mostly the fundamental frequency (flute) versus a short >>> slightly inharmonic plink with a completely missing fundamental (a >>> quick tap of the bottom key on a piano as filtered through a cheap telco >>> microphone), and for nearest semitone versus 0.1 cent pitch accuracy. >> >> the AMDF or ASDF (or auto-correlation which application to pitch detection >> is derived from ASDF) does not care about a missing fundamental > > However AMDF or ASDF does care if the "harmonics" are close to but > not exact multiples of the missing fundamental and one of the weaker > harmonics is the one you care about (e.g. what the human ear/brain > might recognize as the musical "pitch" under some conditions).
i do not entirely understand why some weaker harmonic should be the one to care about in a pitch-detection problem. can you explain?
> Most techniques similar to auto-correlation will lock onto the strongest > harmonic
that i don't understand. the ASDF or AMDF (or an auto-correlation derived from it) will be minimum (or max for autocorrelation) at what looks like the period. a strong 2nd harmonic will not change that as long as there is some energy at the odd harmonics. if the energy of the odd harmonics gets close to zero, you start to have an "octave problem".
> (e.g. not necessarily the local maxima you want, or possible even > some super low sub-harmonic related to the true least common multiple > e.g. the mathematical fundamental frequency, completely unrelated to > the slightly inharmonic physical or audible frequency content of interest).
this sounds like the old "octave problem". take a perfectly periodic 200 Hz waveform (doesn't need to be a sine). the pitch detector says it's 200 Hz. now add to it a 100 Hz waveform that is -80 dB relative to the 200 Hz waveform. what's the fundamental frequency? mathematically? or perceptually? this kind of problem, *is* a problem but is sorta orthogonal to whether ASDF or AMDF or auto-correlation.
> Others here have mentioned using long zero-padded fft's as one alternative > for certain types of pitch detection/measurement.
i wouldn't do that. you still need to deal with the possibility of missing or weak harmonics (inc. fundamental). i agree with Dmitry Terez about not using FFT. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
dt@soundmathtech.com wrote:
> =
> Didn't I tell everybody here that pitch detection problem is solved ? > =
> It seems that some people are unable to learn, or they are deliberatly > trying to mislead general public asking questions here. > =
> Go to http://www.soundmathtech.com/p=ADitch for more information. > =
> Also, US Patent Application at http://www.uspto.gov/patft > (Pub. No. 20030088401)
Thats one solution. My guess is that there are at least 10 other possible solutions, at least one of which is better than whatever is covered by that patent. Erik -- = +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Never argue with stupid people. They'll just drag you down to their level and beat you with experience
in article 4252FD0C.BDDBEDA9@mega-nerd.com, Erik de Castro Lopo at
nospam@mega-nerd.com wrote on 04/05/2005 17:03:

> dt@soundmathtech.com wrote: >> >> Didn't I tell everybody here that pitch detection problem is solved ? >> >> It seems that some people are unable to learn, or they are deliberatly >> trying to mislead general public asking questions here. >> >> Go to http://www.soundmathtech.com/p&#4294967295;itch for more information. >> >> Also, US Patent Application at http://www.uspto.gov/patft >> (Pub. No. 20030088401) > > Thats one solution. My guess is that there are at least 10 other > possible solutions, at least one of which is better than whatever > is covered by that patent.
i'm gonna download the MATLAB stuff and see if i can try it out. long ago (about 2002 when it came out) i took a good look at the ICASSP paper Dmitry published about this method, and concluded that there were many elements of the AMDF function in it. it was jazzed up in some ways, but it came down to subtracting shifted versions of the waveform from itself, applying the magnitude, subtracting that magnitude difference from some parameter (that inverts the measure), applying the unit step function, adding up a few of these (i thought it was exceedingly small number, like 3 terms) and then doing some kind of statistical histogram thing and looking for a maximum. Dmitry has denied that it's merely a jazzed-up AMDF and has challenged me to produce some waveform that fools it (i said that one could since the unit step function throws away information and that can be exploited to fool the algorithm). i probably should put some time into answering that challenge but i don't have the time (it would take hours to days to really research the thing and i ain't a grad student anymore). anyway to Dmitry: i think you underestimate some of the expertise in pitch detection in both of these newsgroups. some of us have a great deal of experience in it and some theoretical expertise also. the overt confidence in your W.C. Fields sales technique might not be warranted. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."