Reply by robert bristow-johnson July 6, 20112011-07-06
On Jul 5, 9:10=A0am, Jerry Avins <j...@ieee.org> wrote:
> Isn't looking at the spacing of the harmonics worth while?
sure, if you're doing this in the frequency domain. if you are doing autocorrelation or AMDF, then it sorta deals with the missing harmonics in the time domain.
> If I saw just 375, 500, and 625 Hz, I'd be thinking about a missing 125 f=
undamental.
>
along with the missing 2nd harmonic at 250 Hz. but the peak in autocorrelation (or the valley in AMDF) will still be at 8 ms and multiples thereof (maybe it's a 62.5 Hz waveform missing its fundamental, 2nd through 5th harmonics, 7th, 9th, and the 11th and above). you need not assume anything other than some degree of periodicity when using a method that makes no assumption other than periodicity. r b-j
Reply by Jerry Avins July 5, 20112011-07-05
Isn't looking at the spacing of the harmonics worth while? If I saw just 375, 500, and 625 Hz, I'd be thinking about a missing 125 fundamental.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
Reply by robert bristow-johnson July 5, 20112011-07-05
On Jul 5, 12:09=A0am, Ben Bradley <ben_u_brad...@etcmail.com> wrote:
> (quoting an earlier post) > On Fri, 01 Jul 2011 00:28:49 -0500, Tim <t...@seemywebsite.please> > wrote: > > >On Thu, 30 Jun 2011 08:25:38 -0500, bloodfire1004 wrote: > > >> Ive been recently using FFT for Pitch Detection and I notice that, > >> although the notes are correct (e.g. C, D#, etc.), there are a lot of > >> notes that are in the wrong octave (e.g. E2 is categorized as E3, C3 i=
s
> >> categorized as C4, always an octave up). > > >> Why is this the case? My algorithm is after calculating the FFT bins, =
I
> >> get the bin with the greatest intensity and calculate which frequency =
it
> >> is. > > >> Any help on this? Thanks! > > >Welcome to the fascinating realm of human perception. =A0A note can be > >perceived even if the fundamental is suppressed or missing. > > =A0 =A0I think it's pretty unusual for the fundamental not to be there at > all.
well, there are electronic (sorta) instruments that the nature of the timbre of the note is that they're real heavy on some harmonic or harmonic group and there may be very little energy in the 1st harmonic. but if there is energy in the 2nd, 3rd, and 4th, you can infer a fundamental at the 1/2 of the 2nd (or 1/3 of the 3rd). one example is a Wurlitzer model 200 electric piano. the waveform for that looks like a sorta rounded or smoothed sawtooth. but if you look closely, every other sawtooth is a little smaller than its adjacent neighbors. just slightly. so a single cycle looked like two sawtooths of equal amplitude, but one was a little longer than the other. you can do a DFT on this waveform and you'll see that it's heavy on the even numbered harmonics and very little in the odd harmonics *including* the first harmonic. but there's enough in the odd harmonics that you can, if you look at it carefully, determine that period (the reciprocal of the fundamental) is length of both long and short sawtooths added together (which is what it should be). but this kinda waveform can fool a pitch detector that emphasizes too much dependence on energy at the fundamental or even the other odd harmonics. and it's the odd harmonics that give the period away. if there are only even harmonics, it might be a note pitch at an octave higher (that would have both even and odd harmonics).
> =A0 =A0Perhaps if the largest-bin approach gives pitch at frequence F as > the loudest frequency, check the bins for pitch F/2, F/3 and F/4. If > any are less than maybe 6dB below F, then the loudest is a harmonic, > and you should pick the biggest out of the lower bins. > > =A0 =A0This of course still may not be very reliable. But if you actually > look at the levels in all the bins for every pitch, it will give you a > a good idea of the levels of the fundamental vs. the 2nd, 3rd and 4th > harmonics at each pitch, and you can adjust thresholds accordingly. > > =A0 =A0Is this an acoustic guitar? The lowest E note is I think the most > likely to have a harmonic higher than the fundamental, as the > helmholtz resonance of the body is usually tuned to about the lowest G > note. > > > > >I believe that one needs to analyze the spectrum for the phantom > >fundamental by taking the cepstrum -- but I'm flying nearly blind here, > >I've never done pitch identification.
isn't it sorta necessary to first find the pitch before you can really do something with the cepstrum? or is it LPC and levison-durbin, i forget? if what you're trying to find is the (possibly time-variant) fundamental frequency of a quasi-periodic signal (where the base-2 log of that is your pitch in octaves), then what you want to estimate is the best guess of the (possibly time-variant) period of quasi-periodic signal. the fact that a portion of the function looks a lot like (but not necessarily exactly like) a displaced portion is the only thing to assume. so how would you naturally measure that if this "almost periodicity" is all that you're looking for? now's the time to look in some really old texts and pull out AMDF. then think about how you might generalize it. but AMDF might serve you very well.
> On Fri, 01 Jul 2011 22:50:32 -0500, "bloodfire1004" > > <bloodfire1004@n_o_s_p_a_m.yahoo.com> wrote: > >Hi all and thanks for the suggestions! > > >For more information, I am just basically getting the frequency bin with > >the highest intensity and considering that as the fundamental frequency. > >Granted, this is not that good of a practice but I don't know any other > >techniques on how to get the pitch. > > >I also implemented Auto-Correlation and I 'think' that it seems to have > >better results although I should still test out on more samples.
BTW, there are a few different ways of implementing autocorrelation. and, during note attacks (and maybe in other conditions) it is not uncommon that a segment of audio correlates better with a segment that is *two* periods away than a segment displaced by one period. it's essentially an octave error. r b-j
Reply by Ben Bradley July 5, 20112011-07-05
(quoting an earlier post)
On Fri, 01 Jul 2011 00:28:49 -0500, Tim <tim@seemywebsite.please>
wrote:

>On Thu, 30 Jun 2011 08:25:38 -0500, bloodfire1004 wrote: > >> Ive been recently using FFT for Pitch Detection and I notice that, >> although the notes are correct (e.g. C, D#, etc.), there are a lot of >> notes that are in the wrong octave (e.g. E2 is categorized as E3, C3 is >> categorized as C4, always an octave up). >> >> Why is this the case? My algorithm is after calculating the FFT bins, I >> get the bin with the greatest intensity and calculate which frequency it >> is. >> >> Any help on this? Thanks! > >Welcome to the fascinating realm of human perception. A note can be >perceived even if the fundamental is suppressed or missing.
I think it's pretty unusual for the fundamental not to be there at all. Perhaps if the largest-bin approach gives pitch at frequence F as the loudest frequency, check the bins for pitch F/2, F/3 and F/4. If any are less than maybe 6dB below F, then the loudest is a harmonic, and you should pick the biggest out of the lower bins. This of course still may not be very reliable. But if you actually look at the levels in all the bins for every pitch, it will give you a a good idea of the levels of the fundamental vs. the 2nd, 3rd and 4th harmonics at each pitch, and you can adjust thresholds accordingly. Is this an acoustic guitar? The lowest E note is I think the most likely to have a harmonic higher than the fundamental, as the helmholtz resonance of the body is usually tuned to about the lowest G note.
> >I believe that one needs to analyze the spectrum for the phantom >fundamental by taking the cepstrum -- but I'm flying nearly blind here, >I've never done pitch identification.
On Fri, 01 Jul 2011 22:50:32 -0500, "bloodfire1004" <bloodfire1004@n_o_s_p_a_m.yahoo.com> wrote:
>Hi all and thanks for the suggestions! > >For more information, I am just basically getting the frequency bin with >the highest intensity and considering that as the fundamental frequency. >Granted, this is not that good of a practice but I don't know any other >techniques on how to get the pitch. > >I also implemented Auto-Correlation and I 'think' that it seems to have >better results although I should still test out on more samples.
As long as we're (or at least I am) kludging heuristics together, maybe you can do both of these, see if you can find where (as in which notes or note ranges) one method is more reliable than the other, and use that one for that note range. On the other hand, research into more reliable pitch detection techniques seems like it would be a better idea.
>One thing that is really confusing me is regarding the 'transposition >instrument' that I have been reading in the guitar. Something about being >one octave below the supposed played note? Can someone clarify me on this?
If this is supposed to be sheet music written an octave above or below the pitch being played, that's a simple transformation (up 12 notes or down 12 notes) after you can reliably detect the right notes. Maybe we need more context on this "transposition instrument."
> >Thanks!
Reply by robert bristow-johnson July 2, 20112011-07-02
On Jul 1, 11:50&#4294967295;pm, "bloodfire1004"
<bloodfire1004@n_o_s_p_a_m.yahoo.com> wrote:
> > For more information, I am just basically getting the frequency bin with > the highest intensity and considering that as the fundamental frequency.
what if the fundamental frequency is in between bins? and what if the 2nd or 3rd harmonic has higher intensity than the fundamental?
> Granted, this is not that good of a practice but I don't know any other > techniques on how to get the pitch. > > I also implemented Auto-Correlation and I 'think' that it seems to have > better results although I should still test out on more samples. > > One thing that is really confusing me is regarding the 'transposition > instrument' that I have been reading in the guitar. Something about being > one octave below the supposed played note? Can someone clarify me on this?
you need to be more specific about what you mean. is this "transposition instrument" essentially your pitch detector making an octave error? octave errors are common, even using a better technique like AMDF or autocorrelation. it's because if some T is a period, that is x(t+T) approx= x(t) for all t then it is also true that x(t+2T) approx= x(t) there are some things you can do about it. not that it always works all the time. r b-j
Reply by bloodfire1004 July 2, 20112011-07-02
Hi all and thanks for the suggestions!

For more information, I am just basically getting the frequency bin with
the highest intensity and considering that as the fundamental frequency.
Granted, this is not that good of a practice but I don't know any other
techniques on how to get the pitch.

I also implemented Auto-Correlation and I 'think' that it seems to have
better results although I should still test out on more samples. 

One thing that is really confusing me is regarding the 'transposition
instrument' that I have been reading in the guitar. Something about being
one octave below the supposed played note? Can someone clarify me on this?

Thanks!
Reply by robert bristow-johnson July 1, 20112011-07-01
On Jun 30, 9:25&#4294967295;am, "bloodfire1004"
<bloodfire1004@n_o_s_p_a_m.yahoo.com> wrote:
> Ive been recently using FFT for Pitch Detection and I notice that, although > the notes are correct (e.g. C, D#, etc.), there are a lot of notes that are > in the wrong octave (e.g. E2 is categorized as E3, C3 is categorized as C4, > always an octave up). > > Why is this the case? My algorithm is after calculating the FFT bins, I get > the bin with the greatest intensity and calculate which frequency it is. > > Any help on this? Thanks!
not that i'll be able to have a conversation (since Google groups isn't fetching and updating posts promptly), but you could be having the classing "Octave problem" with pitch detection, but you're not telling us much what you're doing with the FFT to estimate pitch. the FFT will display peaks at all harmonics of a single note that have appreciable energy. how are you avoiding counting those harmonics as separate notes? and you should be aware that you may not have appreciable energy even at the fundamental of a note and then you'll miss that one completely. you should use a method that only assumes some degree of periodicity, with the smallest possible period being the reciprocal of the fundamental frequency. and pitch, in octaves, is the log2(fundamental_frequency), *not* necessarily log2(strongest_frequency). r b-j
Reply by Tim July 1, 20112011-07-01
On Thu, 30 Jun 2011 08:25:38 -0500, bloodfire1004 wrote:

> Ive been recently using FFT for Pitch Detection and I notice that, > although the notes are correct (e.g. C, D#, etc.), there are a lot of > notes that are in the wrong octave (e.g. E2 is categorized as E3, C3 is > categorized as C4, always an octave up). > > Why is this the case? My algorithm is after calculating the FFT bins, I > get the bin with the greatest intensity and calculate which frequency it > is. > > Any help on this? Thanks!
Welcome to the fascinating realm of human perception. A note can be perceived even if the fundamental is suppressed or missing. I believe that one needs to analyze the spectrum for the phantom fundamental by taking the cepstrum -- but I'm flying nearly blind here, I've never done pitch identification. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Reply by Les Cargill June 30, 20112011-06-30
bloodfire1004 wrote:
> Ive been recently using FFT for Pitch Detection and I notice that, although > the notes are correct (e.g. C, D#, etc.), there are a lot of notes that are > in the wrong octave (e.g. E2 is categorized as E3, C3 is categorized as C4, > always an octave up). > > Why is this the case? My algorithm is after calculating the FFT bins, I get > the bin with the greatest intensity and calculate which frequency it is. > > Any help on this? Thanks!
So dump the top five bins out and look at them. I will bet you are getting harmonics. -- Les Cargill
Reply by bloodfire1004 June 30, 20112011-06-30
Ive been recently using FFT for Pitch Detection and I notice that, although
the notes are correct (e.g. C, D#, etc.), there are a lot of notes that are
in the wrong octave (e.g. E2 is categorized as E3, C3 is categorized as C4,
always an octave up).

Why is this the case? My algorithm is after calculating the FFT bins, I get
the bin with the greatest intensity and calculate which frequency it is.

Any help on this? Thanks!