Function Reference

Math

Arithmetic and conversion, over numbers and over signals alike.

abs(x)

number → number

Magnitude, dropping the sign.

amp(amplitude)

number → number

Linear amplitude to decibels, the inverse of db: 1.amp is 0. The amplitude must be above zero.

bpm(beats)

number → number

Beats per minute to bars per second. The beat is the quarter note; how many of them make a bar is the project's time signature, so 120.bpm is 0.5 in 4/4 — the default tempo — and 0.667 in 3/4, where the bar is shorter.

ceil(x)

number → number

Smallest whole number at or above x.

cents(hz, cents)

number → number

Detune a frequency by cents, 1/100 of a semitone: 440.cents(-14) flattens A4 slightly.

db(decibels)

number → number

Decibels to a linear amplitude: 0.db is 1, -6.db is about 0.5. Use it to write gains the way you hear them.

floor(x)

number → number

Largest whole number at or below x.

h2m(hz)

number → number

Frequency in hertz to MIDI note number, the inverse of m2h: 440.h2m is 69. The result may be fractional.

log2(x)

number → number

Base-2 logarithm. x must be above zero.

m2h(note)

number → number

MIDI note number to frequency in hertz: 69.m2h is 440. Equal temperament, A4 = 440 Hz.

norm(x, lo, hi)

number → number

Map 0..1 onto lo..hi. Values outside 0..1 extrapolate; clamp first if you do not want that.

oct(note, octaves)

number → number

Transpose a MIDI note by whole octaves: 60.oct(-1) is 48.

pow(x, exponent)

number → number

x raised to a power: 2.pow(10) is 1024. Good for exponential curve shaping.

round(x)

number → number

Nearest whole number, halves away from zero.

scale(note, scale)

number → number

Snap a MIDI note to the nearest tone of a scale, given as semitone offsets within an octave: 61.scale([0, 2, 4, 5, 7, 9, 11]) is 60. Ties snap down.

sqrt(x)

number → number

Square root. x must not be negative.

wrap(x, lo, hi)

number → number

Fold a number back into lo..hi, wrapping around rather than clamping. Useful for modular pitch.

19names in Math. All categories.