#BeatScript cheat sheet
Generated from docs/BEATSCRIPT.md. BeatScript writes a whole track as text: pattern lines become Petri nets on decks A and B, and every other line is a control call. The grammar and rules are authoritative: run check and fix every line:col error before playing.
#The rules in one screen
- A program is lines. A line is blank, a
# comment, or one statement. A line that starts with
|continues the statement above it. - The first line is the version line,
#! beatscript 2; a text without one is BeatScript 1 ("Versions"). - Words are lower case. Deck names are
AandB. Numbers are plain:5,0.7,2k(= 2000),
50%(= 0.5), and wherever the language takes a number it takes arithmetic:tempo 120 + 6,
at bar $i * 2 + 1,kick e($i % 4 + 1, 8). - A statement is
[when:] [target:] body [when guard]. Each head ends in a colon, and they read left to right:
when (every 16 bars), whose (deck A,master), then what; a trailingwhen $i % 2 == 0keeps the line
only where the condition holds. - Time is bars (four beats), and a beat is a quarter of a bar:
over 2 beats,at bar 16 beat 3. Seconds appear
only where a sound or a check needs them (attack=5ms,assert length == 3m30s). A pattern is one cycle (one bar)
long, and its terms share the cycle equally;hihat/12gives a part a cycle of its own. - Text in, same net out: the same program text always gives the same net CIDs and the same program CID. Everything is
total (no recursion, every count written out) and deterministic (chance is a hash of the text and the bar;
nothing reads a clock, a random source or the machine). - A mistake is an error with a line, a column, what was expected and the nearest name; the program is refused whole.
#Grammar (EBNF)
program = { line } ;
line = [ statement ] NEWLINE ;
statement = setting | headed | let | def | repeat | section | arrange | arrange_block | start | launch | end | loop
| evolve | wire | assert | set | station ;
setting = "tempo" tempo
| "swing" arith
| "key" KEY ;
tempo = arith [ "->" arith "over" dur [ shape ] ] ;
headed = "deck" deck ":" parts [ guard ]
| "at" pos [ "for" dur ] ":" "deck" deck ":" parts [ guard ]
| [ timing ":" ] [ target ":" ] control [ cguard ]
| [ timing ":" ] "control" ":" ( engine | do | duck | mix ) [ cguard ] (* the control deck *)
| [ timing ":" ] ( invoke | duck | mix ) [ cguard ] ;
timing = when [ "for" dur ] | "for" dur ;
when = "every" dur [ "from" ( arith | pos ) ]
| "on" "phrase" (* every 8 bars: a phrase *)
| "on" "next" "bar"
| "on" "next" "phrase" [ "8" | "16" | "32" ]
| "at" pos
| "after" NAME
| "before" NAME dur ;
dur = arith ( "bar" | "bars" | "beat" | "beats" ) ;
pos = "bar" arith [ "beat" arith ] ;
guard = "when" expr ; (* kept where it holds *)
cguard = "when" cexpr ;
target = "deck" deck | "master" ;
deck = "A" | "B" | PARAM ;
control = action | engine | do | sing ;
parts = pitem { "|" pitem } ;
pitem = part
| "stack" "(" pargs ")"
| "then" "(" pargs ")" ;
pargs = { pexpr "," } pitem { "," pexpr } ;
pexpr = pitem | "silence" ;
part = role [ "/" INT ] pattern { param }
| role ref { param } ;
role = "kick" | "snare" | "hihat" | "clap"
| "bass" | "melody" | "harmony" | "arp" ;
param = pname "=" pvalue
| "voice-lead" [ "=" ( "on" | "off" ) ] ;
pname = "vel" | "oct" | "len" | "inst" | "seed" | "kit" | "sound" | "route"
| "glide" | "decay" | "pitch-drop"
| "cutoff" | "res" | "env" | "accent" | "drive" ;
pvalue = arith [ ".." arith ] | WORD | PARAM ;
pattern = term { term } ;
term = atom [ mark ] [ "*" ( INT | "(" arith ")" ) ] { "?" [ prob ] } [ "~" INT ] ;
mark = ( "!" | GHOST ) [ "^" ] [ "&" ] [ RATCHET ] | "^" [ "!" | GHOST ] [ "&" ] [ RATCHET ]
| "&" [ RATCHET ] | RATCHET ;
atom = "x" (* a hit *)
| "~" (* a rest *)
| NOTE (* c3 f#2 bb4 *)
| INT
| "(" arith ")"
| degrees (* deg(1 b3 5' ~) *)
| ROMAN [ "/" INT ]
| PARAM
| "[" pattern { "," pattern } "]"
| "<" pattern ">"
| choose
| call
| NAME ; (* a let pattern's name *)
call = NAME "(" [ arg { "," arg } ] ")" ;
arg = arith | KEY | CHORD | ROMAN [ "/" INT ] | NAME | NAME "=" ( arith | WORD ) | "[" pattern "]" | degrees | call | PARAM ;
degrees = "deg" "(" dstack ")" ;
dstack = dseq { "," dseq } ;
dseq = dterm { dterm } ;
dterm = dleaf [ mark ] [ "*" INT ] | "~" | "x" | "[" dstack "]" | "<" dseq ">" | "(" ( dterm | arith ) ")" ;
dleaf = ( INT | SDEG ) { "'" } { "," } ;
prob = NUMBER | "(" arith ")" ;
choose = "choose" "[" pattern "]" "weights" weight { weight } [ "seed=" INT ] ;
weight = NUMBER | "(" arith ")" ;
action = "filter" ( "lp" | "hp" ) change (* hertz: 20 .. 20k *)
| "filter" ( "off" | "open" )
| ( "delay" | "reverb" | "crush" | "drive" | "resonance" ) change (* 0 .. 1: how much *)
| ( "level" | "low" | "mid" | "high" ) change ;
engine = "tempo" tempo
| MACRO NAME ( "on" deck [ span ] | span "on" deck ) ;
change = value (* a plain value *)
| value "->" value span [ shape ]
| lfo ;
span = "over" dur ;
value = carith ;
do = ( "do" WORD | SUGAR ) [ WORD ] { STRING } { NAME "=" doval } [ span [ shape ] ] ;
doval = arith [ "->" arith ] | WORD | STRING | "[" [ doval { "," doval } ] "]" | lfo ;
shape = "linear" | "exp" | "log" | "s-curve" | "step" INT ;
lfo = "lfo" wave dur { "depth=" value | "center=" value | "phase=" NUMBER } [ span ] ;
wave = "sine" | "tri" | "square" | "saw" ;
arith = sum ;
sum = product { ( "+" | "-" ) product } ;
product = unary { ( "*" | "/" | "%" ) unary } ;
unary = [ "-" ] primary ;
primary = NUMBER | PARAM | "(" arith ")" | ( "min" | "max" ) "(" arith { "," arith } ")" ;
carith = csum ;
csum = cproduct { ( "+" | "-" ) cproduct } ;
cproduct = cunary { ( "*" | "/" | "%" ) cunary } ;
cunary = [ "-" ] cprimary ;
cprimary = NUMBER | PARAM | "(" carith ")" | ( "min" | "max" ) "(" carith { "," carith } ")" | input ;
expr = or ;
or = and { "or" and } ;
and = not { "and" not } ;
not = [ "not" ] compare ;
compare = operand [ cmp operand ] ;
operand = sum | WORD ;
cexpr = cor ; (* a control line's guard *)
cor = cand { "or" cand } ;
cand = cnot { "and" cnot } ;
cnot = [ "not" ] ccompare ;
ccompare = coperand [ cmp coperand ] ;
coperand = csum | WORD ;
cmp = "==" | "!=" | "<" | "<=" | ">" | ">=" ;
input = "knob" "(" INT ")" | "pad" "(" INT ")" | "fader" "(" deck ")"
| "held" "(" "key" ")" | "held" "(" PITCH ")" ;
let = "let" NAME "=" ( sexpr | arith | ref | TOKEN { TOKEN } ) ;
def = "def" NAME "(" [ NAME { "," NAME } ] ")"
[ "in" ":" type { "," type } ] [ "out" ":" type { "," type } ]
"{" { def_line } "}" ;
def_line = [ statement | emit ] NEWLINE ;
invoke = NAME "(" [ tokens { "," tokens } ] ")" ; (* a def's call *)
tokens = TOKEN { TOKEN } ;
repeat = "repeat" INT [ "every" INT "bars" ] "{" { body_line } "}" ;
body_line = [ statement ] NEWLINE ;
section = "section" NAME INT "bars" "{" { line } "}"
| "section" NAME "from" ref ;
arrange = "arrange" sexpr { sexpr }
| "arrange" NAME ":" sexpr { sexpr } [ arr_end ]
| "arrange" "from" ( seed | template )
| "arrange" "from" gen ;
arr_end = "then" NAME | "loop" [ INT ] | "end" ;
start = "start" NAME ;
launch = "launch" NAME "on" "pad" "(" INT ")" [ "next" ( "bar" | "phrase" [ "8" | "16" | "32" ] ) ] ;
sexpr = NAME
| "silence" (* the empty section *)
| "stack" "(" sexpr { "," sexpr } ")" (* at the same time *)
| "then" "(" sexpr { "," sexpr } ")" ; (* one after another *)
end = "end" [ "at" "bar" INT | "after" NAME ] ;
loop = "loop" ;
arrange_block = "arrange" "{" { arr_gap } NAME { arr_gap | NAME } "}" [ block_end ]
| "arrange" NAME ":" "{" { arr_gap } NAME { arr_gap | NAME } "}" [ arr_end ] ;
arr_gap = NEWLINE | "," | mutation NEWLINE ;
mutation = ( "~" | "@" ) [ INT ] ( switch | mut_target mut_op { "|" mut_op } { "," mut_target mut_op { "|" mut_op } } ) ;
switch = "control" [ NAME ] ( "on" | "off" ) ;
mut_target = GLOB | NAME ;
mut_op = NAME { NUMBER | "-" NUMBER | NAME } ;
block_end = "end" | "loop" | "loop" INT [ "then" { NAME } "end" ] ;
ref = seed | gen | stored ;
seed = SEED "(" NAME "," INT [ "," structure ] ")" [ "." role ] [ "[" INT [ ".." INT ] "]" ] ;
stored = CID [ "." NAME ] [ "." role ] ;
gen = GEN NAME "seed" "=" ( INT | NAME ) { gen_param } ;
gen_param = "bpm" "=" NUMBER | "key" "=" KEY | "length" "=" ( "short" | "standard" | "long" ) | "section" "=" NAME | "part" "=" role ;
structure = "standard" | "loop" | "minimal" | "extended" ;
template = "template" "(" NAME "," ( PHRASE | STRING | NAME ) { "," binding } ")" ;
binding = NAME [ "." role ] "=" ( source | [ "-" ] INT ) ;
source = gen | NAME | notes | form | stored | track ;
notes = "[" pattern "]" | "<" "[" pattern "]" { "[" pattern "]" } ">" ;
form = "template" "(" NAME { "," binding } ")" [ "." NAME [ "." role ] ] ;
track = CID "." NAME [ "." NAME ] [ "." role ] ;
evolve = "evolve" "every" INT "bars" "{" { NEWLINE } { rule NEWLINE { NEWLINE } } [ bound NEWLINE { NEWLINE } ] "}" ;
rule = ( role | "deck" deck ) ":" op { "|" op } [ "when" "gen" [ "%" INT ] cmp INT ] ;
op = ( "rotate" | "transpose" | "octave" | "invert" | "reverse" | "thin" | "fill" | "slow" | "fast" ) { NUMBER | "<" NUMBER { NUMBER } ">" } [ "seed=" INT ] ; (* seed= on thin and fill *)
bound = "stop" "when" "gen" ( "==" | ">=" | ">" ) INT | "for" INT "gens" ;
type = "chords" | "key" | "bass" | "melody" | "drums" | "rhythm" | "bars" | "tempo" | "pattern" ;
emit = "emit" [ type | "out" ] tokens ;
wire = "wire" NAME "." port "->" NAME "." port ;
port = type | "in" | "out" ;
duck = "duck" deck "under" deck "." role db { "attack=" time | "release=" time } ;
mix = "mix" "{" { NEWLINE } mixitem { ( "," | NEWLINE ) { NEWLINE } mixitem } { NEWLINE } "}" ;
mixitem = deck "level" arith | deck "eq" band arith [ "db" ] | "master" "level" arith | deck "pan" arith ;
band = "low" | "mid" | "high" ;
db = DECIMAL "db" ; (* glued: 6db *)
time = DECIMAL ( "ms" | "s" ) ; (* glued: 5ms *)
sing = "sing" ( lyric | PHRASE | NAME ) "on" role { "bars=" INT | "key=" KEY | "voice=" NAME } ;
lyric = STRING ;
lyric_text = { TEXT | "/" SPACE | escape } [ "/" { TEXT } ] ;
escape = "/" PHONES "/" ;
assert = "assert" ( "ends"
| "period" [ "(" NAME ")" ] cmp INT
| "length" ( ( "==" | "!=" ) clock [ "±" clock ] | ( "<" | "<=" | ">" | ">=" ) clock )
| "level" leveldeck cmp levelexpr [ "in" NAME ]
| "key" ( "==" | "!=" ) KEY [ "in" NAME ]
| "never" subject ( "beside" | "during" ) subject [ "in" NAME ]
| subject "ends" "on" INT [ "in" NAME ] ) ;
subject = "sing" | ldeck | [ ldeck "." ] role ;
clock = DECIMAL "m" [ DECIMAL "s" ] | DECIMAL "s" | DECIMAL "ms" ; (* 3m30s 90s 500ms *)
leveldeck = { lfactor lop } ldeck { lop lfactor } ;
lop = "+" | "-" | "*" | "/" ;
ldeck = "A" | "B" | "master" ;
levelexpr = lterm { ( "+" | "-" ) lterm } ;
lterm = lfactor { ( "*" | "/" ) lfactor } ;
lfactor = NUMBER | ldeck | "(" levelexpr ")" ;
set = "set" "{" { NEWLINE } { ( set_play | set_mix | set_next ) NEWLINE { NEWLINE } } "}" ;
set_play = "play" ( NAME | STRING | gen ) [ "until" until_when ] ;
set_next = "next" step [ "until" until_when ] ;
until_when = TIME | "bar" INT | NAME | "after" NAME ;
set_mix = "mix" INT ( "bar" | "bars" ) "with" TRANSITION [ "," "tempo" NUMBER "->" NUMBER ] ;
TIME = DECIMAL UNIT { DECIMAL UNIT } ;
TRANSITION = "crossfade" | "filter_exit" | "echo_out" | "cut" ;
station = "station" "{" { NEWLINE } { station_line NEWLINE { NEWLINE } } "}" ;
station_line = "from" gen | "next" step | "forms" NAME { NAME } ;
step = "seed" "=" ( "+" INT | "~" ) ;
NAME is a lower-case word (letters, digits, _, and - between letters), WORD any word. INT is a whole number
(arithmetic that comes to one is fine: repeat 2 + 1); NUMBER also takes a fraction and the k / % marks, and
DECIMAL is a number with no mark, before a glued unit (UNIT: 6db, 5ms, 2s, 3m30s, 1h30m; hz after a
filter's cutoff, filter lp 300hz, is the number and nothing else; the hours of 1h are read only after a set's
until). NOTE, PITCH (a note with its octave), KEY, CHORD and ROMAN are pitch words read as one token
(f#2, c4, d:dorian, am7, ii°); SDEG a written degree in deg( ) (b3, #4); PARAM a def's or a
repeat's $name; SUGAR a control noun said without do; STRING a double-quoted string; TOKEN any token; GLOB a
name with * in it; CID a saved program's id; SEED seed or seed@2; GHOST a ghost's . and
RATCHET a ratchet's :N (x. x:3). ± may be written +- after
a unit (3m30s +- 5s). In a lyric, PHONES is an escape's text:
aa ae uh aw eh er ii ee uu oo ay ie oy ow oh p b t d k g f v s z sh zh th dh h m n ng l r w y ch j, - cuts a word, _ rests,
: holds a vowel, ! accents it; / and a space: a phrase break. A phrase's NAME is one use phrase @id as NAME gave;
use theme ode_to_joy as tune names a theme ("Name a source").
#Patterns: mini-notation
kick x ~ x ~ 4 terms: quarter notes, hits on 1 and 3
kick x x x x x x x x 8 terms: eighths
snare ~ x ~ x hits on 2 and 4
hihat x*8 eight hits, one an eighth
hihat [x x] x [x x] x groups: two hits squeezed into one slot
bass c2 ~ [c2 eb2] g2 notes
bass 1 ~ 3 5 scale degrees of the key
bass 1 ($i + 1) 5 a degree computed (inside a repeat or a def)
melody <c4 e4 g4> alternation: one a bar, then round
kick e(5,8) euclid: five hits over eight steps
kick e(3,8,2) the same, rotated by two
harmony [c3,e3,g3] a comma inside [] stacks: three notes at once
hihat x*8?0.7 each of the eight hits kept with chance 0.7 (seeded)
bass choose [c2 e2 g2] weights 3 1 1 one of the three a bar, c2 three times as often
melody deg(1 b3 5' ~) degrees with accidentals and octave marks, one slot
harmony <I V vi IV> Roman numerals: a chord of the key a bar (bare, one a quarter); a section's own `key` re-reads them
hihat/12 x x ~ x a cycle of twelve sixteenths: four terms of three steps, drifting against the bar
bass c2~3 e2 elongate: c2 ~ ~, the step takes three slots
hihat x*8? a bare ? is ?0.5
*nplays its termntimes in its slot (nis 1 to 64, and may be(arithmetic)).<a b>*2isa binside one
bar (the alternation advances twice).- A pattern with an alternation is as many bars long as it needs (the least common multiple of the deck's
alternations, at most 64 bars); the net is that long and loops. A cycle of its own (hihat/12) or chance lengthens
it too ("How long a program can be"). - The grid is sixteenths: a term off it (three or five in a bar) snaps to the nearest step, with a warning
(x x x: steps 0, 5, 11). - A hit plays the drum's note in a drum part, the key's root in the part's octave in a tonal one. A note plays itself, a
degree that step of the key's scale (1the root,8an octave up), a Roman numeral a chord of the key (harmony),
its bass tone (bass,melody) or the chord a note at a time (arp). - Default octaves: bass 2, harmony 3, melody 4, arp 4.
oct=Nsets it.
#Generators
| call | does |
|---|---|
e(k, n) / e(k, n, rot) / euclid(...) |
k hits over n steps, rotated by rot. As a term it takes one slot, so kick e(5,8) is a bar of eight steps and kick x e(3,8) puts the eight steps in the second half. 0 <= k <= n, 1 <= n <= 64 ("Euclidean rhythms and polymeter"). |
markov(key, density) / markov(density) / markov(key, density, seed) |
a Markov melody of one bar in the key's scale. The key is the program's key (or the section's) when left out. density 0..1. Same seed, same notes: the seed is, when left out, taken from the text of the part. |
arp(chord, mode, n) |
the chord's notes one at a time over n steps (default 8) in up, down or updown. Either takes shift=n: its notes n key degrees up (-21..21; up n writes it). |
chord(chord) / chord(chord, octave) |
the chord's notes together. A chord is a symbol (am7) or a numeral (V7). |
choose [a b c] weights 3 1 1 [seed=4] |
one option a bar, picked by a hash, by weight (not a call: it has its own words, "Seeded chance"). |
#Parameters
| param | value | does |
|---|---|---|
vel=90 / vel=70..100 |
1..127 | velocity. A range gives each hit its own, by a hash of its place: the same text, the same velocities. |
oct=2 |
-1..8 | the part's octave. |
len=3 |
1..16 | note length in steps (drums 1, tonal 2). |
inst=sub-bass |
a name | the instrument. |
seed=7 |
a whole number | the seed of the part's generators (and of its chance terms, unless they say their own). |
glide=70 decay=900 pitch-drop=7 |
ms, ms, semitones | tonal: ^ bends into the next note; each note's tail; starts 7 semitones high. On inst=acid-bass a ^ slides without glide= (60 ms) and decay= is its filter's sweep. |
cutoff=400 res=80 env=60 accent=90 drive=20 |
Hz 20..12000, then 0..100 each | tonal, the acid voice's knobs: the filter's floor, its resonance, how far each strike opens it (100 is 6 octaves), how much an accent ! does, how hard the oscillator drives the filter. Defaults 300, 72, 45, 80, 0. On any other voice they are ignored, with a warning. |
voice-lead / voice-lead=off |
on or off | a harmony (or arp) part of chords: each chord after the first is voiced for the least motion from the one before; bare, it is on. |
A range a..b is any value from a to b, only ever for a parameter of a part. A ramp a -> b is
moving from a to b, only for a control change, with over N bars (or beats).
#Settings
tempo 126 (BPM, 40..300), swing 0.1 (0..1), key am. A setting applies to the whole program. key
is the default for notes with no octave, scale degrees, Roman numerals, markov, and the key tag the share carries.
No key: C major. No tempo: the decks keep theirs.
#Control
master: filter lp 2k
deck A: filter hp 400
master: filter off
master: delay 0.4
master: reverb 0.3 / crush 0.5 / drive 0.6
master: level 0.8
deck A: level 0.7 / low 0 / mid / high
duck B under A.kick 6db
mix { A level 0.7, A eq low -3 }
deck B: sing "words" on melody
at bar 16: tempo 128 -> 140 over 4 bars
macro riser on A over 8 bars
#Time words
| word | fires |
|---|---|
| (none) | once, on the first bar line after the statement is added or changed (in a section: on its first bar); a value that names an input (knob(1)) follows it on every bar |
every 16 bars: |
on bars 16, 32, 48 ... (never on bar 0) |
every 2 beats: |
every half bar, from the program's first bar: at 1/2, 1, 1 1/2 ... of a bar (never at 0). The finest is every 1/64 bar |
every 4 bars from 8: |
on bars 8, 12, 16 ... (from takes a bar, a fraction of one, or a position: from bar 3 beat 2) |
on next phrase [8|16|32]: |
once, on the first bar that is a multiple of 8 (or 16, 32) |
at bar 32: |
once, on bar 32 (in a section: bar 0 is its first bar, so at bar 4 is the fifth) |
at bar 16 beat 3: |
once, on the last quarter of bar 16 (beats count from 0: beat 4 is an error, write at bar 17) |
after drop: |
once, on the bar the section drop ends on |
before drop 4 bars: |
once, four bars ahead of the section: the roll that leads into a drop (before drop 2 beats: is a half bar ahead) |
for 4 bars / for 2 beats |
after any of the above: the effect is put back after that long (for 4 bars: alone is now) |
#The whole surface: do
do <noun> [<verb>] [<positional text>] key=value ... [over N bars [shape]]
every 16 bars: freeze phrase bars=2
at bar 8 for 4 bars: trick on deck=A kind=stutter
do vocoder set mix=0 -> 1 over 8 bars
#The wheel
wheel load preset=NAME # an instrument, by its id from `do wheel presets`
wheel key root=C transpose=2 # the key every note is re-wound for: root C, F#3, Bb2 ..., transpose -24..24
wheel sequence notes="C E G B" # the notes the path plays, in order; without notes, the preset's own
wheel motor on=true speed=2 # a cord instrument's motor: on / off, speed in m/s (0..25)
wheel level db=3 # the wheel's level, dB -20..40
wheel play
wheel pause
A wheel line takes a time head like any other (at bar 16: wheel play). The browser engine on beatscript.app plays the
wheel too, the same instrument as the booth: the wheel goes into the master after the decks, so master: filter, reverb
and level reach it.
#Functions and structure
let name = ...at the top. One token (8,c2,am) is a value put in place of every later use of
the name (soat bar late:andbass rootwork, and the canonical text shows the value). More tokens are a
pattern, used asbass kicks, in<a b>alternations, in[a, b]stacks and as the pattern a transform
takes. Arithmetic that is the whole value is a number:let n = 2 * 4is 8 (an earlier scalar may be used in
it:let m = n + 1);let r = 3*2is the number 6, the degree 3 twice islet r = [3 3]. A section expression
names a composition (let verse = stack(groove, wash)). A name cannot be a
word of the language, a note, a chord, a key or a Roman numeral (let kick,let aandlet viare errors).def name(a, b) { ... }is a macro: its body is lines, and$ais where an argument goes. A call
name(x, y)is a line, withat bar N:/after X:/before X N bars:or none. The body is read when it
is called, so an error in it says where in the def and which call. A def that calls itself, directly or
through another def, is an error (ping -> pong -> ping) found before anything runs. A def
may declare a boundary (def walker(oct) in: chords, key out: bass { ... }) and be glued to others withwire:
typed ports, below.repeat N { ... }withNwritten out (1 to 64).repeat 8 every 2 bars { ... }shifts copyiby
i * 2bars;$iand$nare the index and the count, and are put in place before an expression is read
(at bar $i * 2 + 1). Written out, a program is at most 4096 lines ("Bounds on the text"). A def's body may have a
repeatof its own: its$iand$nare the repeat's.whenguards end a line (drop(A, 8) when $i != 0,deck A: kick x ~ x ~ when $i % 4 == 3): the line is kept
in the copies where the condition holds and removed, before it is checked, in the others. They see$i,$nand a
def's$params("Guards", above).section name N bars { ... }andarrange a b c: the song is the sections in that order (a section
may be named twice; withoutarrange, in the order written). A section is 1 to 256 bars, and its body is
statements, one to a line ({ends the line it is on; a block of adeforrepeatmay be on one line, a section's
may not). Lines outside every section apply to the whole
song, a section's own part of the same role wins, and a deck a section does not use is stopped there. After the last
section the last nets play on.sectionandarrangebelong at the top, not inside another block.arrangealso takesstack(...),
then(...)andsilence("Composition: stack and then"). A section may open with akeyof its own and may set a
tempo.
#Ending
| line | does |
|---|---|
end after outro |
where the section outro ends (the song stops there, later sections never play) |
end at bar 64 |
on bar 64 of the song (of the program, with no sections) |
loop |
at the song's end it starts again from the first section, its at lines firing again each lap |
arrange set: drop wubs then close |
a named arrangement that goes on to another one (below) |
arrange set: drop wubs loop |
a named arrangement that repeats itself for ever: the song's lap starts at it, not at the first section |
launch drop on pad(2) |
a hit of pad 2 brings in the section (or arrangement) drop on the next phrase line, where it loops; next bar or next phrase 16 set the line |
arrange close: outro end |
a named arrangement that ends the song |
start set |
the arrangement that plays first (default: the first written) |
#Evolving
section drop 32 bars {
deck B: melody [a4 c5 e5 g5] | bass [a2 ~ e2 ~]
deck A: kick x ~ x ~ | hihat x*8
evolve every 8 bars {
melody: rotate 1 | transpose <0 5 7 0>
hihat: thin 0.1 seed=3
bass: invert when gen % 2 == 1
stop when gen == 3
}
}
| transform | does |
|---|---|
rotate n |
every hit n steps (sixteenths) along its bar, wrapping |
reverse |
the steps of a bar backwards |
transpose n / octave n |
pitches up n semitones / octaves (tonal parts; a drum's note is the drum) |
invert |
pitches turned over about the part's first note (tonal parts) |
thin p [seed=s] |
drops the share p of the hits, picked by a hash of (seed, generation, bar, step, note): the same seed, the same hits |
fill p [seed=s] |
each step of a bar with no hit on it takes, with chance p (a hash of seed, generation, bar and step), a copy of the hits of the step before it that has some; a bar with no hits stays empty |
slow n |
the first 1/n of each bar played over the whole of it: a hit at step s moves to s*n (its length with it), what would fall past the bar's end is gone (n 1 to 16) |
fast n |
each bar played n times in the time of one: a hit at s lands at s/n and again every 16/n steps (n 1, 2, 4, 8 or 16) |
#Pattern transforms
| call | does |
|---|---|
transpose(p, n) / octave(p, n) |
n semitones / octaves up (a hit in a tonal part is its root first) |
reverse(p) / rotate(p, n) |
the steps backwards / moved n steps along |
every(n, p) / every(n, p, q) |
p on every nth bar (the 4th, 8th ...), q (or a rest) on the others |
degrade(p, a) / degrade(p, a, seed) |
drops the share a of the hits: seeded, so the same text is the same hits |
slow(p, n) / fast(p, n) |
p stretched over n bars / played n times a bar |
humanize(p, seed) / humanize(p, seed, amount) |
velocities wander by up to amount (default 10), seeded |
maybe(p, prob) / maybe(p, prob, seed) |
keeps each hit of p with chance prob (0 to 1): p with ?prob on every hit |
rests(p) / rests(p, q) |
a hit on each step where p rests / q kept there |
ply(p, n) |
each step of p n times in its slot (*n on each) |
palindrome(p) |
p, then p backwards: <[p] reverse(p)> |
iter(p, n) |
p a 1/n of its steps later each bar |
off(p, n) / off(p, n, k) |
p and a copy n steps later (k semitones up) |
poly(p, q ...) / poly(n, p, q ...) |
each walked n steps a bar (the first's count when left out), stacked |
Marks touch their step: c2! an accent (velocity +27), x. a ghost (40%), e2^ a slide (held into the next
step; with glide= it bends), x& a flam, x:3 a ratchet (3 hits in the sixteenth, 2 to 8). Not ! with ..
#Arrange mutations
arrange {
intro build drop
~ acid_a rot 2, hoov_a up 3 # from here on
wubs build2
~3 acid_* drift 0.15 # a glob, on every 3rd pass only
peak
@ hoov_b rev # the next section only
@ control off # the control deck: none of its lines fire in the next section
outro
} loop 4 then outro end
| op | does (to the pattern's steps: see The steps below the table) |
|---|---|
rot n / rev / swap / mirror / shuffle |
rotate n steps later / backwards / swap neighbours / the first half, then backwards / a seeded permutation |
thin p / fill p / euclid k |
each sounding step rests with chance p / each rest takes the step before it with chance p / the hits re-spread as k Euclidean hits |
half / double / stutter n |
the first half at half speed / the pattern twice in the bar / the first 1/n of it n times |
ratchet p / swing amt |
a sounding step struck twice with chance p: doubled on the grid (*2) when its step is longer than a sixteenth, else ratcheted inside it (x:2, again x:4, at most x:8), so no hit snaps / every second step later by amt of a step (on the sixteenth grid) |
up n / down n / oct n / invert / drift p |
scale degrees of the key up / down / octaves / turned over about the first note / a step up or down with chance p. A Roman numeral moves by degrees too (in A minor i up 2 is III, the key's own triad there; V7 up 1 is VI7) |
vel n / accent p |
accents on the n strongest steps (vel -n takes n off) / an accent with chance p |
morph b p / xfer b / mask b |
each step becomes b's with chance p / b's rhythm with these notes / rests where b rests |
grow / decay |
one rest filled / one sounding step taken out (seeded; they pile up pass on pass) |
voice n / spread |
each chord [a3,c4,e4] or chord(am7) inverted n times / its every second note an octave up |
jux op |
the pattern stays the left copy, op of it plays hard right (jux rev) |
#Start from a seed
arrange from seed(techno, 42) the whole track
section intro from seed(techno, 42)[1..8] bars 1 to 8 as a section
deck B: bass seed(techno, 42).bass[17..24] inst=fm-bass a part's bars; your params win
let riff = seed(techno, 42).bass[17..20] the same, named (say which part)
arrange from seed@2(jazz, 7) seeds v2: the track, swung
section hook from <cid>.drop a saved program's section (parts, key)
deck B: bass <cid>.drop inst=hoover its part (the line's role; .melody another)
arrange from template(deep-house, @tempest_such_stuff) a phrase as a track
arrange from template(rondo, @hands_up, refrain=ode_to_joy) a form, a role bound: docs/forms.md
#Sung lyrics
Found phrases: pick a line for its meter: https://beatscript.app/docs/found-phrases.md
#Radio: stations
Radio: a station is an endless program, track N always the same: station { } holds from gen@2 techno seed=42
(track 0), next seed=~ (the step) and forms seeded rondo fugue (in turn); MCP station and POST /api/station
give track n, its segue and neighbours; MCP artifact with station makes a page: https://beatscript.app/docs/radio.md
#Sounds
| param | takes | does |
|---|---|---|
inst=wobble-lead |
a voice | the part's instrument. An unknown name is an error with the nearest names; a family word (inst=reese) is accepted with a warning that it plays the generic saw bass, and which voices have a sound of their own. inst=acid-bass (or inst=acid) is a 303: ! accents, ^ slides, cutoff= res= env= accent= drive= turn its knobs |
kit=drums-808 |
a kit | a drum part's kit (set once the net has landed) |
sound=synth:wobble-lead |
own, synth, synth:NAME, inst:NAME |
the role's sound option on the deck, set once the net has landed |
#On beatscript.app
- Everything above checks here;
importand<cid>need the program (a link carries it).samplechecks (a local file needsuse restricted), but a program with either is not public: never stored or rendered: only its inline link. loop, the booth's lines (move,swap pairs,load,sync,queue,crossfader,play,stop,mute) and the sugar nouns (wheel,trick,freeze,vocoder,vocal) check. The browser engine playswheelandmove(every move but aphrase_syncthat steps a seed); it does not playswap pairs,load,sync,queue,macro(renderandlistendo) or the other sugar nouns: the page lists each as "not played here". The grammar above leaves them and the DJ tier out (solo drums,loop 4 beats,jump -8 beats,cue:needs: booth).inst=andkit=take what/api/instrumentslists.- ✦generate (key G): the seeded generator, no model or sign-in;
[]step the seed as it plays.
View source (the raw markdown of this page, for models and scripts)