home/ atoms/ strudel-lastof-firstof-periodic-transform

lastOf and firstOf apply a transform on one specific cycle out of every n

lastOf(n, fn) applies the function fn to the pattern on the last cycle of every n-cycle group and passes it through unchanged otherwise; firstOf(n, fn) applies it on the first cycle instead. (The common every(n, fn) is the widely-used shorthand for this firstOf-style periodic transform.) These are the primary mechanism for regular variation — periodic fills, sweeps, reverses — without maintaining a cycle counter, and they compose: two such calls with different periods each fire independently on their own cycles.

Examples

s(“bd sd hh cp”).lastOf(4, x => x.fast(2)) // double-time on cycle 4 of every 4 s(“bd*4”).firstOf(4, x => x.jux(rev)) // reverse-in-one-channel on cycle 1 of every 4

Assessment

Layer lastOf(8, rev) and firstOf(4, fast(2)) on a hihat pattern and describe what happens on cycles 1, 4, and 8.

“Applies the given function every n cycles, starting from the last cycle.”