This is the first in what I hope is a series of posts explaining some of the directions and projects that I’ve tried with Sonic Pi in the past. It’s an attempt both to share my experiences (and mistakes) and to inspire those who want to pick up the baton if any of these ideas interest them. I have quite a backlog of ideas from my three years or so working with SP (ideas are cheap!).
A while ago I went crazy and tried to get Sonic Pi working inside a Docker container. The logic was that I wanted to work toward creating an online Sonic Pi bot that could “render” any code to an audio file. Docker made sense because it allows it to be sandboxed on a server and it would also “solve” the issue of complex server setups, especially where audio configuration was concerned.
Initially I had a big hairy Dockerfile which installs all the packages, configures SSH and audio and then builds SuperCollider and Sonic Pi from source e.g. https://github.com/xavriley/sonic-pi-docker/blob/master/Dockerfile#L5-L35 I got this working in virtualbox with audio, although this will probably fail now as you’d need to compile the Sonic Pi release from the time which was around 2 years ago.
All the pieces are there, I just need to do the hard work of turning this into a useful service. I’m thinking something that will look for gists https://gist.github.com tagged with #sonicpi or whatever, fetch these and render an audio file (say 1 minute by default) and then upload it to a service like https://clyp.it/ (which has gone premium since I last looked…)
Any comments or queries are welcome. Would this be a useful thing?
I don’t know if you remember but I met you a couple years back in Horsham - Tubular Bells etc.
Anyway I think what you are proposing would be great for Code Clubs if you could ‘render’ the Code from Trinket etc.
One of the problems with the Sonic Pi projects in Code Club is that it can’t be run in the browser like most the other projects can - event the Sense Hat now has an emulator.
If the kids could use Trinket and then ‘export to WAV’ etc I think you could be onto a winner.
I think its a great idea to quickly browse through online available sonic pi scripts and play them there and then. The online service may become a hub for compositions.
Also there can be some sort of a magnet link to send code in the gist from browser to the locally running sonic pi instance so that people may not need to render it on a remote server.
This site will take code, wrap in in record_start and record_stop statements and upload the resulting audio to S3 for further listening. There’s no database or anything to store submissions but building a website around this is the easy bit
Feels good to get this working after what was probably months of research on and off. It also opens the doors to other things like streaming audio and twitter bots. There’s a “todo” list for ideas on the README so I welcome contributions to that.
If anyone wants to use their webdev skills to help me polish this up and turn it into a community resource that would also be very welcome.
Oh, neat! This might be exactly what I’m looking for - I’m looking to play around with machine learning and Sonic Pi, and to that I figure I need to supply code and receive a sound file.
Do you know if this can render sound at faster than 1:1 speed?
It can’t render faster than 1:1 at the moment but you can run multiple instances of it fairly easily. That would give you some parallel processing at least.
SuperCollider (the underlying synth engine for SP) does allow for some non-realtime processing but it wouldn’t be compatible with the way that Sonic Pi sends timed messages.
It’s now a bit more stable and shows the code along with the rendered file. You still have to refresh the page manually for the results to show (takes around 30 seconds) but it should be basically usable. If anyone wants to use it to share examples etc. feel free to do so.
Yes there’s a limit of 30 seconds at the moment which is arbitrary. I don’t think I can detect when a piece stops naturally yet so I have to impose some kind of time limit for now. Should be possible to fix that in future though.