Skip to main content

Language Reference

A BeatBax song is a sequence of top-level statements: chip and tempo, instruments, named patterns and sequences, channel wiring, then play. This reference documents the grammar as implemented by @beatbax/engine — not planned or retired design notes.

For a narrative walkthrough that builds one Game Boy song, start with the Tutorial.

Boxes are clickable topics. Rounded pills are statement keywords; square boxes are related syntax groups.

Program / Statement

Pattern RHS

Sequence RHS

Channel RHS

Pattern atom

Statement map

TopicCovers
Global directiveschip, bpm, volume, stepsPerBar, scale, song, play, comments
NotesPitches, durations, rests, sustains
Patternspat / shorthand, groups, inline inst, effect suffixes
Sequencesseq, refs, repeats, groups
Channelschannel N => …, speed=, lock=
Instrumentsinst, macros, note mapping, subpat, imports
ModifiersColon-chained sequence/pattern transforms
EffectsNamed effect presets and inline <…>
ExportDeprecated in-file export format "path"
AppendixStatement index, reserved words, lexical notes

Typical song shape

song name "Example"
chip gameboy
bpm 120

inst lead type=pulse1 duty=50 env=gb:12,down,1
pat phrase = C5 E5 G5 C6
seq lead_seq = phrase*2

channel 1 => inst lead seq lead_seq
play

Order is flexible in the parser, but most songs follow metadata → instruments → patterns/sequences → channels → play.