{"id":1760,"date":"2015-04-02T12:21:47","date_gmt":"2015-04-02T12:21:47","guid":{"rendered":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1760"},"modified":"2015-04-02T13:29:58","modified_gmt":"2015-04-02T13:29:58","slug":"sonic-pi-sound-synth-application-for-learning-coding-and-music","status":"publish","type":"post","link":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/sonic-pi-sound-synth-application-for-learning-coding-and-music\/","title":{"rendered":"Sonic-PI: Sound synth application for learning coding and music"},"content":{"rendered":"\n<!-- Facebook Like Button v1.9.6 BEGIN [http:\/\/blog.bottomlessinc.com] -->\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=http%3A%2F%2Finspiredtoeducate.net%2Finspiredtoeducate%2Fsonic-pi-sound-synth-application-for-learning-coding-and-music%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px; height: 30px; align: left; margin: 2px 0px 2px 0px\"><\/iframe>\n<!-- Facebook Like Button END -->\n<p><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-content\/uploads\/2015\/04\/15555351878_5cb36826c7_z.jpg\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1762\" src=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-content\/uploads\/2015\/04\/15555351878_5cb36826c7_z.jpg\" alt=\"Sonic PI\" width=\"640\" height=\"359\" srcset=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-content\/uploads\/2015\/04\/15555351878_5cb36826c7_z.jpg 640w, http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-content\/uploads\/2015\/04\/15555351878_5cb36826c7_z-300x168.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>I love it when I find a tool that combines my two favorite hobbies: music and computers. A gifted programmer named <a href=\"https:\/\/twitter.com\/samaaron\" target=\"_blank\">Sam Aaron<\/a> has created an engaging tool for teaching music and code to makers young and old entitled Sonic-Pi. The tool delightfully blends an introduction to <a href=\"http:\/\/www.codecademy.com\/en\/tracks\/ruby\" target=\"_blank\">Ruby programming<\/a> and concepts of music through written tutorials and a real time coding area. The tool can be used on a Raspberry-PI, Windows, or Mac.<\/p>\n<p>Make sure to check out the introduction video on the front page of the <a href=\"http:\/\/sonic-pi.net\/\" target=\"_blank\">Sonic-Pi website<\/a>.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/player.vimeo.com\/video\/107897082\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>I liked how the Sonic-Pi tutorials decomposed the concepts of sound, loops, pitches, and music. I like that the tutorials progress from simple to complex ideas. Since music, R&amp;B, and techno have loops and repetitions, students encounter natural introductions to the coding concepts of sequencing commands and repeating them.<\/p>\n<p>During high school, my mother and I were looking for \u201cmother\/son\u201d activities. We decided to take a course in cocktail piano together at a local college. It was great fun! In the course, we learned how to improvise piano pieces based on a melody line a chords. \u00a0 The secret of most jazz musicians is that much of their creative thinking combines heart, physical execution and a kind of mathematical theory we call <a href=\"http:\/\/www.musictheory.net\/lessons\" target=\"_blank\">music theory<\/a>. I&#8217;m not an expert in this subject, but it&#8217;s very fun. \u00a0 It has enabled me to learn how to arrange music, basic scores, and improvise with groups. \u00a0 You can think of it as the \u201cmath\u201d or patterns that exists behind music. I think the Sonic-Pi tutorials do a good job of introducing the music theory concepts and code for ideas like scales, chords, rests, and the various timing ideas of music.<\/p>\n<p>So, what does Sonic-PI code look like? Here\u2019s my first program:<\/p>\n<p><code><br \/>\nin_thread do<br \/>\n  loop do<br \/>\n    play_chord chord(:a, :minor)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:g)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:f)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:e)<br \/>\n    sleep 2<br \/>\n  end<br \/>\nend<br \/>\nin_thread do<br \/>\n  loop do<br \/>\n    sample :drum_bass_hard<br \/>\n    sleep 1<br \/>\n    sample :drum_snare_hard<br \/>\n    sleep 1<br \/>\n  end<br \/>\nend<\/p>\n<p>in_thread do<br \/>\n  loop do<br \/>\n    sample :drum_tom_hi_soft<br \/>\n    sleep 0.5<br \/>\n    sample :drum_cymbal_closed<br \/>\n    sleep 0.5<br \/>\n  end<br \/>\nend<br \/>\nloop do<br \/>\n  play choose(scale(:a, :minor_pentatonic, num_octaves: 1))<br \/>\n  sleep choose([1,0.25])<br \/>\nend<br \/>\n<\/code><\/p>\n<p>Here&#8217;s the break down; In the following code, we play the following chord progression: AM, G, F, E.  The chord changes every two beats.<\/p>\n<p><code><br \/>\n    play_chord chord(:a, :minor)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:g)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:f)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:e)<br \/>\n    sleep 2<br \/>\n<\/code><\/p>\n<p>Since we want our chord progression to repeat itself, we wrap the chord progression in a loop.   We also wrap it in an \u201cin_thread\u201d code block so that this progression can be executed in parallel with other musical ideas.<\/p>\n<p><code>in_thread do<br \/>\n  loop do<br \/>\n    play_chord chord(:a, :minor)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:g)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:f)<br \/>\n    sleep 2<br \/>\n    play_chord chord(:e)<br \/>\n    sleep 2<br \/>\n  end<br \/>\nend<br \/>\n<\/code><\/p>\n<p>This small musical piece has a drum track executing in the loop.   The following code executes a bass drum on beat 1 and a snare drum on beat 3.   We put this musical idea in a loop and a thread so this idea can run in parallel with other ideas. <\/p>\n<p><code><br \/>\nin_thread do<br \/>\n  loop do<br \/>\n    sample :drum_bass_hard<br \/>\n    sleep 1<br \/>\n    sample :drum_snare_hard<br \/>\n    sleep 1<br \/>\n  end<br \/>\nend<br \/>\n<\/code><\/p>\n<p>In the final element of code, I wrote a few lines to randomly generate a melody based on an A minor pentatonic scale.   The \u201cscale\u201d function generates a set of notes included in the pentatonic scale.   The \u201cchoose\u201d function selects one of those notes at random.   The program will hold the note from 1 beat or an eight note. <\/p>\n<p><code><br \/>\nloop do<br \/>\n  play choose(scale(:a, :minor_pentatonic, num_octaves: 1))<br \/>\n  sleep choose([1,0.25])<br \/>\nend<br \/>\n<\/code><\/p>\n<p>I\u2019m looking forward to trying this out with older middle school students or high school students.  I know some \u201cbig kids\u201d who will enjoy this as well.  Hope you enjoy Sonic-Pi!  Send us links to your songs if you make anything cool!<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/e_CQpFaTGyw\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Top Stories on InspiredToEducate.NET<\/strong><\/p>\n<p><strong>Learning To Code<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1319\">Easy Data Visualization with Google Charts and JavaScript<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=795\">Learn to Build Your Own Conversational Bot using ChatScript<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1285\">10 Free Resources for Learning JavaScript and HTML5<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1238\">17 Fun Tools To Teach Kids To Code by @ChrisBetcher<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=623\">Benefits of Teaching Kids To Code That No One Is Talking About<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1349\">Easy Recipes for Building Android Apps using MIT App Inventor<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=738\">12 Steps To 3D Print Your Minecraft Creations<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=849\">How to Build Your Mobile App using HTML<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1079\" target=\"_blank\">Simple Minecraft Programming Using ScriptCraftJS<\/a><\/li>\n<\/ul>\n<p><strong>Science Education<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1093\">Why hate science?<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=374\">7 ideas for creating a student centered learning environment by Paul Andersen<\/a><\/li>\n<li><a href=\"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/?p=1022\">Using candy to teach DNA structure<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Join the\u00a0<a href=\"https:\/\/www.facebook.com\/groups\/1529734900588516\/\" target=\"_blank\">Spark Macon Maker Space Community on Facebook<\/a><\/strong><\/p>\n<p>Photo credit : https:\/\/www.flickr.com\/photos\/dougbelshaw\/<\/p>\n<p>&nbsp;<\/p>\n\n<!-- Facebook Like Button v1.9.6 BEGIN [http:\/\/blog.bottomlessinc.com] -->\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=http%3A%2F%2Finspiredtoeducate.net%2Finspiredtoeducate%2Fsonic-pi-sound-synth-application-for-learning-coding-and-music%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px; height: 30px; align: left; margin: 2px 0px 2px 0px\"><\/iframe>\n<!-- Facebook Like Button END -->\n","protected":false},"excerpt":{"rendered":"<p>I love it when I find a tool that combines my two favorite hobbies: music and computers. A gifted programmer named Sam Aaron has created an engaging tool for teaching music and code to makers young and old entitled Sonic-Pi. The tool delightfully blends an introduction to Ruby programming and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,24,16,23,11,8,1],"tags":[],"_links":{"self":[{"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/posts\/1760"}],"collection":[{"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/comments?post=1760"}],"version-history":[{"count":3,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/posts\/1760\/revisions"}],"predecessor-version":[{"id":1764,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/posts\/1760\/revisions\/1764"}],"wp:attachment":[{"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/media?parent=1760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/categories?post=1760"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/inspiredtoeducate.net\/inspiredtoeducate\/wp-json\/wp\/v2\/tags?post=1760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}