Q

Home » Work » Sonic PI

Sonic PI

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 45 other followers

For anyone who knows me well, you probably know I was a Glee kid in high school.

I had a hard time pacing my breathing so I couldn’t run worth squat. I hated getting hit so football and sports like that were decidedly not for me. And while I tried wrestling one year, I learned very quickly that other than sexually, I am just not a physical guy.

Oh I loved dodge ball. Which I was actually pretty good at.

But that was the type of thing in high school that the PE coaches would reserve for days they couldn’t think of anything else to do.

So for most of high school, I was decidedly not cool.

At my school anyways.

When I hit 16, outside of my school, I had quickly gained the reputation as a partier, but the people from my school never really did mix it up with other schools so this reputation never really threatened by nerd image at Cactus High School where I was known as the geeky glee kid.

One time, as if to ‘test out’ the waters of geekdom, I remember the football type jocks from my school registering for a concert choir.

My teacher, Ms Peggy Shively, was absolutely thrilled.

Her choir, which in my opinion was pretty darn good was getting the attention it deserved and might establish itself a better reputation.

They didn’t last three weeks. It’s not that they had bad voices or anything. It’s that it required effort and training and patience to learn to read music, it required synchronized teamwork and timing unlike anything they’d been presented with on a football field. It required keen awareness of timing and pacing.

But most of all. It required that they keep their pride and individualism in check just long enough to participate as an individual in a group rather than just be part of a group.

In any case.

I was proud of them for trying. Absolutely proud of them. They’d made an effort to try something outside their own comfort zones which caused them each ridicule over the next year by their peers, ridicule which I had been used to, but also ridicule which placed me firmly on friend terms with a few of the guys who made the effort.

I often wondered – I had tried wrestling only six months before and started lifting weights at the same time. Were they trying out choir as an act of respect to me?

It doesn’t matter.

I enjoyed singing.

But I had a HUGE problem with appearing in front of crowds.

I have spent a great deal of my life avoiding appearing in front of an audience. And this, ultimately, is what broke down my singing career.

I’d actually ‘dreamed’ of becoming a ‘rock star’ when I was 14. I’d had a chance to sing for a band when I was 15, but blew it, freezing up on the microphone.

And the day of a solo in front of an audience for choir, I fell tremendously ill and someone else did the solo instead.

I can’t tell you where my insecurities came from, I had so many, but this one in particular – public speaking – has plagued me my entire life.

For my MBA at Thunderbird, I quite literally had no memory of the speeches I gave mere seconds after I gave them. I know another part of me who could give those speeches spoke for me, because the confidence I lacked and profuse sweating and nervousness would systematically be supplanted by everyone telling me what a great job I had done afterwards.

All this aside.

I had never stopped loving music.

I had taken up guitar when I was 16. That’s when I learned to play chords, and in the process found a wonderful new way to annoy my parents.

I was a huge fan of the ‘hair bands’ who – while they didn’t have a great deal of talent – they had amazingly fun songs. Bands such as Poison, Twisted Sister, and Motley Crue had songs I would frequently try to recreate with my limited training and skills.

But when I measured myself against the entertainers I was in true awe of: Whether that was Eddie Van Halen , Aerosmith, Dio, and AC/DC, I knew I could never measure up against that ‘raw’ kind of talent. They had something I myself never thought was possible in myself.

So I bowed out of music altogether.

And shifted into a role as a programmer.

I have since realized anyone can have that raw talent.

But not everyone chooses to make music in the ways those who walked before them chose to with that talent which can be applied to anything imaginable.

So three days ago, I was in a conversation with a friend of a friend who’s on the verge of getting a job with Insomnia entertainment – the makers of the amazing game series for the Playstation 3 series called “Ratchet and Clank”. They bend time in their games in ways most people do not understand and I love it!

No matter – this guy is a novice at C++, so I have been helping him out – not too much – in an intense programming test he has to take for the position.

I told him WHEN he gets in. I’m putting out some positive energy to the universe. WHEN he gets in. Then recommend me as a QA guy and since you know I have no desire to program but have that background, I’ll be easier to work with than your typical QA people who have no clue about what you’re doing.

I also told him ”Don’t get me wrong, I won’t be easy on you and will do things you never expected which may drive you insane, but I can guarantee you we’ll test it out and make the final product something we both enjoy and we’ll kick butt.”

I sincerely hope he gets the job. I have actually applied for this company once, but like any company I suspect an in helps.

In the course of the conversation, he told me about some of the sound/audio work he had done in the past, and while I had experience with most of the programs he had discussed, Audacity being a personal favorite for editing sound files (available here), he mentioned something called Sonic PI.

I had never heard of Sonic PI before.

And like most things in conversations where people mention something new I hadn’t heard about lately, I dismissed it.

The next day, I was browsing my tube (youtube), and came across a wonderful version of Daft Punk’s Aerodynamic made with Sonic PI.

I come from a coding background. I pretty easily shift in between any programming language now, and can say solidly I know about 30 languages but can pick a new one up as quickly as most people can change a tire.

Which helps. Sonic PI is a language for sound.

And it’s AWESOME!

Here’s a small snippet of Sonic PI code I created:

loop do
  sample :guit_em9, amp:2, pitch: -2
  sleep 3
  sample :guit_em9, amp:2, pitch: 0
  sleep 3
  sample :guit_em9, amp:2, pitch: 2
  sleep 2.5

  use_synth :prophet
  loop do
    [1, 3, 6, 4, 2, 5, 1, 3].each do |d|
      (range -3, 3).each do |i|
        play_chord (chord_degree d, :c, :major, 3, invert: i)
        sleep 0.25
      end
    end
  end
end

Here’s a link to the output of this sample/test I created on Soundcloud.

What’s wonderful about this thing – Sonic PI – is. It’s a language for creating audio for coders.

So yesterday I sifted through all the samples, and came across “Bach Minuet in G” coded by Robin Newman.

It’s more or less transcription of the sheet music, which he did a great job with, but it comes across sounding… hollow, and cutesy, kinda like an old school 8 bit Nintendo video game. Here’s a link to the song Sonic PI produced BEFORE I made changes to it so you can hear the difference between my version and their version, on Soundcloud.

The changes I made were small. I changed the primary instrument to a piano. I added a concert hall echo to the tone, and I added in a few sustain changes to simulate the pressing of piano keys on a baby grand piano. Oh yeah, that and I slowed the pace down slightly to 57 beats per minute from 60 to give it a more natural feel to it.

The effects and changes, if I must say so myself, are pretty amazing. It goes from feeling like I’m playing a video game to feeling like I am in a concert hall and watching someone on a stage in an auditorium with a grand piano.

Here’s the link to my modified version of the song, AFTER I made changes to it here on Soundcloud.

I’m going to experiment with Sonic PI for a bit with some music I create. This is fun, in such entirely geeky ways and doesn’t require me to have to have the dexterity I never really had to play an instrument with any kind of virtuosity.

Instead it’s me and my thoughts and an attempt to commit them to code. GEEK FUN!

You can download Sonic PI here if you have any desire to learn to code with Sonic PI yourself.

Here’s the code for my version of Bach’s Minuet in G, which inherits almost all of it from the original Coded by Robin Newman.

Thanks, Robin!

use_bpm 57
use_synth_defaults release: 3.0, amp: 1.7, cutoff: 30, decay: 0.4, sustain:4, attack_level:0.8

in_thread do
  with_fx :reverb, room: 0.5 do
    use_synth :piano

    ## Each section of the minuet is repeated
    2.times do

      ## First start a thread for the first 8 bars of the bass left hand part
      in_thread do
        play_chord [55,59]#b1
        sleep 1
        play_pattern_timed [57],[0.5]
        play_pattern_timed [59],[1.5] #b2
        play_pattern_timed [60],[1.5] #b3
        play_pattern_timed [59],[1.5] #b4
        play_pattern_timed [57],[1.5] #b5
        play_pattern_timed [55],[1.5] #b6
        play_pattern_timed [62,59,55],[0.5] #b7
        play_pattern_timed [62],[0.5] #b8
        play_pattern_timed [50,60,59,57],[0.25]
      end

      ## Play concurrently the first 8 bars of the right hand part
      play_pattern_timed [74],[0.5]#b1
      play_pattern_timed [67,69,71,72],[0.25]
      play_pattern_timed [74,67,67],[0.5]#b2
      play_pattern_timed [76],[0.5]#b3
      play_pattern_timed [72,74,76,78],[0.25]
      play_pattern_timed [79,67,67],[0.5]#b4
      play_pattern_timed [72],[0.5] #b5
      play_pattern_timed [74,72,71,69],[0.25]
      play_pattern_timed [71],[0.5] #b6
      play_pattern_timed [72,71,69,67],[0.25]
      play_pattern_timed [66],[0.5] #b7
      play_pattern_timed [67,69,71,67],[0.25]
      play_pattern_timed [71,69],[0.5,1] #b8

      ## Start a new thread for bars 9-16 of the left hand part
      in_thread do
        play_chord [55,59]#b9=b1
        sleep 1
        play 57
        sleep 0.5
        play_pattern_timed [55,59,55],[0.5] #b10
        play_pattern_timed [60],[1.5] #b11=b3
        play_pattern_timed [59,60,59,57,5],[0.5,0.25,0.25,0.25,0.25] #b12=b4]
        play_pattern_timed [57,54],[1,0.5] #b13
        play_pattern_timed [55,59],[1,0.5] #b14
        play_pattern_timed [60,62,50],[0.5] #b15
        play_pattern_timed [55,43],[1,0.5] #b16
      end

      ## Play concurrently bars 9-16 of the right hand part the first six
      ## bars repeat bars 1-6
      play_pattern_timed [74],[0.5]#b9 = b1
      play_pattern_timed [67,69,71,72],[0.25]
      play_pattern_timed [74,67,67],[0.5]#b10=b2
      play_pattern_timed [76],[0.5]#b11=b3
      play_pattern_timed [72,74,76,78],[0.25]
      play_pattern_timed [79,67,67],[0.5]#b12=b4
      play_pattern_timed [72],[0.5] #b13=b5
      play_pattern_timed [74,72,71,69],[0.25]
      play_pattern_timed [71],[0.5] #b14=b6
      play_pattern_timed [72,71,69,67],[0.25]
      play_pattern_timed [69],[0.5] #b15
      play_pattern_timed [71,69,67,66],[0.25]
      play_pattern_timed [67],[1.5] #b16
    end


    ## ==========second section starts here======
    ## The second section is also repeated
    2.times do

      ## Start a thread for bars 17-24 of the left hand part
      in_thread do
        play_pattern_timed [55],[1.5] #b17
        play_pattern_timed [54],[1.5] #b18
        play_pattern_timed [52,54,52],[0.5] #b19
        play_pattern_timed [57,45],[1,0.5] #b20
        play_pattern_timed [57],[1.5] #b21
        play_pattern_timed [59,62,61],[0.5] #b22
        play_pattern_timed [62,54,57],[0.5] #b23
        play_pattern_timed [62,50,60],[0.5] #b24
      end

      ## Play bars 17 to 24 of the right hand concurrently with the left
      ## hand thread
      play_pattern_timed [83],[0.5] #b17
      play_pattern_timed [79,81,83,79],[0.25]
      play_pattern_timed [81],[0.5] #b18
      play_pattern_timed [74,76,78,74],[0.25]
      play_pattern_timed [79],[0.5] #b19
      play_pattern_timed [76,78,79,74],[0.25]
      play_pattern_timed [73,71,73,69],[0.5,0.25,0.25,0.5] #b20
      play_pattern_timed [69,71,73,74,76,78],[0.25] #b21
      play_pattern_timed [79,78,76],[0.5] #b22
      play_pattern_timed [78,69,73],[0.5] #b23
      play 74 #b24
      sleep 1.5

      ## Start a new thread for bars 25-32 of the left hand part
      in_thread do
        play_pattern_timed [59,62,59],[0.5] #b25
        play_pattern_timed [60,64,60],[0.5] #b26
        play_pattern_timed [59,57,55],[0.5] #b27
        play 62 #b28
        sleep 1.5 #includes a rest
        play_pattern_timed [50,54],[1,0.5] #b29
        play_pattern_timed [52,55,54],[0.5] #b30
        play_pattern_timed [55,47,50],[0.5] #b31
        play_pattern_timed [55,50,43],[0.5] #b32
      end

      ## Play bars 25-32 of the right hand part concurrently with the left
      ## hand thread
      play_pattern_timed [74,67,66,67],[0.5,0.25,0.25,0.5] #b25
      play_pattern_timed [76,67,66,67],[0.5,0.25,0.25,0.5] #b26
      play_pattern_timed [74,72,71],[0.5] #b27
      play_pattern_timed [69,67,66,67,69],[0.25,0.25,0.25,0.25,0.5] #b28
      play_pattern_timed [62,64,66,67,69,71],[0.25] #b29
      play_pattern_timed [72,71,69],[0.5] #b30
      play_pattern_timed [71,74,67,66],[0.25,0.25,0.5,0.5] #b31
      play_chord [67,59] #b32
      sleep 1.5
    end
  end
end

 

 

 

Enter your email address to follow this blog and receive notifications of new posts by email.