I’m trying to figure out how to load a Ruby gem for use within a Sonic Pi buffer. Has anyone tried doing this?
I found this related thread from 2015: https://groups.google.com/forum/#!msg/sonic-pi/QgX82sXcHqY/wNpxGLhggmUJ
I’m interested to hear your thoughts on that discussion. Here are mine: I get that Sonic Pi != Ruby, but I love that I can use plain old Ruby objects in Sonic Pi and it’d be really cool to know how to package them up and share them. Ruby gems come to mind.
One of the projects I’m working on uses a genetic algorithm to “evolve” music. I published a gem for working with genetic algorithms and have been using it alongside the sonic-pi-cli Ruby gem. I’m getting some pretty cool results and would like to be able to load “population” objects from the gem within a Sonic Pi buffer and live code with them.
If there’s no support for loading Ruby gems into the Sonic Pi buffer environment, I suppose I can put all my code in one file and require it - I’m pretty sure this would work. Then to share, I guess i could create a rake task to do it, so for anyone to use it they’d have to do something like the following:
gem install evolvable; rake compile_sonic_pi_file
but ideally I could skip the rake command and just do something like this in the Sonic Pi buffer: