Skip to content

Signal generators

Graham Wakefield edited this page Apr 27, 2019 · 4 revisions
// sine wave (-1..1) with named properties: "period", "bias", "amp", "phase"
sine(period_in_beats, center_bias, amplitude) 
// sine wave (-1..1) with named properties: "period", "bias", "amp", "phase"
lfo(freq_in_hz, center_bias, amplitude) 
// sine wave (-1..1)
cycle(freq_in_hz)	

// ramp wave (0..1), not bandlimited
beats(period_in_beats) 
// ramp wave (0..1), not bandlimited
phasor(freq_in_hz) 	
// make a ramp run faster or slower. 
// e.g. a rate(phasor(1), 2) produces the same ramp as a phasor(0.5):
rate(ramp, divisor)

// generate noise between -1 and 1
noise()

// accumulates the first argument every sample. 
// nonzero value in 2nd argument will reset to zero
accum(amount, reset)
// samples input when control signal rises above threshold
sah(input_to_sample, control, threshold)

// fades from `from` to `to` over `time` beats
// then replaces the graph with a constant value of `to`
fade(time, from, to)

// convert period_in_beats to a frequency in Hz
btof(period_in_beats) 

// add, sub, multiply, divide, compute remainder, etc:
add(a, b), sub(a, b), mul(a, b), div(a, b)
mod(a, b), absdiff(a, b) 
// reversed-argument forms:
// i.e. same as div(b, a), sub(b, a), mod(b, a)
rdiv(a, b), rsub(a, b), rmod(a, b) 
// number manipulations:
min(a, b), max(a, b) 
abs(a)  // rectifies negative numbers to be positive
sign(a) // returns -1, 0 or 1 depending on sign of input
// round down or round up
floor(a), ceil(a) 
// keep only integer or fractional parts of signal
trunc(a), fract(a) 

// comparators. "true" generates 1, "false" generates 0:
// equal, not-equal
eq(a, b), neq(a, b)
// greater-than, less-than, greater-than-or-equal, less-than-or-equal
gt(a, b), lt(a, b), gte(a, b), lte(a, b) 
// logic operations. 
// any non-zero value is considered "true", zero is "false"
and(a, b), or(a, b)

// trigonometric functions
sin(a), cos(a), tan(a), asin(a), acos(a), atan(a), atan2(b, a)
sinh(a), cosh(a), tanh(a), asinh(a), acosh(a), atanh(a)
// cheaper versions (not as accurate)
fastsin(a), fastcos(a), fasttan(a) 
hypot(a, b) // compute hypoteneuse from two sides
degrees(a), radians(a) // convert rad->deg or deg->rad

// constants:
samplerate(), degtorad()
pi(), twopi(), halfpi(), invpi()
sqrt2(), sqrt1_2()
E(), ln10(), ln2(), log10e(), log2e()

// globals:
time()
Clone this wiki locally