i have seven simple rhythms, like this:
rtm_1:i[] = [1/4,1]
rtm_2:i[] = [1/4,1/4,1]
rtm_3:i[] = [1/2,1,1/4,1]
rtm_4:i[] = [2/3,1/4,1]
rtm_5:i[] = [1/4,1,1]
rtm_6:i[] = [1,1/4,1]
rtm_7:i[] = [1,1]
i want to get one of the elements randomly (again and again for an instrument call).
if we had lists in csound 7, i could put these arrays in a list and then take a random element:
all_rtms:i[] = [rtm_1,rtm_2,rtm_3,rtm_4,rtm_5,rtm_6,rtm_7]
as we don't have lists yet, what would be the best approach?
Hi Joachim,
tables of rhythms and an array with table numbers is a good one or, if you have one trigger instrument, send table numbers through specific channels. Or you could create a longer table or array with a good internal structure, so you could pass along starting indices. Perhaps indicate how many elements your rhythm has or determine a maximum length and fill empty spots with symbolic values like 0 or -1. Perhaps you could use a UDO to convert this more complex structure to a simple array inside your playing instruments, so you can go through the more awkward logic only once in i-time per instrument event.
Personally, I would not use 2D arrays, since I seem to recall some issues with certain situations.
As a last thought: I remember some Csound genius using a kind of dynamic code generation. I think it was cslc, a library supporting all kinds of live-coding: