SynthDef in Ndef and fadeTime

I have a large number of SynthDefs that I’d like to use as Ndef sources combined with .fadeTime. If I’m understanding it right, defining the \out key overwrites the internal Ndef one, meaning you can’t use the fadeTime parameter without defining your own explicitly. Is there any way around this? I’d like to avoid rewriting all my SynthDefs/remake everything as an Ndef. Thanks!

//fade

Ndef(\test).clear;

Ndef(\test, { SinOsc.ar(\freq.kr(440)) * 0.1 ! 2;});

Ndef(\test).fadeTime = 10;

Ndef(\test).play;

Ndef(\test).xset(\freq, 220);

//no fade

(
    SynthDef(\my_synthdef, {
        var sig = SinOsc.ar(\freq.kr(440)) * 0.1;
        Out.ar(\out.kr(0), sig ! 2);
    }).add;
)

Ndef(\test).clear;

Ndef(\test, \my_synthdef).fadeTime = 10;

Ndef(\test).play;

Ndef(\test).xset(\freq, 220);

This isn’t a complete solution for NodeProxy, but the ddwPlug quark can “wrap” a synthdef within another without any rewriting:

(
(1..2).do { |ch|
	SynthDef(("fade_wrapper" ++ ch).asSymbol, { |out = 0, fadeTime = 0.2, gate = 1|
		var sig = NamedControl.ar(\src, Array.fill(ch, 0));
		var eg = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime, -1.5), gate, doneAction: 2);
		Out.ar(out, sig * eg);
	}).add;
};
)

// now if you have a SynthDef \x, you can "wrap" in the fade envelope like this:
thingToPlayInNodeProxy = Syn(\fade_wrapper2, [
	out: nodeProxy.bus,
	fadeTime: 0.2,  // whatever time you want
	src: Plug(\x, [ ... args for x ... ])
]);

“Wrap” in quote marks because the structure of \x remains the same. The Plug passes the signal to Syn on a bus, automatically managed for you.

I’m not familiar enough with the details of xxxControl JITLib objects but it should certainly be possible to put a Syn onto a NodeProxy bus. (One thing though is that the \x control names will all get ‘src/’ appended at the front, e.g. Ndef(\x).set('src/freq', 880) – necessary to disambiguate which node is responsible for which control).

hjh