The run function generates sequential integer patterns for automatically stepping through sample indices or pitch values
The run n function generates a pattern of integers from 0 to n-1, evenly distributed over one cycle. Combined with n (sample index) or up/speed, it automates sequential selection: d1 $ n (run 8) # s "arpy" plays arpy samples 0 through 7 in sequence. Combining with every and rev creates ascending/descending patterns. The run output is a standard pattern and accepts all pattern transformations: d1 $ sound "arpy*8" # up (every 2 (rev) $ run 8) alternates ascending and descending. Range notation [0 .. 7] is shorthand for run 8 sequences in numerical patterns.
Examples
// sequential samples:
d1 $ n (run 8) # s "arpy"
// alternating ascending/descending pitch:
d1 $ sound "arpy*8" # up (every 2 (rev) $ run 8)
// range shorthand:
d1 $ n "[0 .. 7]" # sound "supergong"
Assessment
Write a pattern that plays 5 samples from the ‘drum’ folder in order, then plays them in reverse on the next cycle, using run, every, and rev.