{"id":60,"date":"2023-09-04T20:23:49","date_gmt":"2023-09-04T20:23:49","guid":{"rendered":"https:\/\/pencilshrubs.com\/?p=60"},"modified":"2023-10-11T01:50:41","modified_gmt":"2023-10-11T01:50:41","slug":"alda-a-music-dsl","status":"publish","type":"post","link":"https:\/\/pencilshrubs.com\/?p=60","title":{"rendered":"Alda: A Music DSL"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>piano: o5 c4 c+ d d+ e f f+ g g+ a a+ b &gt; c<\/code><\/pre>\n\n\n\n<p>By playing that piece of code in Alda, a DSL, you can hear the fifth octave on a piano.<\/p>\n\n\n\n<p>To play the first four measures of <em>Ode to Joy <\/em>by Beethoven in Alda:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>piano: o4 f4 f g a | a g f e | d d e f | f4. e8 e2<\/code><\/pre>\n\n\n\n<p>Here&#8217;s what it means, broken down.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>The first section states the instrument. I could change it to <em>violin<\/em>, <em>flute<\/em> or any other instrument.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>piano:<\/code><\/pre>\n\n\n\n<p>Next is the octave, which in this case is the fourth.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>o4<\/code><\/pre>\n\n\n\n<p><em>f4 <\/em>is the note and its duration\u2014<em>4 <\/em>means a quarter note.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>f4<\/code><\/pre>\n\n\n\n<p>Then, there are the other notes, along with separating pipe symbols to represent measures. They&#8217;re ignored by the program but make the code easier to understand.<\/p>\n\n\n\n<p>Finally, that brings us to <em>f4.<\/em>, which is a dotted note. For those who don&#8217;t know what dotted notes are, they&#8217;re 3\/2 of the original note.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>f4.<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>That&#8217;s not all, though. You can also add variables.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>volone = (vol 25)\nvoltwo = (vol 50)\nvolthree = (vol 100)\n\nnotes = c2\/e\/g\n\npiano:\n  volone notes\n  voltwo notes\n  volthree notes<\/code><\/pre>\n\n\n\n<p>This code would play the C Major chord at three different volumes \u2014 25, 50, and 100.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p class=\"has-black-color has-text-color\">You can download Alda and find the tutorial at <a rel=\"noreferrer noopener\" href=\"http:\/\/alda.io\" data-type=\"URL\" data-id=\"alda.io\" target=\"_blank\">alda.io<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>(\/\\*&gt;*)\/\\<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By playing that piece of code in Alda, a DSL, you can hear the fifth octave on a piano. To&#8230;<\/p>\n","protected":false},"author":1,"featured_media":67,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[22,21],"_links":{"self":[{"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":10,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions\/103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=\/wp\/v2\/media\/67"}],"wp:attachment":[{"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pencilshrubs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}