Multiple and independent pitchEvent keys inside a SynthDef

Check out array arguments (SynthDef help file). Whenever you write something like xy1, xy2 etc. consider writing arrays.

For some reason especially array args seem to fbe unpopular, or they are poorly documented, or both. Array args are a bit tricky with patterns though - but not really, just note that you have to wrap into an extra array to avoid expanding into multiple synths per event (which normally happens if you use arrays within event patterns).

(
SynthDef(\SimpleSine_arrayArg, {
    arg freq = #[440, 2, 0.1], out;
    var sig;
    freq.poll;
    sig = PMOsc.ar(freq[0], freq[1], freq[2]);
    Out.ar(out, sig * EnvGen.ar(Env.perc, doneAction: 2)) 
}).add;
)

(
f = Pbind(
    \instrument, \SimpleSine_arrayArg,
    \degree, Ptuple([
        Pseq([0, 1, 2, 4, 6, 3, 4, 8], inf),
        Pwhite(-7, 7) ,
        Pbrown(0, 7, 1)
    ]).collect([_]), // wrap into extra array
    \dur, 0.5, 
    \octave, [[5, 3, 2]] // wrap into extra array here too
).trace.play;
)

The miSCellaneous_lib quark contains a tutorial “Event patterns and array args”.
Also see Nathan’s note on NamedControl, esp. the chapter “Advantage: Better multichannel controls”:

2 Likes