This is a part Tidal - part Haskell question. Having some issues wrapping my brain around ControlPatterns.
I can’t seem to find the syntax for recursively mapping an arithmetic function over all of the gain values (or all the values) in a ControlPattern. I’m sure this is pretty basic, but its stumping me.
For simple things, you can just apply arithmetic operators (*, /, +, -) directly
d1 $ gain "1 0.9" * gain "1 0.8 1.1" # s "bd"
Often you’ll want to preserve structure from one or other of the patterns, which you can do with
*|. E.g. to preserve structure on the left:
d1 $ gain "1 0.9" |* gain "1 0.8 1.1" # s "bd"
In this example it’d be easier to work with the number pattern inside the control pattern, e.g.
d1 $ gain ("1 0.9" |* "1 0.8 1.1") # s "bd"
If you have a more complex need in mind let us know
Thanks for the reply!
I do have slightly more complex operations in mind. For example, if I want to invert values normalized between 0 and 1, I could make a simple function:
invert x = 1 - x
and this gives the kind of result I want when applied to a
Pattern String, e.g.,
pt = "0.0 0.25 1.0*4"
gain (invert pt)
But what I’m looking for is something that could take advantage of the operations available on ControlPatterns. I’d like to be able to get the same result with
invert (gain pt)
so that I could apply it to more elaborate expressions like
every 4 invert (gain pt)
invert $ slowcat [(gain pt1), (gain pt2), (gain pt3)]
My apologies, I should have been more explicit in my original post.
No problem, that would be
invert = (gain 1 -|)
That’s exactly what I was looking for!
I didn’t think to use those pattern algebra operators that way. That opens a lot of new possibilities for me.
It is often nice to work at the controlpattern level, but your examples would all still work inside the gain pattern btw, e.g.:
gain (every 3 (1 -|) $ slowcat [pt1, pt2, pt3])