I'm creating a kind of sequencer that's relatively simple but with an interesting behaviour - it transposes itself over time in ever increasing length cycles. I'm calling it a "fractal sequencer".
Think of a four step sequencer. Once it completes a cycle, it spawns an outer cycle running at a quarter of the speed which transposes the original values. Once the outer cycle completes it spawns a further outer cycle that runs at a quarter of the speed again which transposes the inner two cycles... and so on and so on ad infinitum... or until you run out of processing power.
This algorithm was relatively easy to write in python using a while loop:
values = [-2, 7, -3, 0] #the values of the four sequence steps
bpm = 600
seqlen = len(values)
scale = 2.0 ** (1/12.0)
middleC = 261.63
note0 = middleC / 32.0
value_range = 12 #A range limit so values don't run off to infinity
i = 0
while True:
positions = []
d, r = divmod(i, seqlen)
positions.append(r)
while d > 0:
d, r = divmod((d-1), seqlen)
positions.append(r)
value = 0
value_list = []
for pos in positions:
value = value + values[pos]
value_list.append(values[pos])
value = ((value + value_range) % (value_range * 2)) - value_range
beep(value + 60)
i += 1
It's not the most efficient algorithm. It maintains state solely by keeping a count of the current beat, which increments ad infinitum. It uses a while loop and mod function to work out how many outer loops to create and what step they would be on, then adds all the values together from all the loops to get the output value.
I can't see how to implement this in kyma / capytalk without using a FOR or WHILE loop and appending values to a list. Can you do that in capytalk? I want to do this in real-time, that is capytalk rather than smalltalk, because I want to be able to manually change the sequencer values while it's running.