Sonic Pi and Play

Bottom-line: You aren't restricted to whole numbers when it comes to the play command; the microtones possible can yield some really fun results.

---------------------------------------

Hello hello!

The first thing you learn when starting Sonic Pi is the play command.

I won't rehash the tutorial, if you aren't familiar with play check it out - it's solid. What I wanted to write about today was something I noticed when writing a post about chords

When playing notes, you can provide the name of the note or the number that corresponds to that key on the keyboard. 60 is C, for example. What's 61? D? Nah, C#/D♭.

62 is D.  

And that makes sense cause you're just moving up the keys on the keyboard. 

But then it got me thinkin'....what about 60.5? Boom. It works.

And this makes total sense too. After all, Sonic Pi is a programming language and why wouldn't it allow you to use all sorts of numbers for inputs? We can use 0.25 as a valid sleep value, right?

-------------------------------------

So what can we do with this?

You can generate some fun effects like:

note = 60

50.times do
  note += 0.1
  play note, attack: 0.1
  sleep 0.1
end

This will start off at C and then added a 0.1 to the pitch for each iteration of the loop. I added the attack modifier to smooth the sound a little. Maybe you could use that for something of a drone:

note = 40

live_loop :increase do
  50.times do                         #loop 50 times
    note += 0.1                       #each loop increase the pitch by 0.1
    play note, attack: 0.1, amp: 0.5  #play that new note
    sleep 0.1                         
  end
  note = 40                           #at the end of the looping, reset to 40
end

sleep 3
live_loop :amen do
  sample :loop_amen
  sleep sample_duration(:loop_amen)
end

This sliding effect can be also be accomplished with the control but, to do that you have to assign a synth sound to a variable. You don't have to assign the synth to a variable in the case above. Although, in this example, you're assigning the note to a variable so, ultimately, you aren't really saving anything. It could look something like this:

live_loop :increase do
  s = play 40, release: 5, attack: 0.1, note_slide: 5
  control s, note: 45
  sleep 5
end

sleep 3
live_loop :amen do
  sample :loop_amen
  sleep sample_duration(:loop_amen)
end

The major sound difference between the two, to me, is that the first example sounds harsher and more aggressive. I suspect because you have notes overlapping whereas, in the second example, it's a single note. 

Music Theory wise, I'm not totally sure. I know that there are microtonal systems of music like Indian Classical Music which could be helpful. But, man, I'm not well versed with European music theory, let alone Indian.

Either way though, it's a fun reminder of the power of Sonic Pi and the flexibility one has available to them. 

What do you think? Can you think of a particularly useful application of the microtones? Let me know in the comments!

Thanks for reading!

Comments

Popular posts from this blog

Very Sus chords in Sonic Pi

Rolling High Hat Trick with Sonic_Pi