The function fix conditionally applies a function to a pattern, eg fix f e p applies function f to any events in pattern p that match those in pattern e (I think).
Is there a version of this that compares e to a pattern other than p, eg a function fixWhen f e q p that applies f to events in p whenever events in e match those in q? Or can this be composed from existing functions?
I have been looking at how to get patterns to interact with each other (like here) and thought a function like this might be a good general-purpose way to do it? For example something like this would silence the arpy whenever the snare sounds:
let p1 = s "~ sn ~ sn"
let p2 = n "0 1 2 3 4 5 6" # sound "arpy"
d1 $ stack [
p1,
fixWhen (# silence) (s "sn") p1 $ p2
]
If this doesn't exist, does it seem feasible to write it? (Been a few years since I wrote any Haskell). Or is there a better way to do this with existing functions?
This is an interesting question but unfortunately I'm not versed enough in Tidal innards and Haskell to answer it completely.
Looking at the source code of contrast, I see that it is a particularization (?) of contrastBy, which does not test for equality but rather uses an arbitrary boolean function. Maybe by feeding it a carefully crafted function you could get it to test on another pattern?