A reader recently asked me if I could post a guitar tuner patch. Here it is!
It is based on the [sigmund~] object that comes with Pd vanilla. It does pitch tracking, which means that it analyses the frequency of the fundamental -and optionally of partials- in the incoming sound (probably using FFT analysis). This is a great object that I used previously in my (very simple) guitar synthesiser example patch.
In the context of a guitar tuner, we assume that the musician plucks the strings one at a time. [sigmund~] is very good at analysing single notes (or single pitches), so this is the perfect object for us.It has many parameters that can be set, but the size of the analysis window is the most important of all for a guitar tuner. The larger the window, the lower the lowest possible frequency that can be detected. A lower pitch means a longer wavelength, and less oscillations for a given period of time : the window needs to be large enough for [sigmund~] to have enough data to analyse the pitch accurately. The drawback of a large analysis window is increased latency, but it really doesn’t matter in the case of a tuner.
In the picture above you can see the GUI of the guitar tuner patch. If your string is perfectly in tune, the pointer of the horizontal slider should be perfectly in the middle, and the value in the number box below should be 0. For each target note (say, E for the first string), the width of the slider is equal to a whole step : if the pointer is close to the left end, your string is tuned to Eb, and if it is close to the right end it’s tuned to F. The target note that the patch detects is indicated in the green area. The toggle to the right is there to switch audio on and off inside the tuner, because pitch tracking is quite expensive and you don’t want the tuner to to stay on while you’re playing.
A nice feature of this patch is the possibility of using practically any tuning. The tuner is set to standard tuning by default (E, A, D, G, B ,E), but you can change the target tuning by simply sending a list of 6 midi notes to the tuner’s inlet (lower E is 40, F is 41, F# is 42, etc.). A different list for open-G tuning is there in the example patch just to show you how it works (I kind of like the blues🙂 ).
Please not that this patch is not perfect… You are expected to pluck your strings gently! Slaming your strings may confuse [sigmund~] as the spectrum of the sound may be very different, and give erratic results. For this same reason, the algorithm used to detect whether the note being played is close a specific target note (look inside “IdentifyNote” for details) actually detects the note at three different octaves. This means that if you wanted to tune your lower E string, the patch would actually look for lower E, E one octave higher, and E two octaves higher. It could become confusing if you used a specific tuning that would include a F, as the patch would look for a note between Eb and F for the E string, and for a note between E and F# for the F string. I’ll post an upadte when I find a way to fix this. Anyway, I think it works great for standard and common open tunings.
You can download the patch here. I thought about posting a sound sample for awhile, but then I decided that not everybody has my sense of humour…