Tzopilotl
Docs
GitHub

Writing SynthDefs

3. Constants and Conversion to Signals

Plain Tzopilotl numbers become constant signal nodes on demand. Three constraints (type sets) describe what converts:

ConstraintMembersMeaning
BasicValuesBool | Int | Fraction | Float Scalars that convert to 1-channel constants
AsConstantSignalBasicValues | [BasicValues] Scalars or arrays of them (arrays become multichannel constants)
AsSignalSignalExpr | AsConstantSignal Anything usable as a signal input

All the operators in §4 have overloads accepting AsConstantSignal on either side, so mixed expressions like x * 0.5 and [8, 7.23] lfsaw just work. When writing your own ugens, declare parameters as AsSignal (or leave them untyped) and call asSignal where you need an S explicitly.

FunctionDescription
asSignal(x)Convert a scalar, array, or signal to S. Identity on signals.
scalar(x)1-channel constant from a Bool/Int/Fraction/Float.
vec(v)Multichannel constant from an array; width = v length asChans, elements repeat cyclically to fill.
fill(chans, x)Constant with x replicated across chans channels.

Fraction literals (e.g. 3/2 in contexts where the language keeps them exact) convert via toFloat; integer-valued constants stay type-flexible (§2.2).

↑ Back to top