There was a stray } in the code above, but if you change it to this and evaluate using Ctrl+Y:
| masterclock position switches voicestealing durations |
masterclock := !Run bpm: (!BPM * 4).
position := masterclock nextIndexMod: 16 reset: !Reset.
switches := 1 to: 16 collect: [ :n | !sw suffix2: n].
voicestealing := (masterclock durationBetweenTriggers s) tick.
durations := 1 to: 16 collect: [:i | !length suffix2: i].
(position of: switches) * voicestealing stayOnFor: durations
The result is the expression:
(((!Run bpm: !BPM * 4) nextIndexMod: 16 reset: !Reset) of: #( !sw01 !sw02 !sw03 !sw04 !sw05 !sw06 !sw07 !sw08 !sw09 !sw10 !sw11 !sw12 !sw13 !sw14 !sw15 !sw16 )) * (!Run bpm: !BPM * 4) durationBetweenTriggers s tick stayOnFor: #( !Length01 !Length02 !Length03 !Length04 !Length05 !Length06 !Length07 !Length08 !Length09 !Length10 !Length11 !Length12 !Length13 !Length14 !Length15 !Length16 )
so you are using an Array #( !Length01 etc..) as the argument to stayOnFor: which expects a scalar value in seconds. To fix this, you could index the lengths Array using the same master clock you are using everywhere else, for example:
(((!Run bpm: !BPM * 4) nextIndexMod: 16 reset: !Reset) of: #( !Length01 !Length02 !Length03 !Length04 !Length05 !Length06 !Length07 !Length08 !Length09 !Length10 !Length11 !Length12 !Length13 !Length14 !Length15 !Length16 ))
which you could do by modifying the last line of your code to:
(position of: switches) * voicestealing stayOnFor: (position of: durations)