home/ atoms/ tidal-fix-contrast-event-matching

TidalCycles fix and contrast apply transforms only to events matching a ControlPattern test, leaving others unchanged

fix f test p applies function f only to events in control pattern p that match the test ControlPattern. fix (# crush 3) (n "[1,4]") p adds bitcrushing only to events where n is 1 or 4. unfix is the inverse — applies only to non-matching events. contrast f g test p is the two-branch form: apply f to matching events and g to non-matching ones. Example: contrast (|+ n 12) (|- n 12) (n "c") shifts middle-C events up an octave and all others down. contrastBy generalises further, accepting any boolean comparison function (e.g., >= for range tests). These functions enable event-level conditional logic rather than cycle-level.

Examples

d1 $ slow 2 $ fix (# crush 3) (n "[1,4]") $ n "0 1 2 3 4 5 6" # sound "arpy"
d1 $ contrast (|+ n 12) (|- n 12) (n "c") $ n (run 4) # s "superpiano"

Assessment

Explain the difference between fix and every. Write a fix expression that adds reverb only to snare events in a drum pattern. What does contrastBy (>=) (|+ n 12) (|- n 12) (n "2") do differently from the basic contrast version?

“The `fix` function applies another function to matching events in a pattern of controls. `fix` is `contrast` where the false-branching function is set to the identity `id`.”
corpus · tidalcycles-conditions-reference-every-whenmod-mask-euclidin · chunk 1