Pbindef fade in and fade out

I’d do this with Pbind of type set, then you can take all benefits of Pbindef. E.g.:

Pdef.removeAll

// start silently first
x = Synth(\default, [amp: 0]);

Pbindef(\a,
	\type, \set,
	\id, x.nodeID,
	\midinote, Pshuf((60..90), inf),
	\dur, 0.2,
	\amp, 0.1,
	\pan, 0
).play

// helper function for fading with Pseg

~f = { |start, end, time, curve = 0| Pseg(Pseq([start, Pn(end)], time, curve)) }

Pbindef(\a, \amp, ~f.(0.1, 0.5, 10))

Pbindef(\a, \pan, ~f.(0, -1, 5))

Pbindef(\a, \pan, ~f.(-1, 1, 5))


Pbindef(\a).stop;
x.release;

With PLbindef from miSCellaneous_lib:

x = Synth(\default, [amp: 0]);

PLbindef(\b,
	\type, \set,
	\id, x.nodeID,
	\midinote, Pshuf((60..90), inf),
	\dur, 0.2,
	\amp, 0.1,
	\pan, 0
).play


~b.amp = ~f.(0.1, 0.5, 10)

~b.pan = ~f.(0, -1, 5)

~b.pan = ~f.(-1, 1, 5)


~b.stop;
x.release;

Note that for non-standard args you’d have to define the setting option within Pbind / Pbindef:

	\args, [\bla_1, \bla_2],

Durations / tempo fading wouldn’t work in the same way, see this thread for some suggestions on this special case:

2 Likes