Coding Music

In the last 2 months, I learned a lot of coding by attending Flatiron School and using different online resources. Started from learning to assign variables to developing web applications with Rails. Of the many ways to learn coding, I really enjoyed using Sonic Pi. Using this application you can learn the fundamentals of programming while composing music.

Sonic Pi
”Sonic Pi is an open-source programming environment developed by Dr Sam Aaron, designed to explore and teach programming concepts through the process of creating new sounds.”
http://sonic-pi.net/

These are examples of codes in Sonic Pi and Ruby.

Codes written in Sonic Pi looks a lot like Ruby. 
In the first line of both examples, I am adding in a library.
On the third line, I am defining a new function that takes in multiple parameters. The block within the function will use the parameters and do something with it.
They can both use conditionals, loops, arrays, and funcitons

Running Sonic Pi code above should sound like the beginning of Shape of You by Ed Sheeran.

Here is a quick tutorial to create a simple drum beat.

Lets start by choosing an instrument or a sound.
In the example below, I clicked Drum Sounds from Samples. On the right, it will show you all the sounds available with this instrument. Copy and paste a line from this set and paste it into the interpreter.

I chose heavy_kick, cymbal_closed, snare_hard, and cymbal_closed. I also had to put a sleep 0.25 between each line t0 let the interpreter know to wait before playing the next drum sound. Then wrap it in a loop do statement to run the beat indefinitely. Click play on the top and it will start your code.

Sonic Pi is a fun way to learn the fundamentals of programming while making music.

Like what you read? Give hui wang a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.