{"id":319,"date":"2009-06-18T09:17:30","date_gmt":"2009-06-18T16:17:30","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1576"},"modified":"2009-06-18T09:17:30","modified_gmt":"2009-06-18T16:17:30","slug":"random-guitar-tablature","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=319","title":{"rendered":"Random Guitar Tablature"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/ number of notes in chord\r\nvar noteNum:int = 3;\r\nvar lowNote:Number = 0;\r\nvar highNote:Number = 4;\r\n\/\/ delay between chords\r\nvar delay:int = 2000;\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nvar chord:String = &quot;&quot;;\r\nhighNote += 1;\r\nvar tab:TextField = TextField(addChild(new TextField()));\r\ntab.x = tab.y = 20;\r\ntab.defaultTextFormat = new TextFormat(&quot;Courier&quot;, 12);\r\ntab.multiline = true;\r\ntab.width = 200;\r\n\r\nchangeChord();\r\nsetInterval(changeChord, delay);\r\n\r\nfunction changeChord():void{\r\n\tvar strings:Array = &#x5B;];\r\n\tstrings&#x5B;0] = &quot;e|---------------n&quot;\r\n\tstrings&#x5B;1] = &quot;B|---------------n&quot;\r\n\tstrings&#x5B;2] = &quot;G|---------------n&quot;\r\n\tstrings&#x5B;3] = &quot;D|---------------n&quot;\r\n\tstrings&#x5B;4] = &quot;A|---------------n&quot;\r\n\tstrings&#x5B;5] = &quot;E|---------------n&quot;\r\n\t\r\n\tfor (var i:int = 0; i&lt;3; i++){\r\n\t\tvar place:int = 5 + i * 4;\r\n\t\tvar choices:Array = &#x5B;0,1,2,3,4,5];\r\n\t\tfor (var j:int = 0; j&lt;noteNum; j++){\r\n\t\t\tvar ii:int = int(Math.random()*choices.length);\r\n\t\t\tvar index:int = choices&#x5B;ii];\r\n\t\t\tstrings&#x5B;index] = strings&#x5B;index].slice(0, place) + (int(Math.random()*highNote)+lowNote) +  strings&#x5B;index].substring(place+1);\r\n\t\t\tchoices.splice(ii, 1);\r\n\t\t}\r\n\t}\r\n\tchord = strings.join(&quot;&quot;);\r\n\ttab.text = chord;\r\n}\r\n<\/pre>\n<p>I&#8217;m working on a small program to help me practice guitar. It randomly generates <a href=\"http:\/\/en.wikipedia.org\/wiki\/Tablature\" target=\"blank\">guitar tabs<\/a>. The idea for the program is similar to a program that helps you learn to type (like <a href=\"http:\/\/en.wikipedia.org\/wiki\/Mavis_Beacon_Teaches_Typing\">Mavis Beacon<\/a>). <\/p>\n<p>I wrote this snippet today as a proof of concept &#8211; just to help me start thinking about what kind of features I want the program to have. There are settings at the top so that you can tweak the number of notes in the chord and the delay between chords etc&#8230;.<\/p>\n<p>It generates three chords at a time&#8230; here are some stills:<br \/>\n<img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/tabs1.gif\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ number of notes in chord var noteNum:int = 3; var lowNote:Number = 0; var highNote:Number = 4; \/\/ delay between chords var delay:int = 2000; \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ var chord:String = &quot;&quot;; highNote += 1; var tab:TextField = TextField(addChild(new TextField())); tab.x = tab.y = 20; tab.defaultTextFormat = new TextFormat(&quot;Courier&quot;, 12); tab.multiline = true; tab.width = 200; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,20,21],"tags":[3,14,4],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-random","category-string-manipulation","category-strings","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}