SynthDescLib non default synth params not working in default Event

Via SynthDescLib non default synth params not working in default Event · Issue #6494 · supercollider/supercollider · GitHub

Environment

  • SuperCollider version: sclang 3.13.0 (Built from tag ‘Version-3.13.0’ [3188503])
  • Operating system: Arch / macOS Sonoma

Steps to reproduce, including expected behavior

(
SynthDescLib(\test, s);
SynthDef("huh", {arg out = 0, amp = 0.1, sinfreq = 440;
	var env = Env.perc(0.1, 0.2, amp).kr(doneAction: 2);
	var snd = SinOsc.ar(freq: sinfreq, mul: env);
	Out.ar(out, snd);
}).add('test');

SynthDef("whaaaaat", {arg out = 0, amp = 0.1, sinfreq = 440;
	var env = Env.perc(0.1, 0.2, amp).kr(doneAction: 2);
	var snd = SinOsc.ar(freq: sinfreq, mul: env);
	Out.ar(out, snd);
}).add;

SynthDef("okay", {arg out = 0, amp = 0.1, sinfreq = 440;
	var env = Env.perc(0.1, 0.2, amp).kr(doneAction: 2);
	var snd = SinOsc.ar(freq: sinfreq, mul: env);
	Out.ar(out, snd);
}).add('test').writeDefFile;
)

// sinfreq is changing the freq of our SinOsc (expected behavior)
Synth(SynthDescLib.all.at(\test).synthDescs['huh'].name, [amp: 0.3, sinfreq: rrand(400,800)])

// Pattern / Event
( // using SynthDescLib -- behavior is not expected: sinfreq is never changed
Pdef('', Pbind(*[
	instrument: SynthDescLib.all.at(\test).synthDescs['huh'].name,
	sinfreq: Pseg([80,900], 5, \exp, inf), 
	dur: Pfunc{|env| cos(env.sinfreq * 2pi / 900).linlin(-1, 1, 0.05, 0.5)},
	amp: 0.3
])).play(quant: 0);
)
( // synthdef without using SynthDescLib - behavior is expected
Pdef('', Pbind(*[
	instrument: 'whaaaaat',
	sinfreq: Pseg([80,900], 5, \exp, inf), 
	dur: Pfunc{|env| cos(env.sinfreq * 2pi / 900).linlin(-1, 1, 0.05, 0.5)},
	amp: 0.3
])).play(quant: 0);
)
( // using SynthDescLib with writeDefFile, behavior is expected
Pdef('', Pbind(*[
	instrument: SynthDescLib.all.at(\test).synthDescs['okay'].name,
	sinfreq: Pseg([80,900], 5, \exp, inf), 
	dur: Pfunc{|env| cos(env.sinfreq * 2pi / 900).linlin(-1, 1, 0.05, 0.5)},
	amp: 0.3
])).play(quant: 0);
)

maybe not related but observed with the SynthDef used with SynthDescLib add.(key)
Posting FAILURE IN SERVER /n_set Node 5088 not found at certain dur values. Something iffy with timing bestween doneAction and free in this kind of broken Event param communication. It seems.

In this case the Event has not specified which SynthDescLib to use. The event key to use is \synthLib.

\instrument, \huh,
\synthLib, SynthDescLib.all.at(\test),

In this expression, SynthDescLib.all.at(\test).synthDescs['huh'].name, the result is a string or symbol naming the SynthDef – which can only be 'huh' here. So the result of the expression has no information about which SynthDescLib to use. So I’m not sure why there was an expectation that the initial formulation would have worked. The event can operate only on the information in it; it can’t magically infer values that had been touched but which don’t exist in the results.

All of the noted problems follow from the lack of the SynthDesc.

hjh

1 Like

Yes, thank you for taking over, I had no time toi write something consistent up yesterday, so I just closed it …

1 Like

Thank you. It is all so so clearer now that I know about \synthLib. And also just realizing that SynthDescLib.getLib(\hjkl).synthDescs is a IdentityDictionary. I had some wild idea in my head that all the control param info was “shipped” directly to the event used by a pattern. Via a symbol lookup…
And that the SynthDescLib was merely a kind of convenience. A (“–human” / “-h”) to organize all the symbols created with SynthDef().add. But actually just providing a symbol at the instrument key in a Pbind was enough for the Event to get all the info it needed. But in this case apparently not everything.
Inner workings of SC is still … :fog::fog::fog: foggy to me. So glad you are here! :heart:
I am yet again reading more in the SCClassLibrary. Removing wild speculative ideas.
Though here is a new nut to crack: Curvature key inside a named control rate breaks SynthDef().writeDefFile

1 Like