Interesting that the question is about patterns, but you haven’t shared any pattern snippets, only SynthDefs.
Anyway… “multiple random values per Event”
In other words, there is a hierarchy of behavior: one note contains multiple random values.
Pbind is a flat stream of events – therefore, Pbind by itself is likely to be clumsy for this requirement. (So, if you were thinking “How to make a Pbind do this” then you’d run into some obstacles.)
One hierarchical approach would be to have an Event spawn another stream, to set controls in the outer stream’s synth nodes. To do that, you would need access to the outer event’s node ID(s). There is a way to do that, although it’s buried in the Pattern Guide:
http://doc.sccode.org/Tutorials/A-Practical-Guide/PG_08_Event_Types_and_Parameters.html#User%20function%20hooks
\callback: A function that will be executed after the Event has finished all its work. The callback may be used for bookkeeping. Finished Events are expected to store new node IDs under ~id; with the IDs, you can register functions to watch node status or set node controls, for instance. The function receives the finished event as its argument.
I always like to post some information first, to be sure that required data will be available. In particular, how long will it play each synth? You don’t want to set controls on a synth that’s already finished. We also definitely need the ID. Because callback
happens after the event has finished processing, all of these are available:
// let's start by probing for available info
(
p = Pbind(
\degree, Pwhite(-7, 7, inf),
\dur, 2,
\legato, 0.9,
\callback, { |event|
[event[\id], event[\freq], event[\sustain]].postln;
}
).play;
)
[ [ 1000 ], 174.6141157165, 1.8 ]
[ [ 1001 ], 440.0, 1.8 ]
p.stop;
OK, so we get an array with one or more IDs, and \freq and \sustain are there too.
Then:
(
p = Pbind(
\degree, Pwhite(-7, 7, inf),
\dur, 2,
\legato, 0.9,
\callback, { |event|
Pfindur(event[\sustain], Pbind(
\type, \set,
\id, event[\id],
\args, [\freq],
\fake_lfo, Pgeom(1, 1.04, inf),
\freq, event[\freq] * Pexprand(
Pkey(\fake_lfo).reciprocal,
Pkey(\fake_lfo),
inf
),
\dur, rrand(0.05, 0.09)
)).play
}
).play;
)
p.stop;
(Edit: First version left out \id, event[\id]
which is kinda the whole point, oops…)
hjh