{"id":2531,"date":"2010-02-05T13:52:59","date_gmt":"2010-02-05T13:52:59","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/02\/05\/guitar-tuner\/"},"modified":"2017-01-06T21:27:20","modified_gmt":"2017-01-07T02:27:20","slug":"guitar-tuner","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/02\/05\/guitar-tuner\/","title":{"rendered":"Guitar Tuner"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction><\/introduction>\r\n   <p>Today's Pick comes to us from guest Picker (pun intended) and MathWorks applications engineer <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31289\">Eric Johnson<\/a>. When he's not playing with MATLAB, Eric can occasionally be seen roaming the floors at The MathWorks with his guitar in hand.\r\n   <\/p>\r\n   <p><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><b>*<\/b><\/p>\r\n   <p>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\r\n      from time to time. Tune it in MATLAB using <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/67204\">Ryan's<\/a> <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26367-guitar-tuner\">Guitar Tuner<\/a> tool!\r\n   <\/p>\r\n\r\n   <p>I like Guitar Tuner's clean, simple interface. When the note is within 10 cents (0.6% of the correct frequency) the tuner\r\n      line lights up green. All of the code is contained in a single <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/creating_guis\/f3-998349.html\">GUIDE-created<\/a> MATLAB file so it can be easily customized. For instance, we can modify these lines:\r\n   <\/p><pre>    %CHECK IF TUNED WITHIN 10 CENTITONE:\r\n    flat  = 15.43379*exp(0.05776234*(tone-0.1));\r\n    sharp = 15.43379*exp(0.05776234*(tone+0.1));<\/pre><p>to change the sensitivity to +\/- 20 cents:<\/p><pre>    %CHECK IF TUNED WITHIN 20 CENTITONE:\r\n    flat  = 15.43379*exp(0.05776234*(tone-0.2));\r\n    sharp = 15.43379*exp(0.05776234*(tone+0.2));<\/pre><p>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\r\n      applications you might also be interested in <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26509-musical-notes\">Musical Notes<\/a>. Musical Notes is a collection of functions for converting between scientific pitch notation (A#4, E5, etc.), frequency,\r\n      semitone\/interval, and cents.\r\n   <\/p>\r\n   <p><a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2531#respond\">Comments?<\/a><\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_2d0ee944ff8b4304bac034613a793fce() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='2d0ee944ff8b4304bac034613a793fce ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 2d0ee944ff8b4304bac034613a793fce';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Brett Shoelson';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_2d0ee944ff8b4304bac034613a793fce()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.9<br><\/p>\r\n<\/div>\r\n<!--\r\n2d0ee944ff8b4304bac034613a793fce ##### SOURCE BEGIN #####\r\n%% Guitar Tuner\r\n%%\r\n% Today's Pick comes to us from guest Picker (pun intended) and MathWorks\r\n% applications engineer\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31289 Eric Johnson>. When he's not playing with MATLAB,\r\n% Eric can occasionally be seen roaming the floors at The MathWorks with his guitar in\r\n% hand.\r\n%%\r\n% *********************************************************************************\r\n%\r\n% Do you play guitar and keep one near your computer for interim jamming? It's a\r\n% fact of life that your guitar will need tuning from time to time. Tune it in\r\n% MATLAB using\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/67204 Ryan's> \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26367-guitar-tuner Guitar Tuner> tool!\r\n% \r\n% <<https:\/\/www.mathworks.com\/matlabcentral\/fx_files\/26367\/1\/Tuner.png>>\r\n%\r\n% I like Guitar Tuner's\r\n% clean, simple interface. When the note is within 10 cents (0.6% of the correct\r\n% frequency) the tuner line lights up green. All of the code is contained in a\r\n% single <https:\/\/www.mathworks.com\/help\/releases\/R2009b\/techdoc\/creating_guis\/f3-998349.html GUIDE-created> MATLAB file so it can be easily customized. For instance,\r\n% we can modify these lines:\r\n%\r\n%      %CHECK IF TUNED WITHIN 10 CENTITONE:\r\n%      flat  = 15.43379*exp(0.05776234*(tone-0.1));\r\n%      sharp = 15.43379*exp(0.05776234*(tone+0.1));\r\n%\r\n% to change the sensitivity to +\/- 20 cents:\r\n%\r\n%      %CHECK IF TUNED WITHIN 20 CENTITONE:\r\n%      flat  = 15.43379*exp(0.05776234*(tone-0.2));\r\n%      sharp = 15.43379*exp(0.05776234*(tone+0.2));\r\n%\r\n% It also has a built in tone generator for tuning by ear. On a related note\r\n% (pun intended) if you are using MATLAB for music-related applications you\r\n% might also be interested in \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26509-musical-notes Musical Notes>.\r\n% Musical Notes is a collection of functions for converting between scientific\r\n% pitch notation (A#4, E5, etc.), frequency, semitone\/interval, and cents.\r\n%%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2531#respond Comments?>\r\n##### SOURCE END ##### 2d0ee944ff8b4304bac034613a793fce\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n   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... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/02\/05\/guitar-tuner\/\">read more >><\/a><\/p>","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2531"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2531"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2531\/revisions"}],"predecessor-version":[{"id":8332,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2531\/revisions\/8332"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}