Can I make a kick drum loop in Sonic Pi, and set it as a variable using kick_loop =
[drum loop] ? So every time I do sample kick_loop
it plays the entire loop?
TIA
Can I make a kick drum loop in Sonic Pi, and set it as a variable using kick_loop =
[drum loop] ? So every time I do sample kick_loop
it plays the entire loop?
TIA
Hi
you should look at the cue system in the doc
cue
is a good option.
It’s fine to use variables to stand in for symbols (things that begin with :
) e.g.
my_sample = :loop_amen
sample my_sample
If you wanted to condense the whole thing down a bit you can also try using a function:
# define here is Sonic Pi specific and the recommended way for functions
# def ... is the Ruby way but that isn't guaranteed to work in future versions
define :my_sample do
sample :loop_amen
end
my_sample # plays the sample
Technically though, you can use a lambda for this too:
my_sample = lambda { sample :loop_amen }
&my_sample # should work
my_sample.call # should work
my_sample() # should work I think
Hope those help. If not, let me know some more details and we can figure out what will work best for you.