fix package:tidal-core

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. It is like contrast, but one function is given and applied to events with matching controls. For example, the following only adds the crush control when the n control is set to either 1 or 4:
d1 $ slow 2
$ fix (# crush 3) (n "[1,4]")
$ n "0 1 2 3 4 5 6"
# sound "arpy"
You can be quite specific; for example, the following applies the function hurry 2 to sample 1 of the drum sample set, and leaves the rest as they are:
fix (hurry 2) (s "drum" # n "1")
The fixRange function isn’t very user-friendly at the moment, but you can create a fix variant with a range condition. Any value of a ControlPattern wich matches the values will apply the passed function.
d1 $ ( fixRange ( (# distort 1) . (# gain 0.8) )
( pure $ Map.singleton "note" ((VN 0, VN 7)) )
)
$ s "superpiano"
<| note "1 12 7 11"
Like contrast, but one function is given, and applied to events with controls which don't match. unfix is fix but only applies when the testing pattern is not a match.