Sonic Pi is easily one of my favorite Ruby-related projects. It's a live musical coding environment where anyone (not just Rubyists) can write code to create music live, including doing live DJ sets. Sam's talk at GOTO 2018 demonstrated the concept well.
With a new Sonic Pi release out this week, I wanted to take the opportunity to catch up with Sam and ask him a few questions about how the project is going:
What inspired you to start the Sonic Pi project almost ten years ago?
I had already been working on live coding music systems (primarily Overtone) for a number of years. I was working as a researcher at the University of Cambridge Computer Laboratory the same year the Raspberry Pi computer was launched. My grant had run out, and I was about to return to being a professional programmer when a small budget was available for a 3-month project to build a prototype system that could help children engage in the new UK CS curriculum. I proposed to build a simplified version of Overtone and got the project: Sonic Pi was born.
You've mentioned that parts of Sonic Pi are being rewritten in Erlang. What prompted this change and will it make any difference to Rubyists enjoying Sonic Pi so far?
Erlang has been part of Sonic Pi for many years now as our well-timed MIDI and network message (OSC) scheduler was written in it originally by the late Joe Armstrong - one of Erlang’s co-creators. An important aspect of Erlang is that it runs on a VM called the BEAM which is built for soft realtime systems with high concurrency, low latency and low jitter. This is precisely what a live music system needs. We are therefore moving more of the critical IO parts of the app into Erlang to benefit from the BEAM’s amazing performance. It turns out that Erlang also has a very similar threading model to Sonic Pi’s so it also makes sense to eventually move much of that to the BEAM which has been much more battle-tested than my Ruby code.
With respect to Rubyists enjoying Sonic Pi - it’s important to point out that whilst Sonic Pi is built on top of Ruby as a DSL, it isn’t Ruby and we don’t support much of Ruby’s behaviour. We also want to have the opportunity to move the DSL to another host language should that prove to be a good engineering choice in the future.
What's the most unusual sort of composition you've seen someone pull off with Sonic Pi?
I’ve seen people re-create entire classical works, compose their own operas, make extremely heavy metal music and also beautiful ambient pieces with Sonic Pi. However, the most unusual composition was by an amazing educational group from Finland who used it to code an entire mechanical orchestra of well-timed robots playing symbols, drums and other percussion to accompany some nice synth riffs. It was huge fun to watch.
Other than using Sonic Pi, is there any way Rubyists can help out?
I think the best way people can help out is to play with it, have fun and use it to share the joy of creative code with everyone they know - especially those that don’t yet code. I’d also recommend people join our friendly community.
Techno or drum'n'bass?
For coding, techno — for dancing, DnB.