Something like Pkey() in supercollider - new func suggestion

Hi, working on my project I've got another idea, that it will be cool to have something like is in SuperCollider pattern system - Pkey function.

What is does it "grab" current value of some previous parameter.
For example:

d1 $ n (segment 4 $ irand 5) # s "metal" # gain ( pkey n / 5 )

The example above should adjust gain depending on current value in n param.

paum

2 Likes

There's an "extract" series of functions that basically does this, but unfortunately the language seems to force a bit of awkward syntax:

(\x -> x # gain ((extractF "n" x)/5)) $ n (segment 4 $ irand 5) # s "metal"

We can make this a little better with a helper function

exf w s f pat = pat # w (f $ extractF s pat)

exf gain "n" (/5) $ n (segment 4 $ irand 5) # s "metal"
2 Likes