Skip to content

DSP

NameDescription
SRSample rate in Hz. Configure with config.sample_rate(rate).
INV_SRInverse sample rate (1.0 / SR). Useful for phase increment calculations.
PIPi (3.14159…)
TWOPITwo pi / tau (6.28318…). Full cycle in radians.
CYCLECurrent cycle position (0.0 to 1.0), derived from the transport clock.
CPSCycles per second — tempo-derived frequency (e.g. 120 BPM = 2.0 CPS).
TIMEElapsed time in seconds since the signal’s epoch. Available in dsp signal blocks only.

SR and INV_SR are injected at runtime and reflect the actual sample rate. CYCLE and CPS are updated each sample from the transport. TIME is only available inside dsp signal blocks.

All built-in functions in DSP blocks are called via __native("name", ...). This makes it explicit that these are native implementations compiled to efficient graph nodes — they have no user-visible definition in Resonon code.

dsp effect FilteredOverdrive {
param cutoff: 2000.0 range(20, 20000);
param drive: 0.5 range(0, 1);
fn process(left, right) -> (out_l, out_r) {
let gain = 1.0 + 20.0 * drive;
let l = __native("tanh", left * gain);
let r = __native("tanh", right * gain);
return (
__native("svf_lp", l, cutoff, 0.707),
__native("svf_lp", r, cutoff, 0.707)
);
}
}
FunctionDescription
__native("sin", x)Sine
__native("cos", x)Cosine
__native("tan", x)Tangent
__native("tanh", x)Hyperbolic tangent (useful for soft clipping)
FunctionDescription
__native("exp", x)e^x
__native("log", x)Natural logarithm (ln)
__native("log2", x)Base-2 logarithm
__native("log10", x)Base-10 logarithm
__native("sqrt", x)Square root
__native("pow", base, exp)Power (base^exp)
FunctionDescription
__native("abs", x)Absolute value
__native("floor", x)Round down to nearest integer
__native("ceil", x)Round up to nearest integer
__native("round", x)Round to nearest integer
__native("fract", x)Fractional part (x - floor(x))
__native("clamp", x, lo, hi)Clamp x to the range [lo, hi]
__native("min", a, b)Minimum of two values
__native("max", a, b)Maximum of two values
__native("lerp", a, b, t)Linear interpolation: a + (b - a) * t
FunctionDescription
__native("mtof", note)MIDI note to frequency: 440 * 2^((note - 69) / 12). Accepts fractional notes for microtonal pitches (e.g. __native("mtof", 60.5) gives a quarter-tone above C4)
__native("ftom", freq)Frequency to MIDI note: 69 + 12 * log2(freq / 440)

These functions maintain internal state across samples. Each call site gets its own independent state — the DSP compiler allocates a hidden state buffer for each __native(...) call that needs it.

FunctionDescription
__native("svf_lp", signal, freq, Q)State Variable Filter — lowpass
__native("svf_hp", signal, freq, Q)State Variable Filter — highpass
__native("svf_bp", signal, freq, Q)State Variable Filter — bandpass
__native("svf_notch", signal, freq, Q)State Variable Filter — notch
__native("svf_allpass", signal, freq, Q)State Variable Filter — allpass
__native("svf_peak", signal, freq, Q)State Variable Filter — peak (bell)
__native("onepole", signal, coeff)One-pole lowpass filter

SVF filters use a topology-preserving transform (Zavalishin). freq is in Hz, Q controls resonance (0.707 = Butterworth, higher = more resonant). The sample rate is injected automatically.

onepole is a simple first-order lowpass. coeff ranges from 0 to 1 — higher values track the input faster.

FunctionDescription
__native("delay", signal, samples)Integer sample delay (circular buffer, max 1 second)
__native("delay_interp", signal, samples)Fractional delay with linear interpolation (max 1 second)
FunctionDescription
__native("noise")White noise, range [-1.0, 1.0]
__native("sample_hold", signal, trigger)Captures signal on rising edge of trigger (transition from <=0 to >0)