01 Structure
otype 1language version, first line of a file (optional)
def name [| arg ...]define a function (a brick when it has no menu); body indented below
const name valuefile-level constant (number, string, list or condition), global to all files
menu "level" >> "action"place of the function in the popup (levels up to 6 chars, action up to 10)
page "label"list the function on the SCRIPT page of the unit (label 1..8 characters; no argument, at most 6 params, no card/slot/pool op)
param name default min maxa setting editable on the unit, read like a constant
confirm ["text"]ask YES/NO before running (implied by destructive operations)
02 Modifiers
if c: ...run the line or block when c is true
elif c: ...after an if/elif at the same indentation: another condition
else: ...after an if/elif at the same indentation: the remaining case
l a b: ...loop i from a to b inclusive; bounds are constant (never a variable)
each: ...for each step of the context, in order (i = the step)
prob p: ...run with p percent probability
every n: ...run once every n passes over this line
skip n: ...run every time except once every n passes
del n: ...reserved: run n steps later (not available yet)
03 Flow
breakleave the innermost loop (l or each)
stopleave the function
ret [v]leave the function, giving the value v (the function then works as a value)
Keyword arguments
allkeyword argument: every track or every step (trk all, steps all)
curkeyword argument: the current track (trk cur)
deepkeyword argument of dir: include subfolders
04 Variables
alocal to one run of the function, 0 at start; assignable
blocal to one run of the function, 0 at start; assignable
clocal to one run of the function, 0 at start; assignable
dlocal to one run of the function, 0 at start; assignable
xglobal, shared, kept from one press to the next, 0 at boot; assignable
yglobal, shared, kept from one press to the next, 0 at boot; assignable
zglobal, shared, kept from one press to the next, 0 at boot; assignable
tglobal, shared, kept from one press to the next, 0 at boot; assignable
icounter of the innermost loop (l, each); read-only, 0 outside loops
jcounter of the loop above the innermost one; read-only, 0 outside loops
05 State
flipalternates 0, 1, 0... on each read; flip x sets it
ocounter, moves by o.inc after each read, between o.min and o.max; o x sets it
o.min xlowest value of o (default 0) statement
o.max xhighest value of o (default 63) statement
o.wrap x1 = o wraps around at its limits (default), 0 = it stops statement
o.inc xstep of o after each read (default 1) statement
drunkrandom walk: moves by -1, 0 or +1 on each read; drunk x sets it
drunk.min xlowest value of drunk (default 0) statement
drunk.max xhighest value of drunk (default 127) statement
drunk.wrap x1 = drunk wraps around at its limits, 0 = it stops (default) statement
06 Maths
add x y+add x and y
sub x y-subtract y from x
mul x y*multiply x by y
div x y/divide x by y (0 if y is 0)
mod x yremainder of x / y, never negative (0 if y is 0)
min x ythe smaller of x and y
max x ythe larger of x and y
abs xabsolute value of x
neg xx with its sign flipped
lim x lo hiclamp x into lo..hi
wrap x lo hiwrap x around into lo..hi
07 Logic
not x1 if x is 0, else 0
eq x y==1 if x equals y
ne x y!=1 if x differs from y
lt x y<1 if x is less than y
gt x y>1 if x is greater than y
le x y<=1 if x is less than or equal to y
ge x y>=1 if x is greater than or equal to y
and x y1 if x and y are both true (both are evaluated)
or x y1 if x or y is true (both are evaluated)
xor x y1 if exactly one of x and y is true
ez x1 if x is 0
nz x1 if x is not 0
Lists and values
? c a ba if c is true, else b (only the chosen one is evaluated)
at list ii-th element of a list (1..n, clamped)
len listnumber of elements of a list
onthe value 1
offthe value 0
08 Randomness
rnd nrandom number 0..n-1
rrand a brandom number a..b inclusive
tossrandom 0 or 1
chance p1 with p percent probability, else 0
pick listrandom element of a list
09 Rhythm
er k n s1 if step s plays in a Euclidean rhythm of k hits over n steps
er.r k n r slike er, with the rhythm rotated by r steps
dr.v c svelocity 0..127 of curve c at step s (16 steps, repeats): 0 flat, 1 beats, 2 off-beats, 3 ramp up, 4 ramp down, 5 eighths, 6 tresillo, 7 swell; another c reads 0
10 Context
trk.curthe current track number
step.curthe current step number
trk t...act on tracks t... (or cur, or all)
steps all|a b|predact on all steps, steps a..b, or the steps matching a predicate (has.trig)
step sact on step s only
seed nreproducible randomness from here on: seeds all five streams
rand.seed nseed the random stream of rnd, rrand and pick only
toss.seed nseed the random stream of toss and chance only
prob.seed nseed the random stream of the prob modifier only
drunk.seed nseed the random stream of drunk only
file.seed nseed the random stream of file.rnd, file.pick and slots.rnd only
11 Trigs
pat.lenlength of the current pattern
has.trig s1 if step s has a trig predicate
is.empty s1 if step s has no trig and no lock predicate
tr.add sadd a trig on step s (a one-shot or trigless trig becomes red; keeps its locks)
tr.del◌ sremove the trig on step s (and its locks, sample lock, condition)
tr.flip◌ stoggle the trig on step s (removal as tr.del)
tr.clr◌remove every trig of the current steps (as tr.del) destructive
tl.add sadd a trigless lock trig on step s
tl.fill pfill the current steps with trigless locks, p percent of them
12 Trig word
cond.set◌ s cset the trig condition of step s (skipped if the step has no trig)
cond.rnd◌ c drandom trig conditions between c and d on the current steps (those with a trig)
micro.set s xset the micro-timing offset x of step s (skipped if the step has no trig)
micro.rnd xrandom micro-timing up to x on the current steps (those with a trig)
ratch◌ s xset x retriggers on step s (skipped if the step has no trig)
13 Locks and parameters
pb nflat parameter number of the n-th parameter of the pb page
lfo nflat parameter number of the n-th parameter of the lfo page
amp nflat parameter number of the n-th parameter of the amp page
fx1 nflat parameter number of the n-th parameter of the fx1 page
fx2 nflat parameter number of the n-th parameter of the fx2 page
amp.atkparameter number of amp ATK
amp.holdparameter number of amp HOLD
amp.relparameter number of amp REL
amp.volparameter number of amp VOL
amp.balparameter number of amp BAL
amp.xvolparameter number of amp XVOL
lfo.spd1parameter number of lfo SPD1
lfo.spd2parameter number of lfo SPD2
lfo.spd3parameter number of lfo SPD3
lfo.dep1parameter number of lfo DEP1
lfo.dep2parameter number of lfo DEP2
lfo.dep3parameter number of lfo DEP3
has.lock s1 if step s has a parameter lock predicate
has.smp s1 if step s has a sample lock predicate
pl.set s p vlock parameter p to value v on step s (skipped if the step has no trig)
pl.get s pthe lock of parameter p on step s
pl.del s premove the lock of parameter p on step s
pl.rnd prandomise parameter p on the current steps (those with a trig)
pl.vary◌ p xvary the locks of parameter p by up to x percent (steps with a trig)
pl.clrremove every parameter lock of the current steps destructive
smp.set s nlock slot n as the sample of step s (skipped if the step has no trig)
smp.get sthe sample slot locked on step s (0 if none)
smp.del sremove the sample lock of step s
smp.rnd n mrandom sample locks from slots n..m on the current steps (those with a trig)
smp.clrremove every sample lock of the current steps destructive
14 Part
trk.type tmachine type of track t
par.set p vset parameter p of the part to v (clamped to its range; refused if the part disables it)
lfo.rndrandomise the LFOs of the part: speeds, depths, destinations (on the fx pages), waveforms
lfo.dest x paim lfo x at parameter p
fx.rndpick a random effect in fx1 and fx2 (never none)
fx.set x ychoose entry y of the effect list of slot x (0 = none, then as listed on the unit)
scn.genscene 1 blank, scenes 2..16 random locks on the lfo and fx pages
scn.clrunlock all 16 scenes of the track destructive
trk.initreset the track's sound: fx, slot, parameters; not its trigs, locks or machine type destructive
trk.slot◌ nassign slot n to the current track's machine
tempo◌ xset the tempo to x BPM
15 Card
dir str [deep]list the files of a card folder (deep: with subfolders) statement
ext wav|aif|aiff|aifc|...keep only files with these extensions statement
match str...keep only files whose name matches a pattern (* wildcard) statement
file.nnumber of files in the list
file.rndindex of a random file of the list
file.pickindex of a random file, never the same twice until all are used
file.at iindex of the i-th file of the list
16 Slots
slot.load n fload file f of the list into slot n
slot.free n1 if slot n is free
slot.firstfreenumber of the first free slot (0 if none)
slot.clr nempty slot n destructive
slots.noneempty the working set of slots
slots.add nadd slot n to the working set
slots.rnda random slot of the working set
pool.fillfill the free slots from the card pool
pool.shuffleshuffle the samples among the slots
pool.clrempty every slot of the pool destructive
pool.rndfill the free slots with random files of the list, never the same file twice
17 Screen
msg strshow a message on screen statement