Crossfade between two pbinds

Hi

I would like to be able to crossfade back and forth between two pbinds like one would crossfade between two signals with the XFade2 UGen.

As a starting point…

(
SynthDef(\sine, {

	arg freq = 300, out = 0;
	var snd, env;

	env = EnvGen.ar(Env([0, 1, 0], [0.2, 0.3]), doneAction: 2);

	snd = SinOsc.ar(freq, mul: 0.3) * env;

	Out.ar(out, snd);

}).add
)


(
SynthDef(\saw, {

	arg freq = 200, out = 0;
	var snd, env;

	env = EnvGen.ar(Env([0, 0.5, 0], [0.3, 0.4]), doneAction: 2);

	snd = LFSaw.ar(freq, mul: 0.2) * env;

	Out.ar(out, snd);

}).add
)


(
u = Pbind (
	\instrument, \sine,
	\dur, 0.5,
)
)

(
v = Pbind (
	\instrument, \saw,
	\dur, 0.8,
)
)

u.play
v.play

Thanks!

This is easiest with Pdef, e.g., see here (this thread is almost exactly 10 years old and I thought I posted the day before yesterday :slight_smile::slightly_frowning_face:)

https://www.listarc.bham.ac.uk/lists/sc-users-2011/msg03814.html

Cool!

What I would like to achieve is to crossfade between the two via Open Stage Control which is an application to send osc data.

I could use a button which would execute

Pdef(\x, q);

at state 1 and

Pdef(\x, p);

at state 0.

But I actually I would like to use a fader which might stop at 80% of one Pdef and 20% of the other Pdef if that makes sense to you.

I can’t quite see at the moment how to do this.

Basically you can decide to do the mixing explicitely (via busses) or by using JITLib stuff. You can blend and morph presets. I’m not a JITLib expert, so someone might want to chime in.