study 01 of 10
Quickstart
In this study you write a script that places a kick on every beat, check it on the computer, see what it does to a pattern, then run it on the Octatrack. Then you change it twice, to see how quickly an idea becomes a new function.
Write the file
Create a text file named BASICS.OTY and type this in it:
def four_floor
menu "BASICS" >> "FOUR FLOOR"
tr.clr
l 1 16: if eq mod i 4 1: tr.add iOutput · what the simulator prints for $ otype.py run four_floor
four_floor seed 1 (--seed) pattern A01 len 16 (default) track 1
T1 1 5 9 13
X...X...X...X...
X trig ! one-shot o trigless trig - trigless lock l locks only . none
part: tempo 120
cost: 176/224 random draws: rand 0 toss 0 prob 0 drunk 0 file 0Line by line:
def four_floorstarts a function namedfour_floor. Everything indented below it is its body.menu "BASICS" >> "FOUR FLOOR"says where the function appears in the script menu: in the categoryBASICS, under the nameFOUR FLOOR.tr.clrclears the trigs of the track. Names with a dot are the Octatrack's operations:tris the family (trigs),clrthe action.l 1 16: …repeats the rest of the line fori= 1, 2, … 16, the steps of the pattern. On each step,if eq mod i 4 1:asks: is the remainder ofidivided by 4 equal to 1? It is on steps 1, 5, 9 and 13, and theretr.add iplaces a trig.
Do not worry yet about eq mod i 4 1: the next study is about
reading that kind of line. Note the indentation: two spaces here, but any width works, as long as the lines of one
block line up.
Check it
From the OType repository, run the checker on your file. It applies exactly the rules the unit applies when it loads the scripts:
python3 tools/otype.py check -v BASICS.OTY
It answers with one line per function: ok, its menu entry, and its cost, the most work one
run can do (more on this in the last study). A mistake gives the file, the line
and what is wrong instead.
See what it does
The simulator runs a function on a pattern, on the computer, and shows the steps afterwards:
python3 tools/otype.py run four_floor BASICS.OTY
The output under the listing above is what it prints. T1 is track 1: an X is a trig,
a dot an empty step. With --bank you can run the same function on a real bank file copied from your
card; nothing is ever written to it.
Run it on the machine
Copy BASICS.OTY into the folder /SCRIPTS/ at the root of the CF card, put the card
back, and load the scripts (your firmware says how). The unit compiles the file itself: no firmware to rebuild.
Open the script menu (in OT1, press FUNCTION twice), choose BASICS, then FOUR FLOOR.
A box asks YES or NO first: because tr.clr erases trigs, OType asks before any function
that changes the project in a way you might regret. Answer YES, and the current track has its four kicks.
Change it
An eighth-note hat instead: a trig on every odd step. Add a second function to the same file:
def eighths
menu "BASICS" >> "EIGHTHS"
tr.clr
l 1 16: if eq mod i 2 1: tr.add iOutput · what the simulator prints for $ otype.py run eighths
eighths seed 1 (--seed) pattern A01 len 16 (default) track 1
T1 1 5 9 13
X.X.X.X.X.X.X.X.
X trig ! one-shot o trigless trig - trigless lock l locks only . none
part: tempo 120
cost: 192/224 random draws: rand 0 toss 0 prob 0 drunk 0 file 0Now let the player choose the spacing before the function runs. param declares a setting with a
default, a minimum and a maximum; the menu shows it, and the script reads it like a number:
def every_n
menu "BASICS" >> "EVERY N"
param gap 4 1 16
tr.clr
l 1 16: if eq mod i gap 1: tr.add iOutput · what the simulator prints for $ otype.py run every_n
every_n seed 1 (--seed) pattern A01 len 16 (default) track 1
T1 1 5 9 13
X...X...X...X...
X trig ! one-shot o trigless trig - trigless lock l locks only . none
part: tempo 120
cost: 176/224 random draws: rand 0 toss 0 prob 0 drunk 0 file 0Copy the file again and load the scripts: the three functions are in BASICS. That is the whole
loop of working with OType: edit, check, copy, run.
What you learned
def name- starts a function; its body is indented below
menu "CAT" >> "NAME"- lists the function in the script menu
param name default min max- a setting the player edits before the run
tr.clr·tr.add s- clear the trigs · place a trig on step
s l a b:- repeat for
i= a … b if c:- do the rest of the line only if
cis true check·run- check a file, run a function on the computer
Try it
- Move the kicks to the off-beats: steps 3, 7, 11 and 15.
- Give
every_na secondparam,start, that shifts the first trig. - Make a mistake on purpose (remove the
iaftertr.add) and read what the checker says.