Being new at all this I tried both systems and liked the NamedControl. This until I started (over) documenting the code.
(
SynthDef.new(\basicFM, {
/*: basic frequency modulator using one carrier and two modulators
and an envelope.
:carrier:
carHz (Hz, 500): carrier frequency (to be modulated by modulated modulator 1).
amp (float, 0.5): attenuation, amplification of the modulated carrier.
:modulator 1:
modHz (Hz, 100): modulator frequency (to be modulated by modulator 2).
modAmp (float, 200): attenuation, amplification of the modulator.
:modulator 2:
mod2Hz (Hz, 100): modulator frequency (modulates modulator 1).
mod2Amp (float, 200): attenuation, amplification of the modulator.
:envelope:
atk (s, 0.01): attack time.
rel (s, 1): release time.
:soundfield:
pan (float, 0): position of signal in soundfield.
*/
var car, carHz=\carHz.kr(500), mod, mod2, env;
env = EnvGen.kr(Env.perc( \atk.kr(0.01), \rel.kr(1) ), doneAction:2);
mod = SinOsc.ar(\modHz.kr(100), mul: \modAmp.kr(200));
mod2 = SinOsc.ar(\mod2Hz.kr(100), mul: \mod2Amp.kr(200));
car = SinOsc.ar(carHz + (mod + mod2)) * env * \amp.kr(0.2);
car = Pan2.ar(car, \pan.kr(0));
Out.ar(0, car);
}).add;
)
(
SynthDef.new(\basicFM, {
/*: basic frequency modulator using one carrier and two modulators
and an envelope.*/
//:carrier:
arg carHz=500 /*:(Hz) carrier frequency (to be modulated by modulated modulator 1).*/
,amp=0.5 /*:(float) attenuation, amplification of the modulated carrier.*/
//:modulator 1:
,modHz=100 /*:(Hz) modulator frequency (to be modulated by modulator 2).*/
,modAmp=200 /*:(float) attenuation, amplification of the modulator.*/
//:modulator 2:
,mod2Hz=100 /*:(Hz) modulator frequency (modulates modulator 1).*/
,mod2Amp=200 /*:(float) attenuation, amplification of the modulator.*/
//:envelope:
,atk=0.01 /*:(s) attack time.*/
,rel=1 /*:(s) release time.*/
//:soundfield:
,pan=0 /*:(float) position of signal in soundfield.*/
;
var car, mod, mod2, env;
env = EnvGen.kr(Env.perc(atk, rel), doneAction:2);
mod = SinOsc.ar(modHz, mul: modAmp);
mod2 = SinOsc.ar(mod2Hz, mul: mod2Amp);
car = SinOsc.ar(carHz + (mod + mod2)) * env * amp;
car = Pan2.ar(car, pan);
Out.ar(0, car);
}).add;
)