# Examples

Playable `.track` files demonstrating the format's features. Play the entry
file of each example with `track-play` (follows `@jump` automatically) or
render it with `track-export`:

```
cargo run --bin track-play --features play -- examples/song/intro.track
cargo run --bin track-export --features export -- examples/song/loop.track loop.wav
```

## song/

An adaptive song graph in A minor, plus two standalone pieces. `packs.track`
imports the shared instrument palette (`scales/scales.track` and the
`sounds/drums.track` bank); `shimmer.track` holds the `pentatonic` shimmer
motif shared by the files that use it (`intro`/`loop`/`bridge`).

- **intro.track → loop.track** — the intro swells for 8 beats (pad chords,
  a bell shimmer, a tom pickup) and `@jump`s into the 32-beat main loop:
  an eight-bar A-minor theme with a walking bass, a full drum groove built
  from reusable drum motifs (`groove_kick`/`groove_snare`/`groove_hat` placed
  four times each), voice-led pad chords, and a pentatonic bell layer in just
  intonation (`@tuning`/`@root`). The loop's `@jump` lines form the adaptive
  graph: `combat > 0` switches to `action.track`, `random < 0.3` occasionally
  detours through `bridge.track`, otherwise it loops itself.
- **bridge.track** — a lighter 16-beat contrast section (relative-major turn:
  F–C–G–Am) with a flute counter-melody, reduced percussion, and an
  unconditional `@jump` back to the loop.
- **action.track** — 150 BPM chiptune combat music in E minor: galloping
  `saw_bass` eighths, a `bitcrusher`ed square lead, blip arpeggios from the
  `chiptune` bank, four-on-the-floor drums with a snare-roll fill, and
  noise-hit accents. A standalone self-`@jump` loop — the adaptive entry
  into it is on the loop's side (`@jump action.track if combat > 0`), so
  opening `action.track` alone loads nothing else.
- **ambient.track** — a 3/4 piece (`@signature 3 4`) built entirely on the
  `seven_limit` just-intonation tuning: a low drone, slowly shifting septimal
  chords, echoing bells, and a flute melody whose `glide 0.5` lines slide
  through fractional scale degrees — tunings interpolate between degrees, not
  just land on integers. No `@jump`: it plays once.
- **panned.track** — a call-and-response figure alternating between a
  hard-left and a hard-right layer (`@pan -0.7`/`0.7`) over a centered pad
  with `highpass` and layer-level `tremolo`. The right side echoes the same
  `call` motif with per-instance tweaks: a `note` override bends the answer
  down instead of up, another raises the peak note, a `trim 2 1` placement
  keeps only the final note as a sparse echo, and the closing statement is
  faded out note by note — all without touching the motif definition.

## suite/

A five-part linear piece (`intro → track1 → track2 → track3 → outro`) with
no loops and no cycle — `@jump` used purely as a way to chain distinct
sections, each with its own tempo. `packs.track` imports the `orchestral`
and `drums` banks; `leitmotif.track` defines the `quest` leitmotif family in
*scale degrees* rather than semitones, so every layer picks its mode via
`@tuning`:

- `quest` — the leitmotif (do–re–mi–so–mi).
- `quest_wide` — the same shape with doubled durations (augmentation).
- `quest_inv` — the same shape with inverted intervals (melodic inversion).
- Fragments are cut from `quest` at the placement via `trim`, so no separate
  fragment motif is needed.

The journey, all rooted on D:

- **intro** — pure atmosphere before the theme exists: drone fifth, wind,
  two lone glockenspiel notes.
- **track1 (exposition, major)** — I–vi–IV–V; `quest` stated plainly on the
  flute, sequenced diatonically to the subdominant on the pluck
  (`transpose 3` moves scale degrees, not semitones), and echoed as a
  two-note glockenspiel fragment (`trim 0 2`).
- **track2 (development, minor)** — the same motif definitions under
  `@tuning minor` flip the whole scene to the parallel minor. Rising
  three-note fragments (`trim 0 3` at climbing transposes) tighten over an
  i–VII–VI–v descent, a full minor statement on the sax closes over the
  five chord, and rim/tom pulses keep it uneasy.
- **track3 (climax)** — 32 driving beats: the bass is a single 4-beat
  `drive` motif transposed to each chord root, drums enter with full groove
  motifs, `quest_wide` soars twice (glockenspiel doubled an octave up),
  `quest_inv` answers in a three-voice canon (lead, reed, sax at 2-beat
  intervals), and a rising line hands over to the outro.
- **outro (resolution)** — minor pads fade, and the final `quest` statement
  is placed with a per-instance `tuning major` override inside a minor
  layer: a Picardy-third resolution that shifts pitch, chord, and scale in
  one line.

## vocal/

Sung songs via the `speech` feature (build with
`--features play,speech` / `--features export,speech`). Both use voice-preset
sounds (`voice male` / `female` / `child`) whose notes carry quoted syllables
in phoneme notation; everything else — tunings, motifs, glides, ramps — works
on sung notes like on synth notes. `phonemes.track` is the minimal
phoneme/glide demo.

- **shanty.track** — a work song in the dorian tuning: a `skipper` verse with
  a `crew` answering through a sung motif (`crew_call` carries its lyrics in
  the motif definition, placed twice), over accordion stabs, a fifth-pendulum
  bass, and a stomp beat. Ends with skipper and crew an octave apart on one
  long "ho".
- **lullaby.track** — 3/4, major: a `female` voice sings a verse, a `child`
  voice answers by humming (sonorant phonemes `m`/`ma`/`mu` are pitched, so
  humming is just singing on `m`), and both fade out humming an octave apart
  over a shrinking pad.
- **lauf.track** — an uptempo vocal song in the `action.track` mold (150 BPM,
  E minor, galloping `saw_bass`, bitcrushed lead, four-on-the-floor drums)
  that loops via a self-`@jump`. The chorus is a `hook` motif whose lyrics
  live in the motif definition ("lauf lauf lauf …"), placed twice over
  different harmony; a `robot` voice throws in answer shouts, and the loop
  turns around on a sung octave `glide` scream.
- **star.track** — Twinkle Twinkle Little Star in English (`child` voice,
  lyrics adapted from phoneme-synth's `scores/`; English "w" is written as a
  `u` glide: "uan d@r", "uöld"). Shows both lyric mechanisms side by side:
  the A phrase is a motif with its text inline, the B phrase is a *textless*
  motif that gets different words per placement via indented
  `note <i> text "…"` overrides.
- **heave.track** — an English sea shanty: a textless verse-melody motif sung
  twice with different verse lyrics via text overrides, a crew answering
  "heave away" from an inline-texted motif, and skipper and crew joining an
  octave apart for the final call, over accordion stabs, fifth-pendulum bass
  and a stomp beat (dorian, like all shanties here).
- **orc.track** — a looping orc war chant on the `ghost` voice preset (which
  growls like an orc): a warlord chant motif with invented guttural verses
  per placement ("grom mak uz gar rok hai"), a horde grunting "hu / ha" on
  the offbeats, war toms, a distorted horn — and a massed octave-glide
  "uaaa" for the final WAAGH before the loop restarts.
- **yoho.track** — a shanty sung entirely on "jo / ho / he / hej / hom"
  vocables: verse melody with its yo-ho text inline, crew answers, and the
  final "jo ho hom" a fifth apart. Same crew/stomp framework as
  `heave.track`, no real words at all.
- **orc_song.track** — the orcs sing actual English: two verses on a
  textless melody via `note … text` overrides ("we march at dawn through
  fire and the stone" / "the drums are calling us into the war"), a
  "blood and iron" chorus chanted by warlord and horde together, and a
  rising massed "uor" before the loop.

### vocal/battle/ — a multi-song vocal suite

Three songs chained by `@jump` into a cycle with hard vibe changes, each
with its own tempo, key and voices — play `village.track` and let it run:

- **village.track** (92 BPM, C major) — a `child` sings over glockenspiel,
  pads and a soft shaker ("the sun is on the water …"); in the last bars the
  harmony turns minor and a distant horn and toms announce what's coming.
- **raid.track** (150 BPM, E minor) — full `action.track` drive: galloping
  bass, four-on-the-floor, bitcrushed lead. The `ghost` warlord chants
  "börn it daun" with the horde piling in, while a `female` voice cuts
  across the top with "dei ar ka miq" and a final glide scream.
- **stand.track** (132 BPM) — the confrontation: the woman sings a defiant
  anthem in English (two verses via text overrides), the orcs answer
  "nou ri trit" between her lines, and the ending stacks her held "lain"
  over the horde's growled "trit" an octave below — then the cycle jumps
  back to the village and peace returns.

## scales_demo/

- **tunings.track** — the same short motif (`phrase`) played back-to-back on
  four layers, each with a different `@tuning` from `scales/scales.track`
  (`chromatic`, `major`, `pentatonic`, `seven_limit`) but the same `@root`.
  Demonstrates that a tuning is a per-layer setting applied uniformly to both
  plain notes and motif instances — the identical motif definition (just
  scale-degree numbers) sounds different in each scale with no extra
  features required, since `render_layer` resolves one voicing per layer and
  uses it for everything on that layer.
- **modal.track** — the same motif (`drift`, this time with `glide` written
  into the motif definition itself rather than a plain note) played once in
  the `minor` tuning and once in `whole_tone` (`equal 6`, the symmetric,
  key-ambiguous scale), each under its own pad chord, back to back at the
  same root pitch. A practical A/B of scale character rather than an
  isolated comparison.
