Skip to content

10/01/2016 – Session Five #Sonic Pi

It has been a few days since I last wrote. I want to write every day but I am usually non-stop doing something so 4/5 days out of 7 is probably more realistic. In this case i’ve been trying to rest by spending less time on the computer before starting work on Monday. Some of this time has been pure self indulgence; hitting the sales and getting my eyebrows done whilst Beyonce is pumped out in the background type thing. I have also had the luxury of time to do a lot more guitar practice and I have been doing some Sonic Pi practice here and there but I didn’t get as far as recording it or writing anything…

In my last post I experimented with threads. I got some feedback on Twitter from Sam Aaron who is the creator of Sonic Pi which was that in_thread is best used when you want to run a block of code in a live_loop but don’t want its duration to affect the beat. I had sort of tried to use in_thread in place of live_loop just to get an idea of how threads work but this isn’t really what in_thread is meant for at all. Sonic Pi will overload if you try and use too many in_threads. Mine just about worked as it was a very small program with very few in_threads. Good to know, so I took Sam’s advice and had a look at the at function.

Figuring out what the inbuilt Sonic Pi functions do is simple, you can click on the ‘Lang’ tab in the navigation for the help menu and you will see a list of what is available with explanations and code examples.

 

Snip20160107_27

 

So this is an example Sonic Pi gives:

at [1, 2, 3], [75, 76, 77] do |n|
play n
end

(I need to figure out how to indent on WordPress…)

This will play the notes specified in the second array or arguments after 1, 2 and then 3 beats.

Snip20160110_28

The explanation for at tells us that “If the block is given 1 arg, the times are fed through. If the block is given 2 args, both the times and the params are fed through. A third block arg will receive the index of the time.”

I decided to make a short piece from scratch to experiment with making music using at and the different ways that it handles arguments. To begin with I made an industrial/ambient generative piece which just uses loop as opposed to live_loop.

code

Problem with this is you start to get a bit sick of the original sounds after a while as they continue throughout. I could have used the times method instead of loop if I wanted parts to play for a certain duration aka:

at 8 do
3.times do
sample :bass_dnb_f, beat_stretch: 1
sleep 4
end
end

I then changed loop to live_loop and tried making the piece into something a bit more live coded (kind of cheating but hey) by changing some fx and parameters as the piece progressed.