Sequencing
In this section we will look at how BeatBax sequences a song: naming patterns with pat, chaining them with seq, and wiring those sequences to channels. You already know notes and lengths from Notes and lengths, and you have instruments on four Game Boy channels from Instruments. Here we take Tutorial Groove beyond a single looping bar — each part gets a pair of contrasting patterns (for example lead_a and lead_b) played in order through a named sequence.
Patterns
A pattern is a named list of tokens. Its length is simply the sum of those token durations — BeatBax does not require a fixed size.
In practice, keep patterns on different channels the same length so they stay locked when you chain them in sequences. A shared phrase size such as 16 steps is easy to manage; Tutorial Groove uses that throughout.
pat rise = C3:16 # one note held for 16 steps
pat lead_pat = E5 . G5 C6 . G5 E5 . D5 . F5 A5 . G5 . . # sixteen one-step tokens
The optional stepsPerBar (default 4) controls how the editor groups steps into bars for display — it does not affect pattern length or playback.
More pattern syntax
Notes, lengths, rests, and sustains (from Notes and lengths) are enough for simple melodies. Patterns also support grouping and repeats, named drum hits, and mid-pattern instrument switches:
| Form | Meaning |
|---|---|
(C5 E5 G5)*2 | Group notes and repeat the group |
snare, hat | Instrument name as a pattern token (plays that instrument’s default note=) |
inst(name,N) | Temporary instrument override for the next N non-rest hits |
inst(name) | Instrument override for the rest of the pattern |
Note: the count
Nininst(name,N)applies only to notes/sustains — rests (.) do not consume from the count.
Sequences
A sequence (seq) is an ordered playlist of patterns. Where a single pat is one phrase, a seq chains several phrases so a part can vary over time instead of looping the same bar forever.
pat lead_a = E5 . G5 C6 . G5 E5 . D5 . F5 A5 . G5 . .
pat lead_b = C5 . E5 G5 . E5 C5 . A4 . C5 E5 . D5 C5 .
seq lead_seq = lead_a lead_b lead_a lead_b
Here lead_seq plays A, then B, then A, then B. Each name in the list is a pattern reference; BeatBax expands them in order when that sequence is assigned to a channel.
You can also repeat patterns or groups inside a sequence:
| Form | Meaning |
|---|---|
pat*2 | Play that pattern twice |
(a b)*2 | Play a then b, then repeat that pair |
seq lead_seq = lead_a lead_b*2 # A, then B twice
seq drums_seq = (drums_a drums_b)*2 # A B A B
Note: empty sequences (
seq name =with nothing after=) will be treated as errors — everyseqneeds at least one pattern reference.
Channels
A channel line tells BeatBax what to play on one chip voice: which default instrument to use, and which pattern or sequence to run. You need one channel line per voice you want to hear.
channel 1 => inst lead seq lead_seq
Reading left to right:
channel 1— the chip voice (on Game Boy: 1 pulse1, 2 pulse2, 3 wave, 4 noise)inst lead— default instrument for this channelseq lead_seq— what to play (a named sequence, or a singlepat)
Tutorial Groove’s four-channel layout:
| Channel | Typical role | Instrument type |
|---|---|---|
| 1 | Lead | pulse1 |
| 2 | Harmony / counter | pulse2 |
| 3 | Bass | wave |
| 4 | Drums | noise |
Other chips may have fewer or more channels — see Sound Chip Plugins.
Channel syntax variants
You can wire music to a channel in several equivalent ways:
| Form | Example | When to use |
|---|---|---|
| Single pattern | channel 1 => inst lead pat melody | One looping phrase (as in the Instruments section) |
| Inline sequence | channel 1 => inst lead seq pat1 pat2 | Short playlists without a separate seq name |
| Named sequence | seq myseq = pat1 pat2channel 1 => inst lead seq myseq | Clearer when the same playlist is reused or gets long |
Tutorial Groove — arranged
We can now arrange a more complex Tutorial Groove song using this information.
Each part now has two patterns (for example lead_a / lead_b) chained through named sequences.
Every pattern is 16 steps long so the four channels stay locked when phrases chain:
Interactive playback loads in the browser.
song name "Tutorial Groove"
song artist "BeatBax Tutorial"
song description "Built step by step in the BeatBax Game Boy tutorial."
song tags "tutorial, gameboy"
chip gameboy
bpm 140
inst lead type=pulse1 duty=50 env=gb:13,down,1 gm=81
inst harmony type=pulse2 duty=25 env=gb:10,down,2 gm=80
inst bass type=wave volume=100 wave=[0,2,4,6,8,10,12,14,15,14,12,10,8,6,4,2] gm=33
inst kick type=noise gb:width=7 uge_note=C-6 length=16 pitch_env=[0,-2,-4,-6] vol_env=[15,12,8,4]
inst snare type=noise gb:width=7 env=gb:13,down,1 length=16 uge_note=C-7 note=C6 pitch_env=[0,7,0] vol_env=[13,10,6,2]
inst hat type=noise gb:width=15 env=gb:5,down,1 uge_note=C-8 note=C6
pat lead_a = E5 . G5 C6 . G5 E5 . D5 . F5 A5 . G5 . .
pat lead_b = C5 . E5 G5 . E5 C5 . A4 . C5 E5 . D5 C5 .
pat harmony_a = C4:4 E4:4 G4:4 E4:4
pat harmony_b = A3:4 C4:4 F4:4 G4:4
pat bass_a = C3 . . C3 G2 . . G2 A2 . . A2 F2 . G2 .
pat bass_b = C3 . E3 . G2 . . G2 A2 . C3 . F2 . G2 .
pat drums_a = kick . hat . snare . hat hat kick . hat . snare hat hat .
pat drums_b = kick . hat hat snare . hat . kick kick hat . snare . snare .
seq lead_seq = lead_a lead_b lead_a lead_b
seq harmony_seq = harmony_a harmony_b harmony_a harmony_b
seq bass_seq = bass_a bass_b bass_a bass_b
seq drums_seq = drums_a drums_b drums_a drums_b
channel 1 => inst lead seq lead_seq
channel 2 => inst harmony seq harmony_seq
channel 3 => inst bass seq bass_seq
channel 4 => inst snare seq drums_seq
playNext
Continue with Modifiers — reshape phrases with :oct, :rot, :slow, and more without rewriting notes.