Five years later, but I’m looking at doing something similar. I would like to have a big file with a whole lot of functions that I can use to create live loops through specification of parameters, and then control them later on.
I didn’t know that it would be possible to start a live loop with a custom symbol in a function. I was hoping that the loops themselves would include some randomisation, but this could be done through a single random seed.
I attempted to create the loops as strings, and then use run_code to run them. While I’m nowhere near ready to write the real functions, I have this:
num_loops = 0
loops = []
descriptions = []
define :create do |seed1, seed2, samp, desc=""|
use_random_seed seed2;
pan = rrand( -1, 1 );
amp = rrand( 0.3, 0.5 );
loop = ":loop" + num_loops.to_s;
code = " live_loop " + loop + " do \n" +
" sync :timing\n " +
" use_random_seed " + seed1.to_s + "\n" +
" 16.times do \n" +
" sample " + samp.to_s + " if one_in(3)\n" +
" sleep 0.25 \n" +
" end \n" +
" end \n";
print code
loops[num_loops] = loop;
descriptions[num_loops] = desc;
run_code code;
num_loops = num_loops + 1;
end
define :stats do
num_loops.times do |i|
print loops[i] + " : " + descriptions[i];
end
end
use_bpm 127
live_loop :timer do
cue :timing
sleep 4
end
That creates the function, as well as setting up a synchronisation loop. I can then use another buffer to call the function to create loops, and print out stats on the current loops.
# create 8354, 5233, ":bd_haus", "Drum Beat"
create 2831, 3563, ":sn_dolf", "Snare Bit"
stats
I do want to be able to control the loops once they are created, and would probably have a third array storing ‘status’ and additional functions (and code in the loops) to allow loops to be paused and controlled in other ways.
If anyone has any comments on the best way to do this sort of thing, that would be appreciated.