Signals
Continuous control signals. Import with use "std/signals";.
Signal
Section titled “Signal”A continuous control signal for modulation. Construct with Sine, Sine2, Saw, Saw2, Tri, Tri2, Square, Square2, Rand, Perlin, signal_ramp(...), or signal(pattern).
fn range(min: Number, max: Number) -> SignalMaps the signal output to a linear range [min, max].
Parameters:
min(Number) — output value at the bottom of the signal’s rangemax(Number) — output value at the top of the signal’s range
Returns: Signal — the rescaled signal, for chaining
range_exp
Section titled “range_exp”fn range_exp(min: Number, max: Number) -> SignalMaps the signal output to an exponential range [min, max]. Useful for frequency modulation.
Parameters:
min(Number) — output value at the bottom of the signal’s rangemax(Number) — output value at the top of the signal’s range
Returns: Signal — the exponentially rescaled signal, for chaining
retrigger
Section titled “retrigger”fn retrigger(mode: String) -> SignalSets the phase reset mode.
Parameters:
mode(String) — phase reset mode: “cycle”, “beat”, or “free”
Returns: Signal — the signal with the new reset mode, for chaining
smooth
Section titled “smooth”fn smooth(time_ms: Number) -> SignalApplies one-pole lowpass smoothing to the signal. Useful for removing zipper noise from MIDI CC signals.
Parameters:
time_ms(Number) — smoothing time in milliseconds
Returns: Signal — the smoothed signal, for chaining
continuous
Section titled “continuous”fn continuous() -> SignalOpt out of bind-time epoch shifting. By default, signals reset their local time to 0 at the next cycle boundary after binding. Use .continuous() to keep the signal on the global playback clock — useful for LFOs where you want to tweak frequency without resetting phase.
Example:
lpf.param("Cutoff") << Sine(hz_to_periods(2)).range(200, 4000).continuous()
Returns: Signal — the signal locked to the global clock, for chaining
fn at(time: Number, value: Number, curve: String?) -> SignalAdds a breakpoint to an automation signal (builder pattern). Can only be called on signals created with automation(). Supported curves: “linear”, “step”, “exp”, “smooth”, “ease-in”, “ease-out”, “ease-in-out”, “ease”, “bezier(x1,y1,x2,y2)”
Example:
automation().at(0, 400).at(4, 2000, "smooth").at(8, 400)
Parameters:
time(Number) — breakpoint time in cycles (or seconds with.in_seconds())value(Number) — value at this breakpointcurve(String) — interpolation curve into this breakpoint (see list above)
Returns: Signal — a new signal with the added breakpoint, for chaining
in_seconds
Section titled “in_seconds”fn in_seconds() -> SignalSwitches automation time base from cycles to seconds. Can only be called on automation signals.
Example:
automation(#[0, 400], #[1.5, 2000]).in_seconds()
Returns: Signal — the automation signal timed in seconds, for chaining
set_param
Section titled “set_param”fn set_param(name: String, value: Number) -> SignalSets a named parameter on the signal.
Parameters:
name(String) — parameter namevalue(Number) — parameter value
Returns: Signal — the signal with the updated parameter, for chaining
fn Cc(cc_number: Number) -> Signalfn Cc(channel: Number, cc_number: Number) -> SignalCreates a MIDI CC input signal (0 to 1 output) for a specific channel. Requires an active MIDI input connection.
Example:
Cc(0, 74)
Parameters:
channel(Number) — MIDI channel (0-15)cc_number(Number) — CC number (0-127)
Returns: Signal — a control signal tracking the CC value, normalized to 0..1
Cc_learn
Section titled “Cc_learn”fn Cc_learn() -> SignalMIDI learn: waits for a CC knob/fader to be moved, then returns a Signal bound to that CC channel and number. Blocks for up to 10 seconds. Requires an active MIDI input.
Example:
let cutoff = Cc_learn()
Returns: Signal — a control signal bound to the learned CC, normalized to 0..1
Perlin
Section titled “Perlin”fn Perlin(freq: Number = 1) -> SignalUnipolar Perlin noise signal (0 to 1). Smooth, continuous.
Parameters:
freq(Number) — noise rate in periods per cycle
Returns: Signal — a unipolar Perlin-noise control signal
fn Rand(freq: Number = 1) -> SignalUnipolar random sample-and-hold signal (0 to 1). Deterministic.
Parameters:
freq(Number) — sampling rate in periods per cycle
Returns: Signal — a unipolar sample-and-hold control signal
fn Saw(freq: Number = 1) -> SignalUnipolar sawtooth signal (0 to 1). Ramps up, then resets.
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a unipolar sawtooth control signal
fn Saw2(freq: Number = 1) -> SignalBipolar sawtooth signal (-1 to 1). Ramps up, then resets.
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a bipolar sawtooth control signal
fn Sine(freq: Number = 1) -> SignalUnipolar sine wave signal (0 to 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a unipolar sine control signal
fn Sine2(freq: Number = 1) -> SignalBipolar sine wave signal (-1 to 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a bipolar sine control signal
Square
Section titled “Square”fn Square(freq: Number = 1) -> SignalUnipolar square wave signal (0 or 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a unipolar square control signal
Square2
Section titled “Square2”fn Square2(freq: Number = 1) -> SignalBipolar square wave signal (-1 or 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a bipolar square control signal
fn Tri(freq: Number = 1) -> SignalUnipolar triangle wave signal (0 to 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a unipolar triangle control signal
fn Tri2(freq: Number = 1) -> SignalBipolar triangle wave signal (-1 to 1).
Parameters:
freq(Number) — oscillation rate in periods per cycle
Returns: Signal — a bipolar triangle control signal
automation
Section titled “automation”fn automation(...breakpoints) -> SignalCreates an automation signal with breakpoint-based modulation. Call with breakpoint arrays, or empty for the builder pattern. Supported curves: “linear” (default), “step”, “exp”, “smooth”, “ease-in”, “ease-out”, “ease-in-out”, “ease”, “bezier(x1,y1,x2,y2)”
Example:
automation(#[0, 400], #[4, 2000], #[8, 400, "smooth"]) automation().at(0, 400).at(4, 2000, "smooth").at(8, 400)
Parameters:
breakpoints(Array) — variadic breakpoints, each#[time, value]or#[time, value, curve]; omit for the builder pattern
Returns: Signal — the automation signal (chain .at(...) to add more breakpoints)
hz_to_periods
Section titled “hz_to_periods”fn hz_to_periods(frequency: Number) -> NumberConverts a frequency in Hertz to periods per cycle time.
Parameters:
frequency(Number) — frequency in Hz (positive)
Returns: Number — the equivalent rate in periods per cycle, for use as an oscillator freq
sec_to_periods
Section titled “sec_to_periods”fn sec_to_periods(period: Number) -> NumberConverts a period in seconds to periods per cycle time.
Parameters:
period(Number) — period duration in seconds (positive)
Returns: Number — the equivalent rate in periods per cycle, for use as an oscillator freq
signal
Section titled “signal”fn signal(pattern: Pattern) -> SignalCreates a signal from a pattern.
Parameters:
pattern(Pattern) — pattern to convert to a control signal
Returns: Signal — emits the MIDI note number of the active event (0 during rests)
signal_ramp
Section titled “signal_ramp”fn signal_ramp(start: Number, end: Number, duration: Number) -> SignalCreates a linear ramp signal that clamps at its endpoints. Holds at start before t=0 and at end after t=duration.
Parameters:
start(Number) — value at the start of the rampend(Number) — value at the end of the rampduration(Number) — ramp length in cycles (optional, defaults to 1)
Returns: Signal — the clamped linear ramp signal