Amp trigger Impulse issue

The impulse trigger responsible for the amp trigger doesn’t work when executing the synthdef
I need to execute the w.set amptrigrate …weird since the initial argument for amptrigrate is 4/2 (2 hertz)
Here is the code

(

SynthDef(\effem,
{
	arg moddetune=1,modratio=2,modtrigrate=1,carrierratio=1,carrierdetune=(-1),moddepth=8,att=2,decay=0.5,ampatt=0.001,ampdec=0.250,amptrigrate=4/2;
	var mod,carrier,modenv;
	mod=SinOsc.ar(220+moddetune*modratio);
		modenv=EnvGen.ar(Env([0,1,0],[att,decay],[0,-2]),doneAction:0,gate:Impulse.ar(modtrigrate));
	mod=(moddepth*mod)*modenv;
	carrier=SinOsc.ar(220+carrierdetune*carrierratio,mod)*0.3;
		carrier=carrier*EnvGen.ar(Env([0,1,0],[ampatt,ampdec],[0,-2]),doneAction:00,gate:Impulse.ar(amptrigrate))!2;
		Out.ar(0,carrier);
}).add
)




w=Synth(\effem);
w.free;
w.set(\modtrigrate,4/2);
w.set(\amptrigrate,8/2);////////have to execute this line 
w.set(\ampatt,0.001);
w.set(\ampatt,0.250);
w.set(\ampdec,1);
w.set(\ampdec,0.125);
w.set(\decay,0.5);
w.set(\at,0.001);
w.set(\moddepth,10)
w.set(\moddepth,5);
w.set(\moddepth,2);
w.set(\moddepth,100,\modratio,2,\moddetune,6,\carrierratio,1,\att,5,\decay,8);///lots of parameters in one

//////////

It seems that the initial argument amptrigrate totally ignores divisions like ‘8/2’
While executing it in set.mode it does not.

w = Synth(\effem, [amptrigrate: 4/2]);

Maybe 2-3 days ago this was discussed in another thread – your thread, as it happens. I’ll add a bit of boldface for the important point:

SynthDef argument defaults must be literal floats or literal arrays. Expressions are never permitted here [i.e. in SynthDef arg lists]. You will also have a problem e.g. with arg freq = 440 / 2.

If you need a synth control to have a nonliteral default, use NamedControl.

So, omit amptrigrate as an argument, and then after the arg list, write:

var amptrigrate = NamedControl.kr(\amptrigrate, 4/2);

From the outside, amptrigrate will then be settable just like any other control, even though it was declared differently.

hjh

Edit: Corrected modtrigrate → amptrigrate.

1 Like