SynthDescLib and .ir arg initialization

(Example code) To make a synthDef more easily readable i wanted to declare my variables in the code using .ir, however this does not seem to work together with SynthDescLib (sliders dont do anything). I don’t know much about .ir initialization or SynthDescLib so maybe someone can help me?

Working code with |args|:

SynthDef(\guiExample, {|freq=100,modFreq=50,amp=0.4|
	var sig, mod;
	sig = SinOsc.ar(freq,0,0.5);
	mod = SinOsc.ar(modFreq,0,0.5,0.5);
	sig = sig*mod;
	Out.ar(0, sig * amp!2);
}, metadata: (
	specs: (
		freq: [30,10000,\exp],
		modFreq: [5,5000,\exp],
		amp: [0, 1, \db]
	)
)).add;
)

SynthDescLib.global[\guiExample].makeGui.alwaysOnTop_(true)

Same code with .ir initialization (silders dont work):

SynthDef(\guiExample, {
	var sig, mod;
	sig = SinOsc.ar(\freq.ir(100),0,0.5);
	mod = SinOsc.ar(\modFreq.ir(50),0,0.5,0.5);
	sig = sig*mod;
	Out.ar(0, sig * \amp.ir(0.4)!2);
}, metadata: (
	specs: (
		freq: [30,10000,\exp],
		modFreq: [5,5000,\exp],
		amp: [0, 1, \db]
	)
)).add;
)

SynthDescLib.global[\guiExample].makeGui.alwaysOnTop_(true)

Use .kr.

.ir means it can only be set when the synth is constructed.

There is also .ar for audio rate inputs, but you have to map them to a bus.

Ahhh yes that totally makes sense!
Thank you for your quick help :slight_smile:

1 Like