OTYPE1.1214 opsscripting for the octatrackoctatrack

1.1 · 16 operator categories

214 operators, grouped by what you want to change. Syntax keywords and variables are listed separately. The machine profile includes every operator.

CategoryOpsUse
Language46Maths, random values, rhythm and script state between presses.
Context11Choose the tracks and steps a script acts on; control random seeds.
Pattern6Current pattern/bank, pattern length, transitions and tempo.
Parts4Choose, save and reload parts; keep each part's sound distinct.
Trigs26Audio trigs, trigless locks/trigs, one-shots, swing and slide trigs.
Timing11Conditions, microtiming, retriggers and FILL.
Track12Machine, assigned sample slot, LEVEL, CUE, project mute, swing and track init.
Pages30Sound parameters and SETUP: Playback, AMP, LFO, Designer and FX.
Locks7Parameter locks on individual steps.
Sample locks6Sample-slot locks on individual steps.
Scenes5Set, read, copy and clear individual scenes and their locks.
Files7List and filter the files of a card folder, then pick from the list.
Slots12Load, test, clear and swap Static and Flex slots; keep a working set of slot numbers. Bulk jobs are loops: see the cookbook.
Audio5Save audio takes, create sliced chains and normalize files.
Live scripts25Live scripts: schedule voice playback, read sequencer and MIDI events, link scripts.
Screen1The text of the end box: msg replaces DONE with strings and numbers.

Reading a line

One command per line, in prefix notation: an operation takes the values that follow it, which may be operations themselves. Modifiers before : repeat or condition the rest of the line; a line ending with : opens an indented block.

# for i = 1..16, 35 % chance: a trig on step i
l 1 16: prob 35: tr.add i
# = pl.set (i) (amp.vol) (rrand 70 127)
pl.set i amp.vol rrand 70 127
# a block: the steps that have a trig
steps has.trig:
  each: cond.set i 50%

Dotted names (tr.add) are the OT's API; your own functions use underscores and take their arguments after |. OType ignores case; this reference writes everything in lowercase. Text between quotes keeps its case.

Read a setting with x tempo; write it with tempo 137. Numbered settings keep their number: x lfo.wave 1 / lfo.wave 1 18. Renamed operators have no compatibility aliases.

Names such as amp.vol and lfo.spd 1 identify a parameter. Read/write its value with par.get/par.set, or use pl.* for a step lock. SETUP operations such as lfo.mult 1 3 write the setting directly.

Argument letters

sstep, 1..64
ttrack, 1..8
nobject / parameter index or sample slot; bounds in each entry
pparameter, 0..29 — written pb 1, lfo 3, amp.vol, fx1 2…
vvalue, clamped to the parameter's range
ctrig condition: 50%, 1:4, fill, !pre… or a number
k n rhits, length, rotation of a rhythm
ffile number in the current dir list
x y znumbers (16-bit, saturating)
1. One gesture: a few random trigs on the current track
def sprinkle
  menu "TRIGS" >> "SPRINKLE"
  l 1 16: prob 25: tr.add i
2. Euclidean hats with accents, on track 3
def euclid_hats
  menu "DRUMS" >> "EUCLID HH"
  param hits 5 1 16
  trk 3:
    tr.clr
    l 1 16: if er hits 16 i: tr.add i
    steps has.trig:
      each: pl.set i amp.vol dr.v 0 i
3. A/B: one press a variation, the next press the reference
def ab_locks
  menu "LOCKS" >> "A/B FX"
  seed ? flip 7 0
  steps has.trig:
    pl.rnd fx1 1
    cond.rnd 50% 99%
4. Bricks: functions with arguments, called by name
def two_euclids
  menu "DRUMS" >> "2 EUCLIDS"
  euclid_on | 1 5 0
  euclid_on | 2 3 4

def euclid_on | track hits rot
  trk track:
    l 1 16: if er.r hits 16 rot i: tr.add i

01 Structure

otype 1
language 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 value
file-level constant (number, string, list or condition), global to all files
menu "level" >> "action"
place of the function in the menu (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)
var name init
persistent variable initialized to init (integer constant) on script load
in clock n: | in note [ch]: | in cc ch n: | in trig t [all]:
event block for periodic clock, incoming MIDI note / CC events, or the sequencer's trigs
launch n
live script: quantize the first wake to the next multiple of n ticks of the grid (96 = a beat)
param name [int] d min max | bool d | option d "a"... | folder "path"
a setting editable on the unit: number in range, bool (yes/no), option (labels) or folder browser
confirm ["text"]
ask YES/NO before running (implied by destructive operations)
input sample
placement header: function acts on the host audio sample context

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

break
leave the innermost loop (l or each)
stop
leave the function
ret [v]
leave the function, giving the value v (the function then works as a value)

Keyword arguments

all
keyword argument: every track or every step (trk all, steps all)
cur
keyword argument: the current track (trk cur)
deep
keyword argument of dir: include subfolders

04 Variables

a
local to one run of the function, 0 at start; assignable
b
local to one run of the function, 0 at start; assignable
c
local to one run of the function, 0 at start; assignable
d
local to one run of the function, 0 at start; assignable
x
global, shared, kept from one press to the next, 0 at boot; assignable
y
global, shared, kept from one press to the next, 0 at boot; assignable
z
global, shared, kept from one press to the next, 0 at boot; assignable
t
global, shared, kept from one press to the next, 0 at boot; assignable
i
counter of the innermost loop (l, each); read-only, 0 outside loops
j
counter of the loop above the innermost one; read-only, 0 outside loops

05 Language

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 y%
remainder of x / y, never negative (0 if y is 0)
min x y
the smaller of x and y
max x y
the larger of x and y
abs x
absolute value of x
neg x
x with its sign flipped
not x
1 if x is 0, else 0
lim x lo hi
clamp x into lo..hi
wrap x lo hi
wrap x around into lo..hi
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 y
1 if x and y are both true (both are evaluated)
or x y
1 if x or y is true (both are evaluated)
xor x y
1 if exactly one of x and y is true
ez x
1 if x is 0
nz x
1 if x is not 0
? c a b
a if c is true, else b (only the chosen one is evaluated)
rnd n
random number 0..n-1
rrand a b
random number a..b inclusive
toss
random 0 or 1
chance p
1 with p percent probability, else 0
pick list
random element of a list
at list i
i-th element of a list (1..n, clamped)
len list
number of elements of a list
on
the value 1
off
the value 0
er k n s
1 if step s plays in a Euclidean rhythm of k hits over n steps
er.r k n r s
like er, with the rhythm rotated by r steps
dr.v c s
velocity 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
flip / flip x
alternates 0, 1, 0... on each read; flip x sets it
o / o x
counter, moves by o.inc after each read, between o.min and o.max; o x sets it
o.min x
lowest value of o (default 0) statement
o.max x
highest value of o (default 63) statement
o.wrap x
1 = o wraps around at its limits (default), 0 = it stops statement
o.inc x
step of o after each read (default 1) statement
drunk / drunk x
random walk: moves by -1, 0 or +1 on each read; drunk x sets it
drunk.min x
lowest value of drunk (default 0) statement
drunk.max x
highest value of drunk (default 127) statement
drunk.wrap x
1 = drunk wraps around at its limits, 0 = it stops (default) statement

06 Context

trk t...
act on tracks t... (or cur, or all)
steps all|a b|pred
act on all steps, steps a..b, or the steps matching a predicate (has.trig)
step s
act on step s only
trk.cur
the current track number
step.cur
the current step number
seed n
reproducible randomness from here on: seeds all five streams
rand.seed n
seed the random stream of rnd, rrand and pick only
toss.seed n
seed the random stream of toss and chance only
prob.seed n
seed the random stream of the prob modifier only
drunk.seed n
seed the random stream of drunk only
file.seed n
seed the random stream of file.rnd, file.pick and slots.rnd only

07 Pattern

pat.len
length of the current pattern
pat.cur◌
active pattern number (1..16)
bank.cur◌
active bank number (1..16)
pat.go◌ p [b]
change to pattern p (1..16) and optional bank b (1..16)
pat.copy a b
copy pattern a (1..16) onto pattern b (1..16) of the current bank, with its undo; the pattern clipboard is untouched destructive
tempo◌ / tempo x
active tempo in BPM; tempo x sets it

08 Parts

part.cur◌
part linked to the current pattern (1..4)
part.go◌ n
link part n (1..4) to the current pattern
part.save◌ [n]
save part n (1..4, or current part) to its buffer
part.reload◌ [n]
reload part n (1..4, or current part) from its buffer (refused if never saved)

09 Trigs

has.trig s
1 if step s has a trig predicate
is.empty s
1 if step s has no trig and no lock predicate
tr.add s
add a trig on step s (a one-shot or trigless trig becomes red; keeps its locks)
tr.del◌ s
remove the trig on step s (and its locks, sample lock, condition)
tr.flip◌ s
toggle the trig on step s (removal as tr.del)
tr.clr◌
remove every trig of the current steps (as tr.del) destructive
tl.add s
add a trigless lock trig on step s
tl.fill p
fill the current steps with trigless locks, p percent of them
tl.del◌ s
remove the trigless lock on step s (mask and locks)
tt.add◌ s
add a trigless trig on step s
tt.del◌ s
remove the trigless trig on step s
os.add◌ s
add a one-shot trig on step s
os.del◌ s
remove the one-shot trig on step s
os.arm◌
rearm one-shot trigs on context tracks
sw.add◌ s
add a swing trig on step s
sw.del◌ s
remove the swing trig on step s
sw.flip◌ s
toggle the swing trig on step s
sl.add◌ s
add a slide trig on step s
sl.del◌ s
remove the slide trig on step s
sl.flip◌ s
toggle the slide trig on step s
rt.add s [src]
add a recorder trig on step s with source mask src (1 AB, 2 CD, 4 internal, 1..7; default 7)
rt.del s
remove the recorder trig on step s (sources, one-shot flag and micro-timing)
rt.clr
remove every recorder trig of the current steps (as rt.del) destructive
rt.src s v
set the source mask v (1 AB, 2 CD, 4 internal, 1..7) of the recorder trig on step s
ro.add s [src]
add a ONE SHOT recorder trig on step s with source mask src (1 AB, 2 CD, 4 internal, 1..7; default 7)
ro.del◌ s
remove the recorder trig on step s, one shot or not (sources, one-shot flag and micro-timing)

10 Timing

cond.set◌ s c
set the trig condition of step s (skipped if the step has no trig)
cond.rnd◌ c d
random trig conditions between c and d on the current steps (those with a trig)
cond.get◌ s
the trig condition on step s (0 if none)
cond.del◌ s
remove the trig condition on step s
micro.set s x
set the micro-timing offset x of step s (skipped if the step has no trig)
micro.rnd x
random micro-timing up to x on the current steps (those with a trig)
micro.get◌ s
the micro-timing offset on step s (-23..+23)
ratch.set◌ s x
set x retriggers on step s (skipped if the step has no trig)
ratch.get◌ s
the number of retriggers (TRIG COUNT) on step s (1..8)
fill◌ / fill x
fill mode status: 1 = active, 0 = off; fill x sets it
fill.once◌
arm fill mode for one pattern cycle

11 Track

trk.swing◌ / trk.swing x
swing amount 50..80 percent on context tracks; trk.swing x sets it
trk.type◌ / trk.type x
machine type of context track (0 static, 1 flex, 2 thru, 3 neighbor, 4 pickup); trk.type x sets it
trk.slot◌ / trk.slot x
assigned sample slot of context track (1..128); trk.slot n sets it
trk.level◌ / trk.level x
track LEVEL (0..127); trk.level x sets it
trk.cue◌ / trk.cue x
track CUE level (0..127); trk.cue x sets it
trk.mute◌ / trk.mute x
track mute status (1 = muted, 0 = active); trk.mute x sets it
rec.src t n v
set recorder input source n (1 INAB, 2 INCD, 3 SRC3) to stock value v on track t (INAB/INCD 0 - 1 A B/C D 2 A/C 3 B/D 4 A+B/C+D; SRC3 0 - 1..8 T1..T8 9 MAIN 10 CUE)
rec.len t v
set recorder length RLEN to v steps (1..63) or max (64) on track t
rec.trig t v
set the recorder TRIG mode of track t: 0 ONE, 1 ONE-2, 2 HOLD
rec.loop t v
set recorder LOOP of track t: 0 off, 1 on (the captured sample loops when played back)
rec.arm t [src]
start recording on track t now, sources src (1 AB, 2 CD, 4 SRC3, 1..7; default 7); QREC is honoured statement
trk.init
reset the track's sound: fx, slot, parameters; not its trigs, locks or machine type destructive

12 Pages

Reading / writing parameters

par.get◌ p
the base value of parameter p in the part
par.set p v
set parameter p of the part to v (clamped to its range; refused if the part disables it)
par.min◌ p
the lowest value parameter p accepts on the context track (refused if the part disables it)
par.max◌ p
the highest value parameter p accepts on the context track (refused if the part disables it)

Playback

pb n
flat parameter number of the n-th parameter of the pb page
pb.setup◌ n / pb.setup n x
setting n (1..6) of the PLAYBACK SETUP page; pb.setup n v sets it

AMP

amp n
flat parameter number of the n-th parameter of the amp page
amp.atk
parameter number of amp ATK
amp.hold
parameter number of amp HOLD
amp.rel
parameter number of amp REL
amp.vol
parameter number of amp VOL
amp.bal
parameter number of amp BAL
amp.xvol
parameter number of amp XVOL
amp.setup◌ n / amp.setup n x
setting n (1..6) of the amp SETUP page; amp.setup n v sets it

LFO

lfo n
flat parameter number of the n-th parameter of the lfo page
lfo.spd n
flat parameter number of lfo n speed (n=1..3)
lfo.dep n
flat parameter number of lfo n depth (n=1..3)
lfo.dest x p
aim lfo x (1..3) at parameter p
lfo.wave◌ n / lfo.wave n x
waveform of lfo n (1..3); lfo.wave n w sets it
lfo.mult◌ n / lfo.mult n x
multiplier of lfo n (1..3, 0..6 for 1x..64x); lfo.mult n v sets it
lfo.trig◌ n / lfo.trig n x
trig mode of lfo n (1..3, 0..7); lfo.trig n m sets it

LFO designer

lfod.set◌ s v
set value (-64..63) of step s (1..16) in lfo designer
lfod.get◌ s
value of step s (1..16) in lfo designer (-64..63)
lfod.interp◌ s x
set interpolation of step s (1..16) in lfo designer (0 off, 1 on)

FX1 / FX2

fx1 n
flat parameter number of the n-th parameter of the fx1 page
fx2 n
flat parameter number of the n-th parameter of the fx2 page
fx.type x y
choose effect type y of FX block x (1 or 2)
fx.count◌ x
number of entries in the effect chooser of FX block x (1 or 2), NONE included
fx1.setup◌ n / fx1.setup n x
setting n (1..6) of the fx1 SETUP page; fx1.setup n v sets it
fx2.setup◌ n / fx2.setup n x
setting n (1..6) of the fx2 SETUP page; fx2.setup n v sets it

13 Locks

has.lock s
1 if step s has a parameter lock predicate
pl.set s p v
lock parameter p to value v on step s (skipped if the step has no trig)
pl.get s p
the lock of parameter p on step s
pl.del s p
remove the lock of parameter p on step s
pl.rnd p
randomise parameter p on the current steps (those with a trig)
pl.vary◌ p x
vary the locks of parameter p by up to x percent (steps with a trig)
pl.clr
remove every parameter lock of the current steps destructive

14 Sample locks

has.smp s
1 if step s has a sample lock predicate
smp.set s n
lock slot n as the sample of step s (skipped if the step has no trig)
smp.get s
the sample slot locked on step s (0 if none)
smp.del s
remove the sample lock of step s
smp.rnd n m
random sample locks from slots n..m on the current steps (those with a trig)
smp.clr
remove every sample lock of the current steps destructive

15 Scenes

scn.set◌ n p v
lock parameter p to value v on scene n (1..16)
scn.get◌ n p
the lock of parameter p on scene n (1..16)
scn.del◌ n p
remove the lock of parameter p on scene n (1..16)
scn.clr [n]
unlock all scenes or scene n (1..16) of the track destructive
scn.copy◌ a b
copy locks from scene a to scene b (1..16)

16 Files

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.len
number of files in the list
file.rnd
index of a random file of the list
file.pick
index of a random file, never the same twice until all are used
file.at i
index of the i-th file of the list

17 Slots

static.load n f
load file f of the list into Static slot n
static.free n
1 if Static slot n is free
static.firstfree
number of the first free Static slot (0 if none)
static.clr n
empty Static slot n destructive
static.swap◌ a b
swap the samples of Static slots a and b (an empty slot swaps too; a = b does nothing)
slots.clr
empty the working set of slots
slots.add n
add slot n to the working set
slots.rnd
a random slot of the working set
flex.load◌ n f
load file f of the list into Flex slot n
flex.free◌ n
1 if Flex slot n is free, 0 if occupied
flex.firstfree◌
number of the first free Flex slot (0 if none); recorder buffers are not counted (experimental)
flex.del◌ n
empty Flex slot n and give its RAM back (stop FIRST while the sequencer plays, if the slot is occupied; experimental) destructive

18 Audio

src.save◌
save the active source sample to disk; the file list then holds only this file (experimental) destructive statement
cat.clr◌
clear the concatenation file list
cat.add◌ f
add file f to the concatenation list
cat.save◌ name
write concatenated audio files and .ot slices as name.wav; the file list then holds only this file (experimental; a very large folder is slow to read on the unit itself, allow time) destructive statement
norm◌ f db
normalize file f to target db (-12..0) in its .ot attributes (experimental; a very large folder is slow to read on the unit itself, allow time)

19 Live scripts

play t
schedule track t to play at the current block's tick of the live script statement
seq.run◌
1 if sequencer is running, 0 if stopped
seq.step◌ t
current playing step of track t (1..64)
seq.mute◌ t
1 if track t is muted, 0 if active
nx.smp◌ n
lock Static sample slot n (1..128) on the next play hit of this live script statement
nx.pl◌ p v
lock parameter p (0..29) to v (clamped to p's range) on the next play hit of this live script statement
note.num
note number of the current note event (0..127)
note.vel
velocity of the current note event (0..127)
note.ch
MIDI channel of the current note event (1..16)
cc.num
controller number of the current CC event (0..127)
cc.val
value of the current CC event (0..127)
cc.ch
MIDI channel of the current CC event (1..16)
trig.step
step (1..64) of the current trig event
trig.hit
1 if the current trig plays, 0 if its condition failed or the track is muted
trig.val
value (0..255) carried by a script trig (coming in 1.2)
midi.cc ch n
last value (0..127) of controller n received on MIDI channel ch (0 if none since power on)
midi.note ch
last note number (0..127) received on MIDI channel ch (0 if none since power on)
midi.vel ch
velocity of the last note received on MIDI channel ch (0 if none since power on)
send.note ch n vel dur
send MIDI note on channel ch (1..16), note n (0..127), velocity vel (0..127), duration dur (>= 1 clock ticks) statement
send.cc ch n v
send MIDI Control Change on channel ch (1..16), cc n (0..127), value v (0..127) statement
send.prog ch p
send MIDI Program Change on channel ch (1..16), program p (0..127) statement
send.nrpn ch p v
send NRPN p (0..16383) = v (0..16383) on channel ch (1..16) as CC 99, 98, 6, 38; either all four go out or none statement
gate n
emit a gate on output n (1..4) at the current block's tick; the live scripts whose `in gate NAME n` names this one run in the same pass statement
out n v
publish value v on output n (1..4), held until it changes; `cv NAME n` reads it statement
cv name n
the value published on output n (1..4) by the running script named NAME (0 if it is not running)

20 Screen

msg◌ item...
end box text instead of DONE: strings and numbers (decimal), space-separated; the last msg of the run is shown statement