Sonic Pi activity

Yeah, yeah, I read the New York Times article (“Lesson of the Day: ‘That Music You’re Dancing To? It’s Code’”), and I was aware of Sonic Pi, but I’d never downloaded it and tried it out until yesterday, and I dug it right out of the box, so to speak. I was wondering what if anything folks here on Lines are doing with Sonic Pi, and a search suggested that there hasn’t been a dedicated thread to it, like there are for Lua and for Pure Data. So I started this one.


@samaaron great to see your name!


I started playing around with it a few months ago and was quite surprised with how much fun it was. Despite never having worked with Ruby I found it really easy to learn (and dead simple to install) and the results were definitely pleasing.

Here’s a relaxing little script that was still in one of my buffers. It only uses the included samples and synths so it should be usable anywhere:

set_mixer_control! amp: 0.95, limiter_bypass: 1

with_fx :reverb, room: 1.0, mix: 0.7 do
  live_loop :hello do
    play (scale :F3, :minor_pentatonic).choose, attack: 2.0, release: 0.9, amp: 0.5, pan: -0.3
    play (scale choose([:C4, :C5]), :minor_pentatonic).choose, attack: 2.0, release: 0.9, amp: 0.4 , pan: -0.4 if one_in(3)
    if one_in(4)
      sample :ambi_glass_rub, rate: choose([0.7, -0.7, 0.85])
    if one_in(5)
      play (scale choose([:F4, :F5]), :minor_pentatonic).tick, amp: 0.3
    in_thread do
      with_fx :echo, decay: 6.0, phase: 1.5, amp: 0.4 do
        use_synth :prophet
        if one_in(7)
          play_pattern_timed (scale choose([:F4, :F5, :C3]), :minor_pentatonic, num_octaves: choose([2,3])), choose([0.0625, 0.125]), amp: 0.5, cutoff: rrand_i(65, 85), cutoff_slide: 7.0
          sleep 0.25
    sleep choose([0.5, 1.0, 3.0, 5.0])

I don’t use Sonic Pi much lately…it piqued my curiosity in Tidal Cycles, and once I became comfortable with sending MIDI out from Tidal Cycles that was pretty much the end of my time with Sonic Pi.

That being said, if anyone were to express an interest in live coding to me, Sonic Pi is definitely the first thing I’d recommend they check out.


Sonic Pi is great, and that article has a couple of familiar names…and Hydra screenshots!

However - the bit that I’ve always really liked about SonicPi was its emphasis on curriculum. It made me think of logo the first time I saw it…sound turtles all the way down. The intersection of education and “generating art through code” makes a ton of sense imo - simple on ramp, near instant feedback, REPL like iterative coding…but then you can go deep…then you can go deeeeeper because it’s open source.

Seems like the perfect slippery slope to nerdsville.

If SonicPi ran on Glitch:mage::fish:

Oh! Don’t forget @samaaron made Overtone too! Hello!


That is exactly how I felt about it as well. So much so that the first person I showed it to was my 12 year old nephew who is interested in learning how to code.


That’s lovely. Thanks for having shared the script.

1 Like

shall we have a Pi Fight?

edit: I found the original tidal fights thread non-combative and inspiring, a little structure/prompting/deadline helps me a lot in giving time to things I might not otherwise, and given that @disquiet hosts the Junto I’m sure this isn’t an unfamiliar notion :upside_down_face:



I am working with Sonic Pi on a regular basis since quite a while.

  • Amongst other things I offer a course at Leuphana University (Germany/Lüneburg).
  • Here is a presentation at Sonoj 2018 (a small Open Source Audio conference at Germany/Cologne) with some live coding and and a talk in very bad English.
  • Finally I am trying to integrate my Grid with Sonic Pi and have started to code an application similar to mlr (I have never been able to try mlr out so I actually don’t know in detail what functions it offers). The code is alpha but I will release it as soon I’ll consider it beta.

I love Sonic Pi, and frequently recommend it as an introduction to livecoding or to programming. I also, as a Rubyist, really appreciate that it’s mainly Ruby.

Here, have some break slicing:

load_sample :loop_amen

live_loop :drums do |count|
  if (count+1) % 4 == 0
    # put a break in every four bars where you chop the break randomly
    # slices = (1..8).to_a.sort_by { rand }
    slices = []
    slices << 0 # always start with slice 1, for a nice kick
    7.times do
      slices << rand_i(1..7)
    slices = (1..8).to_a
  slices.each do |slice_int|
    sample :loop_amen, num_slices:8, slice: slice_int, amp: 5
    sleep sample_duration(:loop_amen) / 8
  count += 1

Yes, sample slicing is a thing which is very easily done with Sonic Pi. You can make it even shorter (accepting a slight variation):

live_loop :drums2 do
  3.times do
    sample :loop_amen, beat_stretch: 2
    sleep 2
  8.times do
    sample :loop_amen, beat_stretch: 2, num_slices: 8, slice: pick
    sleep 0.25

Yes, that code is shorter… but I’m quite attached to not entirely randomly slicing things; forcing downbeats is useful. Anyhow, I like the expressiveness of slicing in it, and how easy it is to play with algorithms for making breaks dynamically.

I also like the use of blocks for wrapping effects processing.


Exactly! Sonic-Pi was my gate of entry in electronic music making and computer music. I spent countless hours improvising with this piece of software and fell in love both with sound design and live-coding on the way. Nowadays, I have more mixed feelings towards this piece of software, something that feels like nostalgia of the golden-age of my encounter with live-coding. I’m supporting Sam Aaron on his Patreon, and I check very frequently, as a routine, if there is an hint at the release of the long awaited 3.2. I’m still unable to contribute technically to the project, even If I would like to.

I would like to give an highlight to some members of the community, who created very interesting sub-languages for Sonic-Pi :

— Amiika with Ziffers. A sub-language that is nowadays pretty much an alternative language living on the top of Sonic-Pi. Melodic generation / algorithmic music / short-hand notation of melodic patterns.
Petal by SiafLab, a defunct early-attempt at implementing a Tidal Cycles like rhythmic language in Sonic-Pi. Lots of fun, sometimes a bit impredictable. It is really sad to see that no update will ever be published, and that I don’t have a single clue about Ruby.
— The incoming Thor Magnusson - Sam Aaaron collaboration about implementing an Ixi Lang sub-language in Sonic Pi.

I would definitely recommend Sonic Pi as a gate of entry into electronic music or live-coding, but I would not advise it for the sole purpose of learning programming. This might be an unpopular opinion, but I feel like making music / time-related programming and designing / extending programs is a completely different thing. When I first began using Sonic-Pi, I was highly confident that it would help me to learn programming but I pretty much crashed into a wall as soon as I was confronted with the real thing (now feeling better…).

The pedagogical aspect of Sonic Pi is excellent, and the in-built tutorial is covering almost everything you have to know to start live-coding and have fun. My dream for Sonic Pi would be to consolidate this pedagogical aspect (I wrote a very long french tutorial about Sonic Pi) and to focus on end-users (skilled users, computer scientists and musicians) to offer them the capacity to extend and contribute to the project as soon as they have mastered the language.

Many thanks to Sam Aaron for keeping this project alive and for dedicating so many attention and hard work to the project.


it was certainly a huge honour to be mentioned in the NYT!


Checking in some time down the road, anyone aware of means for Sonic Pi to communicate with Eurorack? Thanks.

Well, maybe not exactly what you were looking for, but I am sequencing my 0-coast via midi using Sonic Pi. I did some experiments (very early state) inspired by Spiegel’s text Manipulation of Musical Pattens mentioned here.

As a side note: Was trying yesterday to clock Fates with Sonic Pi also via midi, but was not successful yet. Sonic Pi can send out midi clock information (which I confirmed with an Arturia Beatstep) but I tried different applications such as Fugu, Awake and Takt without success (but I am an absolute Norns/Fates beginner and might have something wrong).

The general reason is that I am very much interested to merge the live coding side with a) external sound sources (such as my 0-coast) and b) the generation of some musical material/sequences outside from Sonic Pi (= Fates) e. g. such as baselines in a meaningful way.


I only learned about this the other day (I actuallycould have sworn it was on here, but no sign of any replies anywhere so I guess it was a different board). Really enjoying it. Over the years I’ve spent at least a little time with CSound, Supercollide, Praxis Live, Max/MSP, Puredata, Bespoke, Reaktor, VVVV, Axoloti and Usine, including university courses in CSound and Max/MSP, plus some dabbling in C and C++, and none of them ever really clicked with me even though the underlying principles made sense.

So far this is hitting the perfect sweet spot between the efficiency and intuitiveness (for me, at least) of code and the more high-level approach and immediacy of something like Reaktor or Usine. I’m probably in the minority, but for me node based UIs like Max/MSP are cumbersome and slow to work with, but Supercollider and CSound and their relatives feel a bit too close to a low level programming language and I end up thinking more about the syntax than the actual music. It doesn’t have all the clutter and ambiguity of Max/MSP and its relatives, I can sit down with nothing and have something musically interesting in a matter of seconds and then get more low level as I need to instead of starting low level and building up to something musically useful like CSound/Supercollider, and it isn’t a resource hog like Usine and Reaktor (never mind Usine’s horrible licensing arrangement - I completely bailed on it when that changed back in 2013 or 14).

If I was going to make livecoding the main thing I did I’d probably go with Praxis Live, and if I was going to go with something primarily node based I’d use VVVV and focus more on video than music (or make better use of my Axoloti), but since I’m mainly an OTB hardware person and just need a way to integrate the stuff I like about programming into my hardware setup, without all the stuff I don’t like about it, this is looking to perfect so far. Especially sinc eI’m mainly planning to use it for generating and processing MIDI so it doesn’t really matter to me that its sound design potential is limited compared to full blown Supercollider.

Once I get a UART MIDI interface going on the Raspberry Pi 4 I’ll probably use the parts I still have from the standalone tracker I was making (turns out ReNoise is pretty unusable on even the biggest 11" touchscreen I could find, and with anything bigger than that I might as well save some money and use an old laptop) but this should be OK with just about any display. Even the little 3" display I use for R_E_C_U_R would be OK, although it wouldn’t be much fun. Too bad I returned the 11" one.

1 Like

There’s not much out there in the way of polyrhythmic and microtonal sequencing, so I made my own for the Sonic Pi platform. It’s all I’ve used to write music for the past year. I’ve posted some demos on Rumble.

1 Like