hey, im writing a Gauss Curve to a Buffer to control the partials on an additive synth Strategy to control an additive synth. when you modulate the phase of LFGauss you can get a kind of Bandpass filter sweep through the partials. I was trying to modulate the phase of LFGauss with a Control Envelope ctrlEnv inside a Pbind and use ~bus[\ctrl][0] to map it to \phase of the source synth and was playing around with multichannel expansion and setting releaseNodes and loopNodes for the ctrlEnv and not sure how the multichannel expansion has to be done correctly.
\ctrlEnv, Pfunc{|e|
Env([0, 1, [2, 4], 1], [0.0001, [e.atk, 0.01], e.rel], \sin, releaseNode: 2, loopNode: 0);
},
What has to be done that ctrlEnv does multichannel expand or is this not possible at all with passing envelopes to patterns?
1.) Do I need more Channels for ~bufAmps and how many?
2.) Do I have to multichannel expand the namedControl \phase in the SynthDef with ! 2 for example? iphase: ( \phase.kr(0, 0.5) ! 2 ).mod(4pi)?
3.) Im also not sure if ctrlEnv needs DoneAction:Done.freeSelf when i set \dur, inf inside the Pbind and set a loopNode and releaseNode. Or if there is a better setting for the looping Envelope in general.
4.) I would like to have a flexible ctrlEnv SynthDef which could be used for several cases so i was wondering if its good to use methods like .linexp etc. inside the SynthDef which are already to hardcoded for different cases i think. is there a good way to have a flexible control Envelope SynthDef with a variable ModDepth which could be declared in the actual Pbind and not in the SynthDef?
any other ideas? thanks a lot 
(
~numPartials = 50;
~bufAmps = Buffer.alloc(s, ~numPartials, 1);
SynthDef(\additive, {
var gainEnv = \gainEnv.ar(Env.newClear(8).asArray);
var numPartials = ~numPartials;
var bufAmps = ~bufAmps;
var sig;
gainEnv = EnvGen.kr(gainEnv, \gt.kr(1), doneAction: Done.freeSelf);
BufWr.ar(
LFGauss.ar(
duration: SampleDur.ir * numPartials * \factor.kr(1, 0.5).reciprocal,
width: \width.kr(0.2, 0.5),
iphase: \phase.kr(0, 0.5).mod(4pi),
),
bufnum: bufAmps,
phase: Phasor.ar(end: numPartials)
);
sig = Array.fill(numPartials, {|i|
var freqs, partials;
freqs = \freq.kr(150) * ((i * 2) + 1);
partials = SinOsc.ar(
freq: freqs,
mul: Index.ar(bufAmps, i)
) / numPartials;
}).sum;
sig = LeakDC.ar(sig);
sig = sig * gainEnv;
sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
Out.ar(\out.kr(0), sig);
}).add;
SynthDef(\ctrlEnv, {
var sig, ctrlEnv;
ctrlEnv = \ctrlEnv.ar(Env.newClear(12).asArray);
sig = EnvGen.kr(ctrlEnv, \gt.kr(1), doneAction: Done.freeSelf);
Out.kr(\out.kr(0), sig)
}).add;
)
(
Pdef(\additive,
Pbind(
\type, \hasEnv,
\instrument, \additive,
[...]
\phase, ~bus[\ctrl][0].asMap,
\atk, 1.5,
\sus, 4,
\rel, 2.5,
\gainEnv, Pfunc{|e|
Env.linen(e.atk, e.sus, e.rel, curve: \sine)
},
\sustain, Pfunc { |ev| ev[\gainEnv].duration },
[...]
)
);
Pdef(\ctrlEnv,
Pbind(
\type, \hasEnv,
\instrument, \ctrlEnv,
\dur, inf,
\atk, 0.3,
\rel, 0.3,
\ctrlEnv, Pfunc{|e|
Env([0, 1, [2, 4], 1], [0.0001, [e.atk, 0.01], e.rel], \sin, releaseNode: 2, loopNode: 0);
},
\sustain, Pfunc { |ev| ev[\ctrlEnv].duration },
\out, ~bus[\ctrl][0],
\group, ~ctrlGrp,
)
);
)
(
Pdef(\additive_ctrl,
Ptpar([0, Pdef(\additive), 0.0001, Pdef(\ctrlEnv)])
).play(t, quant:1);
)