Grammar
Every production of BeatScript, drawn from grammar.ebnf, the language's one grammar. Read a diagram left to right along the line: a rounded box is text written as it is, a square box is another production (tap it to go there), a dashed box is a kind of token (a name, a number, a note). The grammar is held to the parser both ways: every example program is a sentence of it, and every sentence it writes is a program the parser reads. 153 productions, 29 kinds of token.
Programs and lines
program
program = { line } ;
line
a comment is "#" to the end of the line; it is not a token
line = [ statement ] NEWLINE ; (* a comment is "#" to the end of the line; it is not a token *)
statement
statement = setting | headed | let | def | repeat | section | arrange | arrange_block | start | launch | import | end | loop
| evolve | wire | assert | sample | cue | use | set | station ;
Settings
setting
setting = "tempo" tempo
| "swing" arith
| "key" KEY ; (* a setting reads no input: it is the program's own *)
Used by statement
tempo
tempo 126 tempo 100 -> 130 over 8 bars exp
tempo = arith [ "->" arith "over" dur [ shape ] ] ; (* tempo 126 tempo 100 -> 130 over 8 bars exp *)
Lines: when, where, what
headed
headed = "deck" deck ":" parts [ guard ]
| "at" pos [ "for" dur ] ":" "deck" deck ":" parts [ guard ] (* a placed part, in a section *)
| [ timing ":" ] "row" ":" "clip" NAME { cparam } [ cguard ] (* an audio placement on the loop row *)
| [ timing ":" ] [ target ":" ] control [ cguard ]
| [ timing ":" ] "control" ":" ( engine | do | duck | mix ) [ cguard ] (* the control deck *)
| [ timing ":" ] ( invoke | duck | mix ) [ cguard ] ; (* a def's call, a duck and a mix name their decks themselves *)
Used by statement
timing
timing = when [ "for" dur ] | "for" dur ;
Used by headed
cparam
cparam = "crop" "=" arith ".." arith (* source beats: crop=32..64 *)
| "gain" "=" arith
| "fade" "=" ( "off" | "beat" | "bar" | time )
| "route" "=" "vocoder" [ ":" INT ] ; (* the vocoder's modulator; vocoder:2 .. 4 *)
Used by headed
when
when = "every" dur [ "from" ( arith | pos ) ] (* every 16 bars every 2 beats every 4 bars from 8 *)
| "on" "phrase" (* every 8 bars: a phrase *)
| "on" "next" "bar"
| "on" "next" "phrase" [ "8" | "16" | "32" ]
| "at" pos (* once, on that place of the program *)
| "after" NAME (* once, where that section ends *)
| "before" NAME dur ; (* once, that long ahead of that section *)
Used by timing
dur
4 bars 1/2 bar 2 beats
dur = arith ( "bar" | "bars" | "beat" | "beats" ) ; (* 4 bars 1/2 bar 2 beats *)
pos
bar 16 bar 16 beat 3 a beat is 0 to 3
pos = "bar" arith [ "beat" arith ] ; (* bar 16 bar 16 beat 3 a beat is 0 to 3 *)
guard
kept where it holds
guard = "when" expr ; (* kept where it holds *)
Used by headed
cguard
a control line's guard may read an input
cguard = "when" cexpr ; (* a control line's guard may read an input *)
Used by headed
target
target = "deck" deck | "master" ;
Used by headed
deck
PARAM: in a def body, filled in when it is called
deck = "A" | "B" | PARAM ; (* PARAM: in a def body, filled in when it is called *)
control
control = action | engine | do | sing ;
Used by headed
Parts
parts
only after "deck X:" and with no time word
parts = pitem { "|" pitem } ; (* only after "deck X:" and with no time word *)
Used by headed
pitem
pitem = part (* each item between `|` has a part in it *)
| "stack" "(" pargs ")" (* over parts: `stack` is `|` *)
| "then" "(" pargs ")" ; (* over parts: the per-bar alternation <p q> *)
pargs
pargs = { pexpr "," } pitem { "," pexpr } ;
Used by pitem
pexpr
silence: the unit of both
pexpr = pitem | "silence" ; (* silence: the unit of both *)
Used by pargs
part
part = role [ "/" INT ] pattern { param } (* hihat/12 x x ~ x : a cycle of 12 sixteenths *)
| role ref { param } ; (* bass seed(techno, 42)[17..24]: a generated part's bars; bass <cid>.drop: a stored program's *)
Used by pitem
role
role = "kick" | "snare" | "hihat" | "clap" (* drum parts: a hit plays the drum's note *)
| "bass" | "melody" | "harmony" | "arp" ; (* tonal parts: a hit plays the key's root *)
Used by partactionseedstoredgen_parambindingformtrackruleducksingsubject
param
param = pname "=" pvalue (* vel=70..100 oct=2 len=3 inst=sub-bass glide=60 *)
| "voice-lead" [ "=" ( "on" | "off" ) ] ; (* a switch, on when it is bare *)
Used by part
pname
pname = "vel" | "oct" | "len" | "inst" | "seed" | "kit" | "sound" | "route" (* velocity, octave, length, voice, its generators' seed, a drum kit, a sound, where it plays *)
| "glide" | "decay" | "pitch-drop" (* tonal, an 808: glide= decay= ms, pitch-drop= 1 to 24 semitones *)
| "cutoff" | "res" | "env" | "accent" | "drive" ; (* the acid voice's knobs: cutoff= Hz 20 to 12000, the rest 0 to 100; not reserved words *)
Used by param
pvalue
a number, a range drawn per hit, a name; a $name in a body
pvalue = arith [ ".." arith ] | WORD | PARAM ; (* a number, a range drawn per hit, a name; a $name in a body *)
Used by param
Mini-notation: the rhythm of a part
pattern
pattern = term { term } ;
term
x*4 c2! e2^ x:3 x*8?0.7
term = atom [ mark ] [ "*" ( INT | "(" arith ")" ) ] { "?" [ prob ] } [ "~" INT ] ; (* x*4 c2! e2^ x:3 x*8?0.7 *)
Used by pattern
mark
mark = ( "!" | GHOST ) [ "^" ] [ "&" ] [ RATCHET ] | "^" [ "!" | GHOST ] [ "&" ] [ RATCHET ]
| "&" [ RATCHET ] | RATCHET ; (* accent ghost slide flam ratchet, any order *)
atom
atom = "x" (* a hit *)
| "~" (* a rest *)
| NOTE (* c3 f#2 bb4 *)
| INT (* a scale degree of the key: 1 3 5 *)
| "(" arith ")" (* a degree computed: ($i + 1) *)
| degrees (* deg(1 b3 5' ~) *)
| ROMAN [ "/" INT ] (* i VI V7/7: a chord of the key; /3 /5 /7 an inversion *)
| PARAM (* a def's parameter: $chords *)
| "[" pattern { "," pattern } "]" (* a group: squeezed into one slot; commas stack *)
| "<" pattern ">" (* alternation: one term per cycle *)
| choose (* choose [a b c] weights 3 1 1 *)
| call
| NAME ; (* a let pattern's name *)
Used by term
call
e(5,8) markov(0.6, shift=2) arp(am7, up) chord(am) maybe(p, 0.5)
call = NAME "(" [ arg { "," arg } ] ")" ; (* e(5,8) markov(0.6, shift=2) arp(am7, up) chord(am) maybe(p, 0.5) *)
arg
arg = arith | KEY | CHORD | ROMAN [ "/" INT ] | NAME | NAME "=" ( arith | WORD ) | "[" pattern "]" | degrees | call | PARAM ;
Used by call
Degrees, Roman numerals, chance
degrees
one slot, its terms squeezed into it like [..]
degrees = "deg" "(" dstack ")" ; (* one slot, its terms squeezed into it like [..] *)
dstack
dstack = dseq { "," dseq } ;
dseq
dseq = dterm { dterm } ;
dterm
dterm = dleaf [ mark ] [ "*" INT ] | "~" | "x" | "[" dstack "]" | "<" dseq ">" | "(" ( dterm | arith ) ")" ;
dleaf
5' an octave up, 1, down; b3 flat, #4 sharp
dleaf = ( INT | SDEG ) { "'" } { "," } ; (* 5' an octave up, 1, down; b3 flat, #4 sharp *)
Used by dterm
prob
0 to 1, or a percent: ?0.3 ?30% ?(1 / 4)
prob = NUMBER | "(" arith ")" ; (* 0 to 1, or a percent: ?0.3 ?30% ?(1 / 4) *)
Used by term
choose
one weight for each option
choose = "choose" "[" pattern "]" "weights" weight { weight } [ "seed=" INT ] ; (* one weight for each option *)
Used by atom
weight
weight = NUMBER | "(" arith ")" ;
Used by choose
Control: what the mix does
action
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 (* deck X: / master: level *)
| "load" SPEC (* deck X: *)
| "play" | "stop" | "sync" | "mute" | "unmute"
| ( "mute" | "unmute" | "solo" ) ( STEM | role ) (* deck X: a stem (solo mutes the other three), or one part by its role [booth] *)
| "loop" ( arith "beats" | "off" ) (* deck X: a slip loop, `for` lets go [booth] *)
| "jump" ( arith ( "beats" | "bars" ) | NAME "." NAME ) ; (* deck X: a beat jump, back when negative; or to a cue point [booth] *)
Used by control
STEM
a net deck's: its drum roles, bass, the melody (the lead), the rest
STEM = "drums" | "bass" | "vocals" | "other" ; (* a net deck's: its drum roles, bass, the melody (the lead), the rest *)
Used by action
engine
engine = "crossfader" change (* no target, or control: *)
| "tempo" tempo (* at bar 16: tempo 128 -> 140 over 4 bars *)
| "swap" "pairs" [ "with" MOVE ] (* the booth's: the desktop app plays these *)
| "move" MOVE "on" deck [ span ]
| "load" "pair" SPEC [ "group" INT ]
| "queue" ( "play" | "pause" | "stop" | "next" | "loop" | "jump" INT | "add" WORD )
| MACRO NAME ( "on" deck [ span ] | span "on" deck ) ; (* macro riser on A over 8 bars: the DJ macro catalogue, by id; MACRO is macro or macro@1 *)
change
change = value (* a plain value *)
| value "->" value span [ shape ] (* a ramp: 2k -> 8k over 8 bars exp *)
| lfo ; (* a value that keeps moving *)
span
span = "over" dur ;
value
a control's value may read inputs: 200 + knob(3) * 7800
value = carith ; (* a control's value may read inputs: 200 + knob(3) * 7800 *)
MOVE
MOVE = "filter_exit" | "echo_out" | "loop_roll" | "bass_swap" | "phrase_sync" | "vocoder_handoff" ;
Used by engine
SPEC
dnb:2602 acid-bass
SPEC = NAME ":" INT | NAME ; (* dnb:2602 acid-bass *)
do
the control registry: noun, verb; SUGAR: a noun said with no do (vocoder, freeze, wheel ...)
do = ( "do" WORD | SUGAR ) [ WORD ] { STRING } { NAME "=" doval } [ span [ shape ] ] ; (* the control registry: noun, verb; SUGAR: a noun said with no `do` (vocoder, freeze, wheel ...) *)
doval
doval = arith [ "->" arith ] | WORD | STRING | "[" [ doval { "," doval } ] "]" | lfo ;
Shapes and lfo
shape
shape = "linear" | "exp" | "log" | "s-curve" | "step" INT ;
lfo
lfo sine 2 bars center=3k depth=1k
lfo = "lfo" wave dur { "depth=" value | "center=" value | "phase=" NUMBER } [ span ] ; (* lfo sine 2 bars center=3k depth=1k *)
wave
wave = "sine" | "tri" | "square" | "saw" ;
Used by lfo
Arithmetic and guards
arith
worked out once, when the program is read, over exact rationals
arith = sum ; (* worked out once, when the program is read, over exact rationals *)
Used by settingtempocparamwhendurpospvaluetermatomargdtermprobweightactiondovalprimaryletmixitem
sum
sum = product { ( "+" | "-" ) product } ;
product
"/" is exact; "%" is Euclidean
product = unary { ( "*" | "/" | "%" ) unary } ; (* "/" is exact; "%" is Euclidean *)
Used by sum
unary
unary = [ "-" ] primary ;
Used by product
primary
primary = NUMBER | PARAM | "(" arith ")" | ( "min" | "max" ) "(" arith { "," arith } ")" ;
Used by unary
carith
arithmetic that may read inputs: only in a control
carith = csum ; (* arithmetic that may read inputs: only in a control *)
csum
csum = cproduct { ( "+" | "-" ) cproduct } ;
cproduct
cproduct = cunary { ( "*" | "/" | "%" ) cunary } ;
Used by csum
cunary
cunary = [ "-" ] cprimary ;
Used by cproduct
cprimary
cprimary = NUMBER | PARAM | "(" carith ")" | ( "min" | "max" ) "(" carith { "," carith } ")" | input ;
Used by cunary
expr
a guard: kept when it is true
expr = or ; (* a guard: kept when it is true *)
Used by guard
or
or = and { "or" and } ;
Used by expr
and
and = not { "and" not } ;
Used by or
not
not = [ "not" ] compare ;
Used by and
compare
words compare with == and != only
compare = operand [ cmp operand ] ; (* words compare with == and != only *)
Used by not
operand
operand = sum | WORD ;
Used by compare
cexpr
a control line's guard
cexpr = cor ; (* a control line's guard *)
Used by cguard
cor
cor = cand { "or" cand } ;
Used by cexpr
cand
cand = cnot { "and" cnot } ;
Used by cor
cnot
cnot = [ "not" ] ccompare ;
Used by cand
ccompare
ccompare = coperand [ cmp coperand ] ;
Used by cnot
coperand
coperand = csum | WORD ;
Used by ccompare
cmp
cmp = "==" | "!=" | "<" | "<=" | ">" | ">=" ;
input
input = "knob" "(" INT ")" | "pad" "(" INT ")" | "fader" "(" deck ")" (* performed: only in a control value or guard *)
| "held" "(" "key" ")" | "held" "(" PITCH ")" ; (* PITCH: a note with its octave, c4 *)
Used by cprimary
Structure: lets, defs, sections, the arrangement
let
one token is a value; more tokens are a pattern
let = "let" NAME "=" ( sexpr | arith | ref | TOKEN { TOKEN } ) ; (* one token is a value; more tokens are a pattern *)
Used by statement
def
def = "def" NAME "(" [ NAME { "," NAME } ] ")"
[ "in" ":" type { "," type } ] [ "out" ":" type { "," type } ]
"{" { def_line } "}" ; (* $NAME inside, filled in when it is called *)
Used by statement
def_line
a def's body line; emit says what an out port carries
def_line = [ statement | emit ] NEWLINE ; (* a def's body line; `emit` says what an out port carries *)
Used by def
invoke
a def's call
invoke = NAME "(" [ tokens { "," tokens } ] ")" ; (* a def's call *)
Used by headed
tokens
tokens = TOKEN { TOKEN } ;
repeat
the count is written out, 1 to 64
repeat = "repeat" INT [ "every" INT "bars" ] "{" { body_line } "}" ; (* the count is written out, 1 to 64 *)
Used by statement
body_line
a repeat's body line: $i is the pass, 0 up
body_line = [ statement ] NEWLINE ; (* a repeat's body line: $i is the pass, 0 up *)
Used by repeat
section
section = "section" NAME INT "bars" "{" { line } "}" (* 1 to 256 bars; a `key` may open the body *)
| "section" NAME "from" ref ; (* section intro from seed(techno, 42)[1..8] section hook from <cid>.drop *)
Used by statement
arrange
arrange = "arrange" sexpr { sexpr }
| "arrange" NAME ":" sexpr { sexpr } [ arr_end ] (* with a NAME it is one of several arrangements *)
| "arrange" "from" ( seed | template ) (* the whole of a generated track: arrange from seed(techno, 42), or of a phrase: arrange from template(deep-house, @tempest_such_stuff) *)
| "arrange" "from" gen ; (* the whole program a generator call prints: arrange from gen@2 techno seed=42 *)
Used by statement
arr_end
only after a NAME: see "Several arrangements"
arr_end = "then" NAME | "loop" [ INT ] | "end" ; (* only after a NAME: see "Several arrangements" *)
Used by arrangearrange_block
start
the named arrangement that plays first; default the first written
start = "start" NAME ; (* the named arrangement that plays first; default the first written *)
Used by statement
launch
a hit of the pad brings the scene, a section or an arrangement, in on that bar line: 8 bars by default
launch = "launch" NAME "on" "pad" "(" INT ")" [ "next" ( "bar" | "phrase" [ "8" | "16" | "32" ] ) ] ; (* a hit of the pad brings the scene, a section or an arrangement, in on that bar line: 8 bars by default *)
Used by statement
sexpr
sexpr = NAME (* a section, or a let that names a composition *)
| "silence" (* the empty section *)
| "stack" "(" sexpr { "," sexpr } ")" (* at the same time *)
| "then" "(" sexpr { "," sexpr } ")" ; (* one after another *)
end
a song ends after its last section by default
end = "end" [ "at" "bar" INT | "after" NAME ] ; (* a song ends after its last section by default *)
Used by statement
loop
a song starts again at its end
loop = "loop" ; (* a song starts again at its end *)
Used by statement
Arrange mutations
arrange_block
arrange_block = "arrange" "{" { arr_gap } NAME { arr_gap | NAME } "}" [ block_end ] (* at least one section; see "Arrange mutations" *)
| "arrange" NAME ":" "{" { arr_gap } NAME { arr_gap | NAME } "}" [ arr_end ] ; (* a named arrangement with mutations *)
Used by statement
arr_gap
a mutation runs to the end of its line
arr_gap = NEWLINE | "," | mutation NEWLINE ; (* a mutation runs to the end of its line *)
Used by arrange_block
mutation
~ from here on, @ the next section only; ~3: every 3rd pass
mutation = ( "~" | "@" ) [ INT ] ( switch | mut_target mut_op { "|" mut_op } { "," mut_target mut_op { "|" mut_op } } ) ; (* ~ from here on, @ the next section only; ~3: every 3rd pass *)
Used by arr_gap
switch
the control deck's lines fire or not: all of them, or one call's (~ control freeze off); a line of its own
switch = "control" [ NAME ] ( "on" | "off" ) ; (* the control deck's lines fire or not: all of them, or one call's (~ control freeze off); a line of its own *)
Used by mutation
mut_target
a let pattern, or a glob: acid_*
mut_target = GLOB | NAME ; (* a let pattern, or a glob: acid_* *)
Used by mutation
mut_op
rot 2 thin 0.1 oct -1 morph b 0.5 jux rev: the operators of "Arrange mutations"
mut_op = NAME { NUMBER | "-" NUMBER | NAME } ; (* rot 2 thin 0.1 oct -1 morph b 0.5 jux rev: the operators of "Arrange mutations" *)
Used by mutation
block_end
default end; loop N: 1 to 256 passes, then a coda
block_end = "end" | "loop" | "loop" INT [ "then" { NAME } "end" ] ; (* default end; loop N: 1 to 256 passes, then a coda *)
Used by arrange_block
Start from a seed
ref
music from elsewhere, written out as BeatScript before the program is read
ref = seed | gen | stored ; (* music from elsewhere, written out as BeatScript before the program is read *)
seed
a track of the beats generator: genre, seed; a part, bars from 1; SEED is seed (seeds v1) or seed@2 (v2: with its genre's swing)
seed = SEED "(" NAME "," INT [ "," structure ] ")" [ "." role ] [ "[" INT [ ".." INT ] "]" ] ; (* a track of the beats generator: genre, seed; a part, bars from 1; SEED is seed (seeds v1) or seed@2 (v2: with its genre's swing) *)
stored
a saved program's section or part, by its CID: <cid>.drop <cid>.drop.bass; a bare <cid> is a program with no sections [host]
stored = CID [ "." NAME ] [ "." role ] ; (* a saved program's section or part, by its CID: <cid>.drop <cid>.drop.bass; a bare <cid> is a program with no sections [host] *)
Used by refsourceuse_source
gen
gen@2 techno seed=42 section=drop part=bass: the seeded generator, called; GEN is gen@2 or a bare gen [host]
gen = GEN NAME "seed" "=" ( INT | NAME ) { gen_param } ; (* gen@2 techno seed=42 section=drop part=bass: the seeded generator, called; GEN is gen@2 or a bare gen [host] *)
gen_param
gen_param = "bpm" "=" NUMBER | "key" "=" KEY | "length" "=" ( "short" | "standard" | "long" ) | "section" "=" NAME | "part" "=" role ;
Used by gen
structure
the generator's song structures; standard is the default
structure = "standard" | "loop" | "minimal" | "extended" ; (* the generator's song structures; standard is the default *)
Used by seed
Phrase templates
template
a template's name and a phrase, a phrasebook id or words in quotes (NAME: one a use phrase line named): the phrase is the vocal line of a track; then a form's roles
template = "template" "(" NAME "," ( PHRASE | STRING | NAME ) { "," binding } ")" ; (* a template's name and a phrase, a phrasebook id or words in quotes (NAME: one a `use phrase` line named): the phrase is the vocal line of a track; then a form's roles *)
Used by arrangeuse_source
binding
a role of the form and what fills it: ground=gen@1 dubstep seed=54876 part=bass; one part of a seed role: a.bass=[d2 ~ a1 ~]; a form's number: delay=6 interval=-12
binding = NAME [ "." role ] "=" ( source | [ "-" ] INT ) ; (* a role of the form and what fills it: ground=gen@1 dubstep seed=54876 part=bass; one part of a seed role: a.bass=[d2 ~ a1 ~]; a form's number: delay=6 interval=-12 *)
Used by templateformuse_source
source
an engine call; a public-domain theme by id (ode_to_joy); notes; another template, or one section of it; a stored program's part or sections; a stored set's track
source = gen | NAME | notes | form | stored | track ; (* an engine call; a public-domain theme by id (ode_to_joy); notes; another template, or one section of it; a stored program's part or sections; a stored set's track *)
Used by binding
notes
a bar, or bars one after another
notes = "[" pattern "]" | "<" "[" pattern "]" { "[" pattern "]" } ">" ; (* a bar, or bars one after another *)
Used by source
form
a form inside another takes no phrase: forms nest 3 deep; .both is one of its sections, .both.arp that section's part
form = "template" "(" NAME { "," binding } ")" [ "." NAME [ "." role ] ] ; (* a form inside another takes no phrase: forms nest 3 deep; .both is one of its sections, .both.arp that section's part *)
Used by source
track
a stored set's track by number: <cid>.track2, its section <cid>.track2.drop, its part <cid>.track2.drop.bass [host]
track = CID "." NAME [ "." NAME ] [ "." role ] ; (* a stored set's track by number: <cid>.track2, its section <cid>.track2.drop, its part <cid>.track2.drop.bass [host] *)
Used by source
Evolving
evolve
a rule a line; the bound last
evolve = "evolve" "every" INT "bars" "{" { NEWLINE } { rule NEWLINE { NEWLINE } } [ bound NEWLINE { NEWLINE } ] "}" ; (* a rule a line; the bound last *)
Used by statement
rule
rule = ( role | "deck" deck ) ":" op { "|" op } [ "when" "gen" [ "%" INT ] cmp INT ] ;
Used by evolve
op
seed= on thin and fill
op = ( "rotate" | "transpose" | "octave" | "invert" | "reverse" | "thin" | "fill" | "slow" | "fast" ) { NUMBER | "<" NUMBER { NUMBER } ">" } [ "seed=" INT ] ; (* seed= on thin and fill *)
Used by rule
bound
bound = "stop" "when" "gen" ( "==" | ">=" | ">" ) INT | "for" INT "gens" ;
Used by evolve
Typed ports
type
type = "chords" | "key" | "bass" | "melody" | "drums" | "rhythm" | "bars" | "tempo" | "pattern" ;
emit
a line of a def body: what an out port carries
emit = "emit" [ type | "out" ] tokens ; (* a line of a def body: what an out port carries *)
Used by def_line
wire
at the top: wire changes.out -> walker.chords
wire = "wire" NAME "." port "->" NAME "." port ; (* at the top: wire changes.out -> walker.chords *)
Used by statement
port
port = type | "in" | "out" ;
Used by wire
Mix moves and sung lyrics
duck
duck = "duck" deck "under" deck "." role db { "attack=" time | "release=" time } ;
Used by headed
mix
in a section: put back where the section ends
mix = "mix" "{" { NEWLINE } mixitem { ( "," | NEWLINE ) { NEWLINE } mixitem } { NEWLINE } "}" ; (* in a section: put back where the section ends *)
Used by headed
mixitem
mixitem = deck "level" arith | deck "eq" band arith [ "db" ] | "master" "level" arith | deck "pan" arith ;
Used by mix
band
band = "low" | "mid" | "high" ;
Used by mixitem
db
glued: 6db
db = DECIMAL "db" ; (* glued: 6db *)
Used by duck
time
glued: 5ms
time = DECIMAL ( "ms" | "s" ) ; (* glued: 5ms *)
sing
a tonal role; PHRASE: a phrasebook id, @hands_up; NAME: a phrase a use phrase line named
sing = "sing" ( lyric | PHRASE | NAME ) "on" role { "bars=" INT | "key=" KEY | "voice=" NAME } ; (* a tonal role; PHRASE: a phrasebook id, @hands_up; NAME: a phrase a `use phrase` line named *)
Used by control
lyric
its text is lyric_text; docs/beatscript/phonemes.md
lyric = STRING ; (* its text is lyric_text; docs/beatscript/phonemes.md *)
Used by sing
lyric_text
"/" and a space is a phrase break; "/" and a phoneme opens an escape, to the next "/" (with none, a break too); a word touching "=" before an escape is its label, kept and not sung: jingle=/j ii ng g uh l/
lyric_text = { TEXT | "/" SPACE | escape } [ "/" { TEXT } ] ; (* "/" and a space is a phrase break; "/" and a phoneme opens an escape, to the next "/" (with none, a break too); a word touching "=" before an escape is its label, kept and not sung: jingle=/j ii ng g uh l/ *)
escape
PHONES (beatscript-v1): 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, "_" a rest, "-" cuts a word, ":" holds a vowel one more note, "!" accents it
escape = "/" PHONES "/" ; (* PHONES (beatscript-v1): 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, "_" a rest, "-" cuts a word, ":" holds a vowel one more note, "!" accents it *)
Used by lyric_text
Assertions
assert
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 ] (* assert never A.snare beside A.snare assert never B during sing: refused where it is false *)
| subject "ends" "on" INT [ "in" NAME ] ) ; (* assert bass ends on 1: the lowest note of its last onset is that degree of the key *)
Used by statement
subject
sing: the vocal; a deck; A.snare; bass on both decks
subject = "sing" | ldeck | [ ldeck "." ] role ; (* sing: the vocal; a deck; A.snare; bass on both decks *)
Used by assert
clock
3m30s 90s 500ms
clock = DECIMAL "m" [ DECIMAL "s" ] | DECIMAL "s" | DECIMAL "ms" ; (* 3m30s 90s 500ms *)
Used by assert
leveldeck
a level read: it names a deck
leveldeck = { lfactor lop } ldeck { lop lfactor } ; (* a level read: it names a deck *)
Used by assert
lop
lop = "+" | "-" | "*" | "/" ;
Used by leveldeck
ldeck
ldeck = "A" | "B" | "master" ;
levelexpr
arithmetic over the words A, B and master: their levels
levelexpr = lterm { ( "+" | "-" ) lterm } ; (* arithmetic over the words A, B and master: their levels *)
lterm
lterm = lfactor { ( "*" | "/" ) lfactor } ;
Used by levelexpr
lfactor
lfactor = NUMBER | ldeck | "(" levelexpr ")" ;
Sets, samples, imports
set
programs of programs: an item a line
set = "set" "{" { NEWLINE } { ( set_play | set_mix | set_next ) NEWLINE { NEWLINE } } "}" ; (* programs of programs: an item a line *)
Used by statement
set_play
a saved program, its CID in the canonical text, or a generator call [host]
set_play = "play" ( NAME | STRING | gen ) [ "until" until_when ] ; (* a saved program, its CID in the canonical text, or a generator call [host] *)
Used by set
set_next
the track before it, a generator call, with its seed stepped [host]
set_next = "next" step [ "until" until_when ] ; (* the track before it, a generator call, with its seed stepped [host] *)
Used by set
until_when
a time, a bar of the track, a section's start or end
until_when = TIME | "bar" INT | NAME | "after" NAME ; (* a time, a bar of the track, a section's start or end *)
set_mix
set_mix = "mix" INT ( "bar" | "bars" ) "with" TRANSITION [ "," "tempo" NUMBER "->" NUMBER ] ;
Used by set
TIME
units glued: 20m 90s 1h 3m30s
TIME = DECIMAL UNIT { DECIMAL UNIT } ; (* units glued: 20m 90s 1h 3m30s *)
Used by until_when
TRANSITION
TRANSITION = "crossfade" | "filter_exit" | "echo_out" | "cut" ;
Used by set_mix
Radio: stations
station
endless and deterministic: position N is always the same track [host]
station = "station" "{" { NEWLINE } { station_line NEWLINE { NEWLINE } } "}" ; (* endless and deterministic: position N is always the same track [host] *)
Used by statement
station_line
the first track's call; the step from a track to the next; the forms in turn
station_line = "from" gen | "next" step | "forms" NAME { NAME } ; (* the first track's call; the step from a track to the next; the forms in turn *)
Used by station
step
seed=+1 counts on; seed=~ draws from a hash of the track before's CID
step = "seed" "=" ( "+" INT | "~" ) ; (* seed=+1 counts on; seed=~ draws from a hash of the track before's CID *)
Used by set_nextstation_line
import
a snippet's name in quotes, or its CID [host]
import = "import" ( NAME | STRING ) ; (* a snippet's name in quotes, or its CID [host] *)
Used by statement
sample
sample = "sample" NAME "from" STRING [ "license" license ] [ "else" NAME ]
| "loop" STRING "as" NAME [ "else" NAME ] ; (* restricted sounds: a local file, an Apple Loop by its hash *)
Used by statement
license
license = "cc0" | "cc-by" | "all-rights-reserved" | "restricted-private" ;
Used by sample
cue
cue tune.drop at bar 32 beat 2: a named place in a sample [booth]
cue = "cue" NAME "." NAME "at" pos ; (* cue tune.drop at bar 32 beat 2: a named place in a sample [booth] *)
Used by statement
use
use = "use" "restricted" (* the program is private: it may use restricted assets *)
| "use" use_source "as" NAME ; (* a name for a source, written out where it is used (docs/beatscript/ext-roles.md) *)
Used by statement
use_source
use_source = stored (* <cid>.drop: a section; <cid>.drop.bass: a line; <cid>: a source for a role *)
| gen (* gen@2 techno seed=42 section=drop, part=bass: a section or a line; with neither, a source for a role *)
| "template" "(" NAME { "," binding } ")" [ "." NAME ] (* template(passacaglia, ground=...): a form, for a role; .ground: a canned section of it *)
| template "." NAME (* template(deep-house, @tempest_such_stuff).night: a canned section, sung with that phrase *)
| "theme" NAME (* a theme of the public-domain library: a line, in the program's key *)
| "phrase" PHRASE (* a phrasebook line: a phrase, for sing and template *)
| GENRE NAME "." NAME ; (* genre@1 techno.drop: a section of a genre template, frozen *)
Used by use
Token classes
The upper-case names that are no production: the kinds of token the lexer reads. A comment (# to the end of the line) is not a token.
- NEWLINE
- the end of a line
- NAME
- a name: a word (
acid,sub-bass,drop2) - WORD
- any word
- INT
- a whole number written out (
4,16) - NUMBER
- a number:
0.7,2k(2000),50%(0.5),-3 - DECIMAL
- a number with no mark, before a glued unit:
6in6db,0.5in0.5s - STRING
- a string in double quotes
- PARAM
- a parameter of a def or a repeat:
$i,$bars - NOTE
- a note: a letter a to g, a sharp
#or flatb, an octave:c3,f#2,bb4,a - PITCH
- a note with its octave:
c4,f#2 - KEY
- a key: a tonic and
m, or a tonic,:and a mode, written as one word:am,c,f#m,d:dorian - CHORD
- a chord symbol: a tonic and a quality, one word:
am7,cmaj7,g7,dsus4,f#m7b5 - ROMAN
- a Roman numeral of the key, one word:
i,VI,ii°,V7,bVII,#iv - SDEG
- a written degree inside deg( ):
b3,#4 - UNIT
- a unit glued to the number before it:
db,ms,s,m,h,hz - TOKEN
- any token but the end of a line
- GLOB
- a name with
*written into it, all one:acid_*,*_a - SUGAR
- a control noun said with no
do:vocoder,freeze,wheel,trick,mashup... - PHRASE
- a phrase of the phrasebook,
@and its id, one word:@hands_up,@feel_the_bass, or a line of verse or speech from before 1929:@tempest_such_stuff - GHOST
- a
.touching the step before it, with no word after it: a ghost note (x.,c3.) - RATCHET
- a
:touching the step before it and a whole number touching it: a ratchet (x:3) - CID
- a saved program's CID:
zand 20 to 80 base58 characters (z4EBG9jDzsE2UHZfL8A9ouKLU5vUJsgHC8nVaTE7sWjci7PCukZ) - GEN
- the generator's call word, its version glued with
@(gen@2,gen@1), or a baregen(gen@2) - MACRO
- the macro line's word, its version glued with
@(macro@1), or a baremacro(macro@1) - SEED
- a seed's head, touching its
(:seed(seeds v1), or its version glued with@(seed@2,seed@1) - GENRE
- the genre templates' word, its version glued with
@(genre@1), or a baregenre(genre@1) - TEXT
- in a lyric: one character that is not
/, a space and a letter alike - SPACE
- in a lyric: one space, tab or line break
- PHONES
- in a lyric: what is between an escape's slashes, from something that is not a space to the next
/: phonemes of the set with a space or-between them (h ii,w ee - aa: r)