# Synth Defintion File Cons

hello all, I apologize if this is a dumb question but I cant file a solution online nor in my italian super collider bbok

in the SynthDefinitionFile we have

• int32 - number of constants (K)
• [float32] * K - constant values

what are the constants and what are their values, for example in this SynthDef:
(
d = SynthDef(\demo, { |out = 0, freq = 340, amp = 0.1, gate = 1 |

Out.ar(out, (SinOsc.ar(freq) * amp ).dup);

});
)

which are the constants?

• I need this info for my Pharo Smalltalk backend. thanks for your help

Theyâ€™re just the constant values in the graph, so 0, 340, 0.1, 1.

Cf.

https://github.com/supercollider/supercollider/blob/develop/SCClassLibrary/Common/Audio/SynthDef.sc

(in SuperCollider)

Or:

https://gitlab.com/rd--/stsc3/-/blob/master/som/Sc3/Kernel/ScGraph.som

(in Smalltalk)

so why if evaluate on my SynthDef from above
d.constants;

Dictionary[ (0.0 â†’ 0) ] ?

I dont understand

Ah, apologies, arguments are controlsâ€¦ See below for more constantsâ€¦ Also all values are floats so 0 and 0.0 are the sameâ€¦

d = SynthDef(\demo, {
var out = 0, freq = 340, amp = 0.1, gate = 1;
Out.ar(out, (SinOsc.ar(freq) * amp ).dup)
});
d.inspect
1 Like

apologies again! gate isnâ€™t referenced, so 1 disappears, thatâ€™s why there are three numbers and not four, i misreadâ€¦

.inspect is great it will answer a few of my future questions too

but still, I donâ€™t understand what those constants are

They are constant values used as an input to a UGen.

The â€śconstantsâ€ť in your example are Control defaults, which are encoded into the SynthDefâ€™s list of controls.

The expression Out.ar(out, (SinOsc.ar(freq) * amp).dup) happens to use no constants at all! All of the UGen inputs here are expressions.

Oh waitâ€¦ except one input! SinOsc has a phase input, which isnâ€™t specified, so it reverts to the default = 0â€¦ and the constants collection does include a 0.

If you add, for instance, an EnvGen, the Env definition is extremely likely to include at least constants 0 (initial and final level) and 1 (peak level), perhaps others. Then youâ€™ll have more constants to look at.

hjh

but still, I donâ€™t understand what those constants are

see the â€śinput-specâ€ť definition for how theyâ€™re used?

https://doc.sccode.org/Reference/Synth-Definition-File-Format.html

an input-spec is :
int32 - index of unit generator or -1 for a constant
if (unit generator index == -1) : int32 - index of constant else : int32 - index of unit generator output

ps. thereâ€™s a synthdef disassembler and pretty printer in haskell supercollider, you can get a cli binary from:

https://github.com/rd--/hsc3-util

it might help if youâ€™re getting stuck?