2/04/2008

02-04-08 - 4

I updated the guitar tuner app with slightly better harmonic/fundamental tracking. It's still not ideal, that's sort of a messy heuristic problem, I could do better than I am doing but whatever it's not hurting the app much so there it is. There are a lot of advantages to all the noise tolerance work; I can tune my guitar while cars are driving by outside, which totally freaks out my handheld crystal tuner thingy; also I can just use the super shitty mic that's built in to my laptop and actually tune pretty well. One ugly thing is that the guitar's low E is very close to the kill noise frequency threshold I'm using (it's 82 Hz and I kill everything below 77 Hz) which can cause some inaccuracy on the low E if you aren't careful, cuz part of the spectrum tail gets cut off.

For my own reference in case I come back to it : there are a few issues with the whole fundamental frequency thing. I mainly modulate out octaves, so F - 2F - 4F harmonics aren't a problem, it gets really screwy when you switch from 2F to 3F , and actually even 5F can be the highest peak. If you get a spectrum where the 3F peak is biggest, but there are still solid 1F and 2F peaks, that's pretty easy to detect. Another case is sometimes the 1F peak is completely missing, but if there's a 2F peak you can still deal with that by looking at 2/3 or by seeing that the spacing between peaks is F. The really really evil case comes from time evolution. Sometimes you can strike a note and it starts up with strong peaks at 1F,2F, and 3F. Over time each of their amplitudes changes and you can get cases where the 1F and 2F peaks almost completely disappear and you're left with only a 3F peak. To handle that correctly you have to use temporal continuity and just assume that that sound is still acting like a 1F pitch (sometime the 1F and 2F peaks come back and the 3F peak dies out as time keeps evolving). The spacing between the peaks in the frequency domain is a pretty way to get the base pitch (you imagine an additional peak at zero frequency).

I hate relying too much on temporal continuity because it mean that short-time errors get persisted. It's much cooler if I can do everything without relying on the previous frame. You do get a tiny short-time error from fourier analysis of transients, but that's negligible. The real problem comes from real world short-time sounds. With tuning a guitar, when you first strike a string there are lots of funny sounds from your finger rubbing the string and perhaps the string slapping the body and all that stuff that only lasts a second or so. If you start building in too much continuity, you could pick up weird pitches in that mess and then try to persist them. Really once the clean note starts sounding you want all that junk to be forgotten.

No comments:

old rants