fadeTime with Pdef and Pbindef

I’d like to use fadeTime to crossfade between \key changes inside a Pdef or Pbindef - for instance, to fade the pattern out from \amp, 0.5, to \amp, 0, without changing any other parameter of the pattern. And then be able to fade the pattern back in using the same procedure.

So far, I can only get this to work consistently when I redefine the entire Pdef, and not when I target single \key pairs with Pbindef.

In the code below, the first Pbindef fades the pattern to \amp, 0 over 5 seconds as expected.
But the second Pbindef sets the \amp to 0.5 immediately as if the fadeTime is no longer there.

Why is this? And how can I get the Pbindef changes to always have the fadeTime?

(
Pdef(\y, Pbind(
		\instrument, \default,
		\dur, 0.5,
		\amp, 0.5,
		\out, 0,
)).play;
)
Pdef(\y).fadeTime = 5;

//fades out over 5 secs
Pbindef(\y, \amp, 0);

//immediately changes
Pbindef(\y, \amp, 0.5);
2 Likes

This question describes an understandable demand, but there is a tricky background involving two blocks of questions.

  1. What do you actually (technically) expect ?
    Should the values of the Pbind-generated synths be changed from event to event, should this happen ‘totally’ gradually in the sense that amp is mapped to a bus so that amp is diminished for every event? Depending on the answer different solutions would be possible. As you have been involved, I mention this related thread for others:
    Continuous Panning of Multiple Pbind Nodes?

  2. How to deal with the question in combination with Pdef / Pbindef
    It could be that fading Pdefs doesn’t do what you expect.
    See this example:

     (
     Pdef.removeAll;
    
     Pdef(\y, Pbind(
     	\instrument, \default,
     	\dur, 0.5,
     	\amp, 0.5,
     	\out, 0,
     )).play;
    
     Pdef(\y).fadeTime = 5;
     )
    
     // do fade, a second player is added !
     Pbindef(\y, \freq, 700);
    

So when “fading out the amp” we are crossfading chords of same pitches where one has amp 0 !
I’m not a JITLib expert but I am not aware if generating a Pdef and then treating it as Pbindef for fading (though possible as they share the same namespace) is an intended usage. There are no fading examples in Pbindef help !

The fading examples I see in the help refer to Pdef sources, so you could do this:

(
Pdef.removeAll;

Pdef(\y, Pbind(
	\instrument, \default,
	\dur, 0.5,
	\amp, 0.5,
	\out, 0,
)).play;

Pdef(\y).fadeTime = 5;
)


Pdef(\y).source = Pbind(
	\instrument, \default,
	\dur, 0.5,
	\amp, 0,
	\out, 0,
) 

Pdef(\y).source = Pbind(
	\instrument, \default,
	\dur, 0.5,
	\amp, 0.5,
	\out, 0,
) 


Pdef(\y).source = Pbind(
	\instrument, \default,
	\dur, 0.35,
	\midinote, 62,
	\amp, 0.5,
	\out, 0,
) 

Pdef(\y).stop

You can save writing here by using template patterns and Pchain. Concerning Pbindef Julian could tell better, so maybe ask him directly or on the mailing list.

2 Likes

Thanks a lot, Daniel. I’ll look more at Pchain, as you suggest, in combination with Pdef.
I think I’ll also ask about Pbindef fadeTime examples on the mailing list. I can see that Pbindef inherits the fadeTime method from Pdef, but as you say, there are no examples in the helpfile.

Regarding what to technically expect, my understanding is that the fadeTime crossfades two players as you point out. That’s fine for my purposes at the moment. But I don’t understand why it doesn’t do this consistently with Pbindef - why it does it once, but not a second time. It could have something to do with the mixing of Pdef and Pbindef as you mentioned…

Update: a similar question here, with a little helper function with Pseg a quite short syntax for fading is easy to do - I haven’t thought about that possibility so far and it works with type \note and \set (Pmono-like)

Note that there’s a typo corrected in

Hey, the way I solved this was by doing another amplitude argument in the SynthDef, I named “mastervol”, then I declare it inside the pbind as an Ndef.

\mastervol, Ndef(\volctrl, {XLine.kr(write here your fade)});

Once that is written down inside the Pbind, you can use that Ndef to always control the overall volume of that Pbind.