Just a bit of background information, I'm a Ruby developer, and familiar with Object Orientated techniques. I've also got a history of playing with code and music, a long-running hobby. I'm getting used to Sonic Pi, but I'm having some difficulty splitting my code out into classes.
Here's my code:
class Drummer
def kick
sample :bd_haus
end
def snare
with_fx :reverb do
sample :drum_snare_soft
end
end
end
drummer = Drummer.new
use_bpm 130
loop do
drummer.kick
sleep 1
drummer.snare
sleep 1
end
However, it doesn't appear that the Sonic Pi language is available to this module. I get this error:
Runtime Error: [Workspace 9, line 23] undefined method `sample' for #
I've had a look at the Sonic Pi repo and tried this line:
include SonicPi::Lang::Sound
It looks like something's still missing, there's a different error:
Runtime Error: [Workspace 9, line 21] undefined method `push' for nil:NilClass
Did you mean? @msg_queue
Is there any way I can get the methods within my self-defined classes to act like code in the workspace?