Rotating Control Patterns?

I think there's something fundamental about the difference between note patterns and control patterns that I've yet to fully digest...

Say that I have a pattern that uses fit like:
s "rytm" (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8")

Now I want to alter the velocity using another pattern (I have a helper function that converts the velocity numbers into amp): vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8"

Now say I'd like to rotate just the control pattern every 5 cycles. My first thought is this, but it does not work:

s (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8") 
   $ every 5 (rot) (# vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8)

I'm pretty sure that's because I can't use one of these types of modifier functions where I put it using the dollar sign. I think I'd have to put the every before the sound pattern and tell it to only effect the "vel" parameter somehow? I often get confused around this so can someone enlighten me, and/or let me know how to accomplish this using functions just on control patterns?

Many thanks!

Hey @ben,

I'm not sure what you mean exactly by 'note pattern'. Do you mean what gets turned into a control pattern?

So taking your pattern, firstly the vel mininotation thingie is missing a closing quote, so fixing that:

s (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8") 
   $ every 5 (rot) (# vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8")

Now looking at the 'every' and what comes after, I see the rot needs a parameter to say how many steps to rotate by, I'll just put 1 there:

s (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8") 
   $ every 5 (rot 1) (# vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8")

Now the third input of every should be a pattern. You've got a # there, which turns it into a function, rather than a pattern. # is a function that takes two patterns as inputs, one on the left, and one on the right, and joins them together into a new pattern. The one on the left is missing, so you end up with a function that takes that missing pattern as input. So lets just get rid of the #:

s (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8") 
   $ every 5 (rot 1) (vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8")

Ok so now we have an s pattern, which gets that pattern from the fit, and a vel pattern, which gets a bit mangled by the every but still ends up being a vel pattern. So these two patterns need to be joined together with something like #. But there's a $ instead, which expects a function on its left, and an input to pass to that function on its right.. So lets swap that $ for an #:

s (fit "<3 2 4>" ["bd2", "cp", "lt", "~", "sd", "ch"] "{0 [1 2?] 4 3*4 [5 6]}%8") 
   # every 5 (rot 1) (vel "{127 [90 120] 111 127 90 110 127 [80 100]}%8")

Ok that should work!

2 Likes

Ahhh. Thank you @yaxu!

I guess in general I've been giving up too quickly when I had my parentheses and combiners (?) messed up, thinking it was a larger issue. Glad it's not!

And thanks for that explanation of # and $. No matter how many times I hear it it sinks in in a new way each time.

B

I'm not sure what you mean exactly by 'note pattern'. Do you mean what gets turned into a control pattern?

PS: Yeah that is what I meant but you clarified it above.

1 Like

"operators" :slight_smile:

1 Like

I’d like to log my vote to change their names to ‘combiner thingees’.

2 Likes

Heh well if you think of $ as combining a function with an input (usually a pattern), and # as combining a pattern with another pattern, that should help?

The confusing thing is that $ is redundant in a way. All you have to do to combine a function with an input is put them next to each other like this rot 1. rot $ 1 means the same. The only difference is that the $ has really low priority, which means the stuff on the right is worked out first. So rot $ 1 + 4 is the same as rot (1 + 4), and rot 1 + 4 is the same as (rot 1) + 4.. Those latter two are syntax errors because rot 1 is a function, and you can't add 4 to a function.

2 Likes

Yes, really helpful thanks.

I had been under a vague impression that I could only use the $ in certain places within code blocks, and only towards the beginning. But now I’m realizing that I was totally wrong, which is great :wink:

That's kind of true - it only works for the final parameter you're passing to a function. So every 3 (fast 2) $ sound "bd sn" works, but every 3 $ fast 2 $ sound "bd sn" or every 3 $ fast 2 (sound "bd sn") don't.