File Exchange Pick of the Week

February 5th, 2010

Guitar Tuner

Today's Pick comes to us from guest Picker (pun intended) and MathWorks applications engineer Eric Johnson. When he's not playing with MATLAB, Eric can occasionally be seen roaming the floors at The MathWorks with his guitar in hand.

***************************

Do you play guitar and keep one near your computer for interim jamming? It's a fact of life that your guitar will need tuning from time to time. Tune it in MATLAB using Ryan's Guitar Tuner tool!

I like Guitar Tuner's clean, simple interface. When the note is within 10 cents (0.6% of the correct frequency) the tuner line lights up green. All of the code is contained in a single GUIDE-created MATLAB file so it can be easily customized. For instance, we can modify these lines:

    %CHECK IF TUNED WITHIN 10 CENTITONE:
    flat  = 15.43379*exp(0.05776234*(tone-0.1));
    sharp = 15.43379*exp(0.05776234*(tone+0.1));

to change the sensitivity to +/- 20 cents:

    %CHECK IF TUNED WITHIN 20 CENTITONE:
    flat  = 15.43379*exp(0.05776234*(tone-0.2));
    sharp = 15.43379*exp(0.05776234*(tone+0.2));

It also has a built in tone generator for tuning by ear. On a related note (pun intended) if you are using MATLAB for music-related applications you might also be interested in Musical Notes. Musical Notes is a collection of functions for converting between scientific pitch notation (A#4, E5, etc.), frequency, semitone/interval, and cents.

Comments?


Get the MATLAB code

Published with MATLAB® 7.9

6 Responses to “Guitar Tuner”

  1. guitar cords replied on :

    Nice!, discovered your page on digg.Happy I finally tested it out. Unsure if its my Opera browser,but sometimes when I visit your site, the fonts are really small? Anyway, love your site and will return.Bye

  2. Liam Brennan replied on :

    Ryan like the tuner really cool i have a question Im trying to understand the code and I see you use a scaling fact or of 1.0015 where did you get that from and why that number.

    Thanks In Advance

    Liam

  3. jiro replied on :

    @Liam,

    I suggest posting your question to Ryan on his File Exchange entry page:

    http://www.mathworks.com/matlabcentral/fileexchange/26367#comments

  4. Liam Brennan replied on :

    Thanks jiro

  5. mawie replied on :

    wow your tuner really work .. could you help me with the code explanation senjacrew@hotmail.com

  6. Brett replied on :

    Mawie, See Jiro’s comment to Liam above. You should do your best to try to understand the code on your own, then if you have specific comments or questions, share them directly with the author of the file. The CSSM newsgroup is also a great place to pose questions:

    http://www.mathworks.com/matlabcentral/newsreader/

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.