OType Command Reference
OTYPEv1 draft131 opsOT1

a scripting language for ot1 · ot cfw · roadmap

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.

l 1 16: prob 35: tr.add i        # for i = 1..16, 35 % chance: a trig on step i
pl.set i amp.vol rrand 70 127    # = pl.set (i) (amp.vol) (rrand 70 127)
steps has.trig:                  # block: the steps that have a 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.

Argument letters

sstep, 1..64
ttrack, 1..8
nsample slot, 1..128
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 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 max
a 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

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 State

flip
alternates 0, 1, 0... on each read; flip x sets it
o
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
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 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 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
lim x lo hi
clamp x into lo..hi
wrap x lo hi
wrap x around into lo..hi

07 Logic

not x
1 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 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

Lists and values

? c a b
a if c is true, else b (only the chosen one is evaluated)
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

08 Randomness

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

09 Rhythm

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

10 Context

trk.cur
the current track number
step.cur
the current step number
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
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

11 Trigs

pat.len
length of the current pattern
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

12 Trig word

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)
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)
ratch◌ s x
set x retriggers on step s (skipped if the step has no trig)

13 Locks and parameters

pb n
flat parameter number of the n-th parameter of the pb page
lfo n
flat parameter number of the n-th parameter of the lfo page
amp n
flat parameter number of the n-th parameter of the amp page
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
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
lfo.spd1
parameter number of lfo SPD1
lfo.spd2
parameter number of lfo SPD2
lfo.spd3
parameter number of lfo SPD3
lfo.dep1
parameter number of lfo DEP1
lfo.dep2
parameter number of lfo DEP2
lfo.dep3
parameter number of lfo DEP3
has.lock s
1 if step s has a parameter lock predicate
has.smp s
1 if step s has a sample 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
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

14 Part

trk.type t
machine type of track t
par.set p v
set parameter p of the part to v (clamped to its range; refused if the part disables it)
lfo.rnd
randomise the LFOs of the part: speeds, depths, destinations (on the fx pages), waveforms
lfo.dest x p
aim lfo x at parameter p
fx.rnd
pick a random effect in fx1 and fx2 (never none)
fx.set x y
choose entry y of the effect list of slot x (0 = none, then as listed on the unit)
scn.gen
scene 1 blank, scenes 2..16 random locks on the lfo and fx pages
scn.clr
unlock all 16 scenes of the track destructive
trk.init
reset the track's sound: fx, slot, parameters; not its trigs, locks or machine type destructive
trk.slot◌ n
assign slot n to the current track's machine
tempo◌ x
set 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.n
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

16 Slots

slot.load n f
load file f of the list into slot n
slot.free n
1 if slot n is free
slot.firstfree
number of the first free slot (0 if none)
slot.clr n
empty slot n destructive
slots.none
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
pool.fill
fill the free slots from the card pool
pool.shuffle
shuffle the samples among the slots
pool.clr
empty every slot of the pool destructive
pool.rnd
fill the free slots with random files of the list, never the same file twice

17 Screen

msg str
show a message on screen statement