Having slept on this....think I'm gonna have to give this one much more thought.
Not the interrupt frequency problem (btw - Bert, I think you were right...put the peak detect code in the main loop!), but I noticed late last night that for the above code 'trapped' the peak of a nice sigen sine wave very well, a real life guitar signal caused problems. Basically, a guitar signal is full of harmonics...so you've not just got a fundamental going on, you've got strong second harmonic immediately after a string has been plucked - these harmonics are lower in signal magnitude & worse still, force the signal to cross zero too - which plays havoc with the larger fundamental peak detect bit.
I guess what I really need is a slick bit of code that acts like a diode with a smoothing cap following on - there's probably a role to play with DTs averaging routines here!
Something along these lines...
1. Is present ADC sample larger than last ...if so then store it (that'll be the diode bit)
2. When cycle crosses zero, then largest sample from the logic above is the peak.
3. Have a rolling average for all the peaks (that'll be the capactor/LPF bit)
One to mull.
Bookmarks