Ye olde "Guitar Tuner" question . . .


Senior Member
OK, so i've seen a lot of posts asking how to make a Music/Guitar tuner and so on........and oddly enough, a few days ago i was asked by a work collegue if *I* could make a Guitar tuner for him.
My immediate response (including lots of swearing) was "Go buy one, it'll be 100 times cheaper than me working out the code, and mine might not even work".

It then got me thinking about HOW i would achieve such a project.
If anything, it's just a self-satisfaction project to prove if it could be done and accuare too....

I don't think i can find any good reason why i would prefer my own picaxe tuner versus a professional/DSP/super accurate tuner for a measly $50-$200....well, other than bragging rights or something.

My FIRST concern coming to mind is the complete lack of NICE numbers in the musical frequencies to work with.
Besides 'A' which seems to be the only note with a perfectly evenly multiplying number throughout the octaves, all other notes are fractional values.

For example:
A = 440Hz
A# = 466.16 Hz,
B = 493.88 Hz,
C = 523.25 Hz, etc.

My next thought would be to simply multiply the frequency x 100 to get rid of the decimal fraction, so 'Note C' at 523.25Hz would now become 52325, a nice non-fractional number to work with.

I guess using the 'count' command would be the main way to sample a frequency for a given period of 1-5 seconds to find a nice stable average frequency to work with.

Obviously the analog guitar signal right at the beginning is going to be a mess of harmonics, but i'm sure buffering the analog signal and then feeding it through a schmitt trigger to square it up might be my first step to approaching a cleaner digital signal to work within the picaxe realm.

I now wonder if maybe i would use a reference oscillator (let's use 'middle C' for example to match the note/string that i'm trying to tune) and then the guitar signal would be schmitt gated to square it up and then AND gated with the Oscillators signal ('middle C') into a 2nd schmitt trigger, this would almost guarantee the majority of the natural 'C note' signal is now being dealt with into the picaxe and not all the harmonics rubbish.

This is about as far as i got by just 'thinking' about how i might approach it, if i was to go further and build something together.

Anyone up for comments? other than "don't do it" lol ;-)


Senior Member
Guitar tuners are about $5 at the local thrift store. There are lots of "apps" for smart phones for tuning guitars. That is is the practical advice.

Now for the fun part, thinking about how one would actually do it yourself. I would start by looking at the waveforms on an oscilloscope. This would at least give you an idea of what is going on.

With zero real knowledge of the waveforms, I would amplify the signal and use a zero crossing detector to create a square wave that could be measured with the picaxe. Pulsein might be a way to measure the period. Another path might be to mix the incoming signal with a locally generated signal of desired frequency. Then use the beat frequency as a way to judge the closeness to ideal frequency.

I'll be interested in following your project.



Well-known member
Obviously the analog guitar signal right at the beginning is going to be a mess of harmonics,
You highly understate the analog requirements to obtain some kind of digital reference, and then there are frequency stabilization problems unless you use a crystal stabilized and calibrated reference frequency. Remember that "Atlas" could lift the world if only he had somewhere to stand!


Senior Member
Fun stuff. I did some quickie experiments reading musical notes using a BASIC Stamp (quite similar to a PICAXE) using a cheap microphone module and the COUNT command. As long as there is a pure sine wave (no complex sounds), it actually works to a certain extent.