Pbind to produce portamento on chords with different freqs

The reason why this is not working is, that you cannot use the Pkey within a Function. As discussed here, Pfunc + specifying is the more flexible approach for taking over other key’s values within an Event.

The Pseq here is filled with an Array, but this will always be the same because the inner Function is evaluated before sequencing. If you want that you would not need the Pseq and could write

\freq, { rrand(200, 1000) } ! 10 // ! is for dup

But if you want different random chords, just write

\freq, Pfunc { { rrand(200, 1000) } ! 10 }

(
Pdef(
    \portamentoSeq, 
    Pbind(
        \instrument, \portamentoPerc,
        \freq, Pfunc { { rrand(200, 1000) } ! 10 }, // random start freqs
        \endFreq, { rrand(200, 500) } ! 10, // same end freqs
        \dur, 2,
        \portaDelai, Pkey(\dur)*0.1, //delay before portamento
        \portaDur, Pkey(\dur)*0.7, // portamento duration
        \amp, 0.05
    )
);
)

c = Pdef(\portamentoSeq);
c.trace.play;
c.pause;
1 Like