Tzopilotl
Docs
GitHub

Writing SynthDefs

4. Signal Operators

These are the primitive per-channel operations on signals, defined in synthdef.x. All are elementwise across channels with broadcasting (§2.4).

Unary operators and functions

GroupOperations
Prefix operators-a (negate), !a (logical not), ~a (bitwise not)
Basicabs, sign
Roundingfloor, ceil, trunc, round
Rootssqrt, cbrt
Logarithmslog, log2, log10, log1p
Exponentialsexp, exp2, exp10, expm1
Trigonometricsin, cos, tan, asin, acos, atan
Hyperbolicsinh, cosh, tanh, asinh, acosh, atanh
π-scaled trigsinpi, cospi, tanpisinpi(x) = sin(πx); cheaper and exact at integer arguments
Speciallgamma, tgamma, erf, erfc
Bit countingclz, ctz, clo, cto, popCount, bitWidth, hasSingleBit
Bit shapingrotr, rtol (rotate left), bitCeil, bitFloor

Binary operators

GroupOperations
Arithmetic+ - * / // (integer divide) % (mod)
Bitwise& | ^ << >> >>> (unsigned shift right)
Named mathmin, max, pow, atan2, hypot, copysign
Pipeline aliasesadd, sub, mul, div, mod — the arithmetic operators as named functions, for space-pipeline style: x mul(0.5) add(1)

Comparison operators

< <= == != >= > compare per channel and produce a numeric 0/1 signal, not a Bool. This is the idiomatic building block for gates and masks — multiply by a comparison to zero out a signal, or feed one to select2:

(x > 0)                -- 1 where positive, else 0
x * (phase < pwm)       -- gate x by a pulse
urand() < prob          -- Bernoulli trigger (see coin)

Cast operators

i32, i64, f32, f64 force the element type (§2.2). They accept any AsSignal.

↑ Back to top