Sonic Pi is a live-coding music program that uses Ruby to generate synth music. Ever since I learned about Algorave earlier this year, I've been really interested in trying out generating music with code, and Sonic Pi seemed like a great place to start.
Sonic Pi is free and open-source, and available for Windows, macOS, and Raspberry Pi. It has a fantastic built-in tutorial that had me writing music right away, and I was really pleased with the quality of the tutorial. I already know Ruby and some intermediate music theory, but it doesn't assume any prior programming or music knowledge.
In about two hours or so, I completed the tutorial and whipped together some rad synth sounds to have on in the background while I code. Check it out on Soundcloud, the code is below!
live_loop :background do
sample :loop_garzul
use_synth :prophet
play :c1, release: 4, cutoff: rrand(70, 130)
sleep 4
play :c2, release: 4, cutoff: rrand(70, 130)
end
live_loop :middle do
sync :background
use_random_seed 4923
use_synth :tb303
notes = (scale :c2, :minor_pentatonic, num_octaves: 1)
sleep 4
8.times do
play notes.choose, release: 1, cutoff: rrand(30, 50), amp: 0.3
sleep 0.5
end
sleep 4
8.times do
play notes.choose, release: 1, cutoff: rrand(30, 50), amp: 0.3
sleep 0.5
end
end
There's a pretty active Sonic Pi Twitter account that shares recent creations (some of which can fit in a single tweet!) as well as a forum which I haven't explored much. Have you used Sonic Pi or something else to generate music? Let me know in the comments!
Top comments (16)
Sonic Pi is one of the coolest things. I wish I had any musical talent. 😳
Oh my God you hooked me into sonic-pi!
Sonic Pi made it so much more easier for music programming. Languages like Csound and supercollider are really good. But have a big learning curve. Sonic Pi is a very fun, great to help people understand programming basics as well.
That is so cool!! Gj :)
It's awesome. Thanks Fen for introduce to us.
I made this site so people can collaboratively code sonic-pi online makemusiconline.net:8080
This is really cool! Thanks for sharing! :D
This is so cool. Thanks for writing about this.
oh my!! I love this.
I can't miss experimenting with this. Thanks for pointing out!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.