Play recorded songs in Light Trails and add lives and power-ups

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-04 13:12:56 -08:00
1 parent cc97161a23
commit cc02631ab5
21 files changed
+1094 -786

No files matched your search

+6 -6
View File
@@ -248,7 +248,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
| `workspace.mjs` | the session's extra folders, and the folders remembered per project and spec |
| `public/activities.js` | the list of activities (`ACTIVITIES`: each game's id, title, picker card line `blurb` and module path) an optional `courses` list (Mini golf's six course ids, which open a course dashboard), `bestKey(id, course?)`, the flat looks.json key for its best score (`activityBestSnake`, one per golf course `activityBestGolfPirate` to `activityBestGolfFrost`, `activityBestTrails`, `activityBestBugs`, `activityBestDrive`, `activityBestStack`, `activityBestBumper`, `activityBestRapids`, `activityBestFuse`, `activityBestHop`, `activityBestBounce`, `activityBestGhoul`); lists Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road and Ghoul Rush, `bestKeys(entry)`, every best key a game keeps, and documents the game contract including the course parts (`courses` and `preview()` on the export, `setCourse()` and `course` on the game), the optional `pointer(type, x, y)`, `release(name)` (a game key let go) and `lowerIsBetter`; data only, imported by the page and by Node |
| `public/activities/snake.js` | Snake: its rules as plain exported functions and the game contract (`create({ canvas, tone, onScore })` returning `start`, `pause`, `resume`, `key`, `tick`, `resize`, `score`, `state`); it never runs a timer or listens for keys, so the Activities window drives it; it also holds the music's rules: `MUSIC_TRACKS`, `dealMusic(random, last)` (a round's shuffle of the ten tracks, never opening on the last round's opener), `trackFor(deck, level)` and `heat(round)` (the snake's speed as 0.3 to 1, so the lead and drums are in from the first step) |
| `public/activities/trails.js` | Light Trails: its rules as plain exported functions (`newRound`, `newHeat`, `turn`, `boost`, `advance` in 8 ms slices (where your crash is held for `GRACE_MS`, a turn in that time riding out of it; rivals get no grace), `choose` and `room` for the rivals' flood-fill steering, `applyPower`, `spawnItem`, `closeRing`), the `ARENAS` (rivals, sharpness and what each adds), the `POWERS` pads and the game contract; memo is the furthest arena reached; a read-only `round` getter for the tests only; it also holds the music's rules: `MUSIC_TRACKS`, `dealMusic(random, last)` (a round's shuffle of the fourteen tracks, never opening on the last round's opener), `trackFor(deck, level)` and `heat(round)` (0.3 while a heat lines up or ends, 0.7 racing, 0.85 down to the last rival, 1 on a boost) |
| `public/activities/trails.js` | Light Trails: its rules as plain exported functions (`newRound`, `newHeat`, `turn`, `boost`, `advance` in 8 ms slices (where your crash is held for `GRACE_MS`, a turn in that time riding out of it; rivals get no grace), `choose` and `room` for the rivals' flood-fill steering, `applyPower` (a Mystery becoming another pad), `pickPower` (by each pad's `from` arena, a Heart only under `MAX_LIVES`), `fireLaser`, `hyperjump`, `awardLives` (a life every `LIFE_SCORE` points, the mark moving on at the cap), `spawnItem`, `closeRing`), the `ARENAS` (rivals, sharpness and what each adds), the `POWERS` pads (Boost, Phase, Eraser, Slow-mo, Coin, Heart, Shield held across heats until a crash in your grace pops it, Laser with `LASER_SHOTS`, Score x2 through one `gain()` every score goes through, Wide Trail with its side cells in `rider.wide`, Coin Rain whose `rain` coins never hold back a pad, Hyperjump, Mystery) and the game contract; `START_LIVES` is 5; memo is the furthest arena reached; a read-only `round` getter for the tests only; it also holds the music's rules: `MUSIC_TRACKS` (its five songs) and `dealMusic(random, last)` (a shuffle of them, never opening on `last`); a run plays the deal one song after another, each in full from the top (asking with `{ restart: true }` until the music takes it), moves on when `music()` answers `"ended"`, deals again after the last, and a new run deals afresh, never opening on the song the last run was playing; its tones and hums play `SFX_LOUDER` times as loud through tones.js's `louder`, all but the engine drones (`DRONES`), kept low under the songs |
| `public/activities/bugs.js` | Bug Hunt: its rules as plain exported functions (`newRound`, `spawnWave`, `slotPos`, `advance` in 8 ms slices over `round.input`, which `key()` and `release()` set, `hurtBug`, `hurtBoss`, `hitShip`, `applyPower`, `ghostly`, `tentacleTip`, `bossRadius`), the `BUGS` by first wave, the `BOSSES` every `BOSS_EVERY` waves, the `POWERS`, the `SECTORS` scenery and the game contract with `release()`; memo is the tally of `DISCOVERIES` as bits; a read-only `round` getter for the tests only |
| `public/activities/drive.js` | Sunset Drive: its rules as plain exported functions (`newRound`, `buildStage`, which appends a stage of road and returns its `forkAt`, `gateAt` and `fork`, `segAt`, `advance` in 8 ms slices over `round.input`, which `key()` and `release()` set, `boost`, `usePower` (the oldest queued power-up, which space fires ahead of `boost`), `hopHeight`, `checkTime`), the `POWERS` in `POWER_ORDER`, the `REGIONS` (roads with their bonus, bends, hills, traffic, colors and props) in `REGION_ORDER`, the projection and drawing (sky, road far to near, props, traffic, Planny's car) and the game contract with `release()`; the next road is built only when the fork is chosen, and `FORK_LEN` must stay at least `DRAW` so it is built before it comes into view; memo is the roads found as bits; a read-only `round` getter for the tests only |
| `public/activities/stack.js` | Stack Deploy: its rules as plain exported functions (`newRound`, `spawnBlock`, `advance` in 8 ms slices that slides the block between the walls, `drop`, which drops it where it was last drawn and returns `{ kept, sliced, perfect, miss }`, `isPerfect` and `zoneOf` (3% of the block's width, the slide in `PERFECT_MS`, or `round.minZone`, the `MIN_ZONE_PX` floor the game sets at each resize, whichever is most, but never more than half the block's width, so a drop off the tower is never perfect), `grow`, `speedAt`, `twistsAt`, `styleAt`, `comboPitch`), the `TWISTS` by floor (speed ramp, either side and turning back, lag spikes, wind, rush hour, faster) and the `STYLES` of the tower, the drawing (sky by height, blocks per style, Planny riding the top, the dashed marker of the highest floor) and the game contract with `pointer()` (a press on the board drops) and `release()` (a held up drops once, not at every key repeat, and `key(name, repeat)` ignores a repeat the window marks, so up held through the countdown never drops at its first repeat); a press waits for the first tick after a start or a play-on, so an arrow that resumes never also drops; a miss holds the round running for `OUTRO_MS` while the camera pulls back over the whole tower; memo is the highest floor ever reached, saved on a pause and at the end; a read-only `round` getter for the tests only |
@@ -446,11 +446,11 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
| `public/sound.js` | the sound cues: which plays, one at a time, held until the first click |
| `public/spec-states.js` | the spec states (`diagnosed`, `fixed`, `exploring`, `mapped`, `planned`, `documented`, `building`, `built`, `unrecognized`): each one's picker label, the card it is the natural next step for and its recommendation, data only; which cards a state lights lives in `skills.js`, how a folder maps to a state in `classifySpec()` in `scan.mjs` |
| `public/state.js` | the page's shared state (`page.S` the server's truth, `page.local` what is staged) and the `redraw()` / save hooks every screen calls; defines only |
| `public/tones.js` | the activities' sound engine, all synthesized in the browser. Three parts: a shared kit of rich one-shot sounds (`RICH`: `layers` of parts played together, each a wave or a noise (`noise`, `pink`, `brown`) with its own `delay`, `gain`, `attack`, a sweeping `filter` and `vibrato`: `explode`, `smash`, `skid`, `whoosh`, `splashBig`, `fanfare`, `gameOver` and some fifty more, up to 1.2 s, at most `MAX_VOICES` parts sounding at once), held **hums** (`hum(id, name, level, pitch)`, called every frame a game wants it: oscillators and noise through one filter that follows the pitch, pulsed for an engine's strokes; a hum not asked for within `HUM_HOLD_MS` fades by itself, so a paused or closed game goes quiet without saying so, `hushTones()` quiets every one and the Activities window calls it whenever it stops ticking; at most `MAX_HUMS`; shared ones `car`, `toycar`, `electric`, `outboard`, `river`, `wind`, `cycle`, `fuse`, `haunt`, `squeal`, `meter`, `swarm`, `train`, `crowd`), and each game's own extras in `public/activities/<id>-sfx.js` (`{ tones, hums }`, plain objects, names prefixed with the game id, merged and frozen here; a name may be defined once across all of them, which `scripts/test-web-console-tones.mjs` checks along with every spec's shape and every name a game's source asks for). Everything plays through one compressor. The older single blips (`BLIPS`): `tone(name, level, pitch)` with an optional loudness from 0 to 1 and an optional pitch that scales every frequency, kept between 0.25 and 4, `unlockTones()`; Snake's blips plus golf's `putt`, `wall`, `bump`, `cup`, `ace` (a three-note rise), `splash`, `power` (a power-up, three notes), `tunnel`, `boom` (a cannon putt), `sizzle` (lava) and `fall` (the pit), the countdown's `count` and `go`, Stack Deploy's `thunk`, `slice` and `perfect`, which it pitches up a scale step for each perfect in a row, and Bumper Ring's `ram`, pitched and leveled by how hard the hit, and `rev`, a rival winding up a dash, and Hot Potato's `tick`, the fuse, which it ticks quicker and pitches higher as the fuse burns down, and `pop`, a pass, and Crossing Rush's `hop`, which it pitches up a step for each quick hop forward in a row, `boing`, a send-back, `bell`, a train coming, and `horn`, and Bounce Road's `engine`, a soft low triangle hum it plays every few frames while you pick up speed (quiet once you cruise or coast), pitched up with your speed, `spring`, a jump, pitched with your speed, and `squash`, a rival flattened, pitched up a step for each in a chain, and `beat`, a low thump while your wheels run on the verge (it borrows the other games' blips for its hazards and rivals), and Rapids Run's `pew` (a shot, a short soft triangle played quietly about seven times a second while fire is held), `charge` (a buoy taken), `lowcell` (the low battery's two-note beep, quicker the lower it runs), `dambreak` (a dam bursting) and `skim` (a bank skimmed at speed, pitched up the more you have skimmed), and Ghoul Rush's `ghoulBlast` (the blaster's bolt, a short soft triangle repeated while fire is held), `zombiePop` (a kill, pitched up a step for each in the chain), `ghoulStomp`, `ghoulBoo`, `ghoulRoar` and `zombieGroan` (now kept for the other games and the tests: Ghoul Rush's monsters speak with their own voices from `ghoul-sfx.js`), `ghoulCandy` (pitched up for candy in quick succession), `batSwoop` (a bat's kill), `doorUnlock` (the key), `doorThrough` (the door to the next room) and `creakBoard` (a crawler coming up, a chandelier or a crumbling board about to go), all soft triangles and sines), silent while Play sounds is off; separate from `sound.js`'s cue queue |
| `public/music.js` | the games' chiptune music: a small sequencer over `tones.js`'s context and compressor (`audioOut()`). A game calls `music(name, intensity)` from its `tick`; the track fades out within `MUSIC_HOLD_MS` once it stops being asked for, picks up again on the bar it left, asking for a different track crossfades the two over `CROSSFADE_S` (the old one keeps playing as it fades, so a new level is not a cut), and `hushMusic()` stops it at once. Tracks are note data under `music` in each game's `activities/<id>-sfx.js` (`{ bpm, rush, bar, voices, patterns, order }`, `bar` the steps in a bar when it is not 16, so the track resumes on a bar start and each pattern is whole bars: pulse, triangle and noise-drum voices, each joining once the intensity reaches its `from`; a step a token, `A4`, `-` to hold, `.` a rest, `A3^037` an arpeggio, drums `k s h o`), read by `compileTrack()` and booked `LOOKAHEAD_S` ahead on the audio clock. The window plays it only while Play sounds, Play game sounds and Play game music (`looks.gameMusic`, off by default) are all on |
| `public/activities/snake-sfx.js` · `public/activities/golf-sfx.js` · `public/activities/trails-sfx.js` · `public/activities/bugs-sfx.js` · `public/activities/drive-sfx.js` · `public/activities/stack-sfx.js` · `public/activities/bumper-sfx.js` · `public/activities/rapids-sfx.js` · `public/activities/fuse-sfx.js` · `public/activities/hop-sfx.js` · `public/activities/bounce-sfx.js` · `public/activities/ghoul-rush/sfx/ghoul-sfx.js` | each game's own sound effects as data, `{ tones, hums }` in the shapes `tones.js` documents, every name prefixed with the game id (`driveEngine`, `ghoulMoan`), merged and frozen by `tones.js`; no imports, but for `ghoul-sfx.js`, which merges each Ghoul Rush stage's own `ghoul-sfx-<stage>.js` into its `tones`, `hums` and `music`, `snake-sfx.js`, which merges `snake-music.js` as its `music`, and `trails-sfx.js`, which merges `trails-music.js` as its `music` |
| `public/tones.js` | the activities' sound engine, all synthesized in the browser. Three parts: a shared kit of rich one-shot sounds (`RICH`: `layers` of parts played together, each a wave or a noise (`noise`, `pink`, `brown`) with its own `delay`, `gain`, `attack`, a sweeping `filter` and `vibrato`: `explode`, `smash`, `skid`, `whoosh`, `splashBig`, `fanfare`, `gameOver` and some fifty more, up to 1.2 s, at most `MAX_VOICES` parts sounding at once), held **hums** (`hum(id, name, level, pitch)`, called every frame a game wants it: oscillators and noise through one filter that follows the pitch, pulsed for an engine's strokes; a hum not asked for within `HUM_HOLD_MS` fades by itself, so a paused or closed game goes quiet without saying so, `hushTones()` quiets every one and the Activities window calls it whenever it stops ticking; at most `MAX_HUMS`; shared ones `car`, `toycar`, `electric`, `outboard`, `river`, `wind`, `cycle`, `fuse`, `haunt`, `squeal`, `meter`, `swarm`, `train`, `crowd`), and each game's own extras in `public/activities/<id>-sfx.js` (`{ tones, hums }`, plain objects, names prefixed with the game id, merged and frozen here; a name may be defined once across all of them, which `scripts/test-web-console-tones.mjs` checks along with every spec's shape and every name a game's source asks for). Everything plays through one compressor. The older single blips (`BLIPS`): `tone(name, level, pitch)` with an optional loudness from 0 to 1 and an optional pitch that scales every frequency, kept between 0.25 and 4, and an optional fourth `louder` (a game lifting its sounds as a whole, up to `LOUDER_MAX`, also the fifth argument of `hum()`), `unlockTones()`; Snake's blips plus golf's `putt`, `wall`, `bump`, `cup`, `ace` (a three-note rise), `splash`, `power` (a power-up, three notes), `tunnel`, `boom` (a cannon putt), `sizzle` (lava) and `fall` (the pit), the countdown's `count` and `go`, Stack Deploy's `thunk`, `slice` and `perfect`, which it pitches up a scale step for each perfect in a row, and Bumper Ring's `ram`, pitched and leveled by how hard the hit, and `rev`, a rival winding up a dash, and Hot Potato's `tick`, the fuse, which it ticks quicker and pitches higher as the fuse burns down, and `pop`, a pass, and Crossing Rush's `hop`, which it pitches up a step for each quick hop forward in a row, `boing`, a send-back, `bell`, a train coming, and `horn`, and Bounce Road's `engine`, a soft low triangle hum it plays every few frames while you pick up speed (quiet once you cruise or coast), pitched up with your speed, `spring`, a jump, pitched with your speed, and `squash`, a rival flattened, pitched up a step for each in a chain, and `beat`, a low thump while your wheels run on the verge (it borrows the other games' blips for its hazards and rivals), and Rapids Run's `pew` (a shot, a short soft triangle played quietly about seven times a second while fire is held), `charge` (a buoy taken), `lowcell` (the low battery's two-note beep, quicker the lower it runs), `dambreak` (a dam bursting) and `skim` (a bank skimmed at speed, pitched up the more you have skimmed), and Ghoul Rush's `ghoulBlast` (the blaster's bolt, a short soft triangle repeated while fire is held), `zombiePop` (a kill, pitched up a step for each in the chain), `ghoulStomp`, `ghoulBoo`, `ghoulRoar` and `zombieGroan` (now kept for the other games and the tests: Ghoul Rush's monsters speak with their own voices from `ghoul-sfx.js`), `ghoulCandy` (pitched up for candy in quick succession), `batSwoop` (a bat's kill), `doorUnlock` (the key), `doorThrough` (the door to the next room) and `creakBoard` (a crawler coming up, a chandelier or a crumbling board about to go), all soft triangles and sines), silent while Play sounds is off; separate from `sound.js`'s cue queue |
| `public/music.js` | the games' chiptune music: a small sequencer over `tones.js`'s context and compressor (`audioOut()`). A game calls `music(name, intensity)` from its `tick`; the track fades out within `MUSIC_HOLD_MS` once it stops being asked for, picks up again on the bar it left, asking for a different track crossfades the two over `CROSSFADE_S` (the old one keeps playing as it fades, so a new level is not a cut), and `hushMusic()` stops it at once. Tracks are note data under `music` in each game's `activities/<id>-sfx.js` (`{ bpm, rush, bar, voices, patterns, order }`, `bar` the steps in a bar when it is not 16, so the track resumes on a bar start and each pattern is whole bars: pulse, triangle and noise-drum voices, each joining once the intensity reaches its `from`; a step a token, `A4`, `-` to hold, `.` a rest, `A3^037` an arpeggio, drums `k s h o`), read by `compileTrack()` and booked `LOOKAHEAD_S` ahead on the audio clock. It also plays recorded **songs**: mp3s a game names under `songs` in its sfx file (a name to a served path, merged by `tones.js` as `SONG_TABLES`, listed by `songNames()`), asked for the same way, one `<audio>` element each made on first use, at `SONG_PEAK` times the volume, faded over `SONG_FADE_MS`; a song plays once, never looped, `music()` returning `"playing"` or `"ended"` (which the window's wrapper passes back to the game), `{ restart: true }` taking it back to the top with `load()` (no seeking, since the server sends no byte ranges), and a song no longer asked for fades and pauses where it was. The window plays it only while Play sounds, Play game sounds and Play game music (`looks.gameMusic`, off by default) are all on |
| `public/activities/snake-sfx.js` · `public/activities/golf-sfx.js` · `public/activities/trails-sfx.js` · `public/activities/bugs-sfx.js` · `public/activities/drive-sfx.js` · `public/activities/stack-sfx.js` · `public/activities/bumper-sfx.js` · `public/activities/rapids-sfx.js` · `public/activities/fuse-sfx.js` · `public/activities/hop-sfx.js` · `public/activities/bounce-sfx.js` · `public/activities/ghoul-rush/sfx/ghoul-sfx.js` | each game's own sound effects as data, `{ tones, hums }` in the shapes `tones.js` documents, every name prefixed with the game id (`driveEngine`, `ghoulMoan`), merged and frozen by `tones.js`; no imports, but for `ghoul-sfx.js`, which merges each Ghoul Rush stage's own `ghoul-sfx-<stage>.js` into its `tones`, `hums` and `music`, and `snake-sfx.js`, which merges `snake-music.js` as its `music`; `trails-sfx.js` has `songs` instead of `music` |
| `public/activities/snake-music.js` | Snake's ten music tracks as data (no imports): `SNAKE_MUSIC`, `{ bpm, rush, voices, patterns, order }` each, named `snake<Place>` and listed in `MUSIC_TRACKS` in `snake.js`. A round deals them in a fresh order, one to each level, so a run hears a different track at every level and none twice. They were picked on the pages in `prototypes/music/snake` (rhythm-first folk and world tunes led by something plucked or reedy, mostly dark or modal), and their bars are not all sixteen steps: 6/8 is 12, 7/8 is 14, ten beats is 20, twelve beats is 24, each pattern a whole number of its bars; merged by `snake-sfx.js` |
| `public/activities/trails-music.js` | Light Trails' fourteen music tracks as data (no imports): `TRAILS_MUSIC`, `{ bpm, rush, voices, patterns, order }` each, named `trails<Name>` and listed in `MUSIC_TRACKS` in `trails.js`. A round deals them in a fresh order, one to each arena, so a run hears a different track in every arena and none twice. They were picked on the pages in `prototypes/music/light-trails` (mostly dark, cinematic grid electro in minor keys at 96 to 120 bpm, three leaning cyberpunk and synthwave), and build with `heat(round)`: bass, drums and sequence while a heat lines up, brass and lead once the riders go; merged by `trails-sfx.js` |
| `public/activities/light-trails/1.mp3` to `5.mp3` | Light Trails' five background songs, named `trailsSong1` to `trailsSong5` under `songs` in `trails-sfx.js` and listed in `SERVABLE`; re-encoded for size with ffmpeg (80 kbps stereo MP3 at 44.1 kHz, loudness-normalized to -16 LUFS with `loudnorm`, metadata stripped), about 7.6 MB together, and copied into every skill with the rest of the console. The server leaves them out of its start-up cache warm |
| `public/activities/ghoul-rush/stages/graveyard/ghoul-sfx-graveyard.js` | The Graveyard's own sounds as data (no imports): `GRAVEYARD_SFX`, its `tones` (the picked `ghoul<Kind><Act>` sounds of the grasping hands, mourners, grave robbers, rotters and their legs, carrion crows and Mother Mourning) and `music` (`ghoulLychgate`, `ghoulGraves`, `ghoulMausoleums`, `ghoulAngel`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own. Every new stage gets its own `ghoul-sfx-<stage>.js`, listed in `STAGE_SFX` there |
| `public/activities/ghoul-rush/stages/grounds/ghoul-sfx-grounds.js` | The Grounds' own sounds as data (no imports): `GROUNDS_SFX`, its `tones` (the 32 picked `ghoul<Kind><Act>` sounds of the topiary beasts, rootlings, lantern moths, mulch crawlers, the Groundskeeper and the Hedge shears' snip) and `music` (`ghoulMaze`, `ghoulTopiary`, `ghoulGazebo`, `ghoulYard`, named in `ROOM_MUSIC`), merged by `ghoul-sfx.js` after the house's own via `STAGE_SFX` |
| `public/uploads.js` | pictures and documents attached to a note: chips, trays, re-encoding, upload, retry, and the page's shared full-screen picture preview (`openPicview`, the `#picview` dialog every thumbnail opens) |
@@ -568,7 +568,7 @@ Key design points:
`POST /subagents` (origin-checked; `400` `not-offered` / `bad` / `too-long` / `max`) saves the store and bumps the session setting. `consume()`, `cmdChat()`, `deliverChat()` and `open` append `blockFor()`'s lines last in `reply` and the `subagents` field; a change alone never ends a `wait` slice. The page's Subagents tab (before Ask) draws `state.helpers` through `helperRows()`. Helpers never reach the meter ledger. Contract: `console-subagents.md`.
- **The filesystem is the transport.** Sessions live in `~/.plan2code/console/sessions/<sid>/`, deliberately not under `specs/`, so the console cannot trip the metrics scraper or any marker parser, and survives `git clean`. A result written after the agent dies is picked up by the next session.
- **Attachments on notes and quick questions live in `<sid>/uploads/`**, never in the project: images as `<uuid>.jpg`, documents as `<uuid>.<ext>` with `ext` from `DOC_TYPES` in `answers.js` (text, code, PDF). The browser re-encodes images to JPEG and sends raw bytes to `POST /upload` as `image/jpeg`; documents go as-is as `application/octet-stream`, the extension taken by `docExt()` from the uncut `x-p2c-name`. `readRaw(req, limit, cb)` in `routes.mjs` caps images at `MAX_BODY` (4 MB) and documents at `MAX_DOC_BYTES` (10 MB), and drains rather than destroys so the client gets its 413. Images need the `FF D8 FF` magic; documents pass `checkDocument()` in `sessions.mjs` (`%PDF-` for PDF, strict UTF-8 with no NUL for text), else 415. The server names the file with `crypto.randomUUID()`. `GET /uploads/<id>.<ext>` serves images as `image/jpeg` and documents under a fixed type (`application/pdf`, else `text/plain`) with `nosniff` and, on text, CSP `sandbox` (a sandboxed PDF cannot open in the viewer), so a browser can show but never run one; `recordSubmitted()` writes every send's note onto its item as `sentNote { at, text, images, files }` (paths and names only), which `noteAwaiting()` in `answers.js` turns into the Sent box's attachment links and the Notes pane's pending note until the agent's next thread message; `DELETE /uploads/<id>.<ext>` takes any allowed extension; both stay contained under `uploads/`. `isOwnUpload()` returns the kind (`"image"` / `"file"` / `false`), and `attachmentsOk()` makes `/submit` comments and `/chat` messages carry images only in `images[]` and documents only in `files[]`, this session's uploads only, at most 5 together (`MAX_ATTACHMENTS`). A comment's `reply` gains one ` Image: <path> (<name>)` or ` File: <path> (<name>)` line per attachment, in attach order; a chat entry's lines come from `chatReplyLines()`, its images first, then its files. `sweepUploads()` bounds disk growth, and the session sweep removes the whole session a month after that. A note attachment a spec file cites is copied out first by `console.mjs keep` (`--session --upload --name --spec [--from]`): it checks both paths (the upload must sit under the session's `uploads/`, and the spec folder under `state.project`, real paths included, so a symlinked folder cannot carry the copy outside), copies with `COPYFILE_EXCL` and reuses an existing copy, prints `{ ok, path, link, image, reused }` with a forward-slash link relative to `--from`, and logs a `keep` event. It is the agent's hand, not the server's: it runs in the agent's shell only when the agent decides to cite a file, so the server still never writes into a project.
- **Attachments on notes and quick questions live in `<sid>/uploads/`**, never in the project: images as `<uuid>.jpg`, documents as `<uuid>.<ext>` with `ext` from `DOC_TYPES` in `answers.js` (text, code, PDF). The browser re-encodes images to JPEG and sends raw bytes to `POST /upload` as `image/jpeg`; documents go as-is as `application/octet-stream`, the extension taken by `docExt()` from the uncut `x-p2c-name`. `readRaw(req, limit, cb)` in `routes.mjs` caps images at `MAX_BODY` (4 MB) and documents at `MAX_DOC_BYTES` (10 MB), and drains rather than destroys so the client gets its 413. Images need the `FF D8 FF` magic; documents pass `checkDocument()` in `sessions.mjs` (`%PDF-` for PDF, strict UTF-8 with no NUL for text), else 415. The server names the file with `crypto.randomUUID()`. `GET /uploads/<id>.<ext>` serves images as `image/jpeg` and documents under a fixed type (`application/pdf`, else `text/plain`) with `nosniff` and, on text, CSP `sandbox` (a sandboxed PDF cannot open in the viewer), so a browser can show but never run one; `recordSubmitted()` writes every send's note onto its item as `sentNote { at, text, images, files, suggest? }` (paths and names only; `suggest` only when the action's is exactly `true`, the **Ask for suggestions** chip, which always writes a thread entry, note or not, and is left out of the `submitted` event's `ids` so the card's staged pick stays), which `noteAwaiting()` in `answers.js` turns into the Sent box's attachment links and the Notes pane's pending note until the agent's next thread message; `DELETE /uploads/<id>.<ext>` takes any allowed extension; both stay contained under `uploads/`. `isOwnUpload()` returns the kind (`"image"` / `"file"` / `false`), and `attachmentsOk()` makes `/submit` comments and `/chat` messages carry images only in `images[]` and documents only in `files[]`, this session's uploads only, at most 5 together (`MAX_ATTACHMENTS`). A comment's `reply` gains one ` Image: <path> (<name>)` or ` File: <path> (<name>)` line per attachment, in attach order; a chat entry's lines come from `chatReplyLines()`, its images first, then its files. `sweepUploads()` bounds disk growth, and the session sweep removes the whole session a month after that. A note attachment a spec file cites is copied out first by `console.mjs keep` (`--session --upload --name --spec [--from]`): it checks both paths (the upload must sit under the session's `uploads/`, and the spec folder under `state.project`, real paths included, so a symlinked folder cannot carry the copy outside), copies with `COPYFILE_EXCL` and reuses an existing copy, prints `{ ok, path, link, image, reused }` with a forward-slash link relative to `--from`, and logs a `keep` event. It is the agent's hand, not the server's: it runs in the agent's shell only when the agent decides to cite a file, so the server still never writes into a project.
- **Answers carry their terminal token.** Each item ships `fallbackText` and `token`, so a click resolves to the literal word the prompt already expects (`approved`, `a`, `skip`). No workflow needs a second code path, and declining the console degrades to prose with nothing lost.
- **A build tells the page how long silence is normal.** The page calls a working agent stuck after two minutes without a post, which is right for a conversation and wrong for a twenty-minute build task. `agent.quietMinutes` (1 to 60, counted only while `working`) stretches the stuck, adrift and Send-grace thresholds; `quietLimitMs()` in `answers.js` is the one rule.
- **A finished quick task's review button is a request through the wait loop**, like the brief: `{ "i": "__review" }` or `{ "i": "__done" }`. The agent keeps waiting after posting a finish that carries `review`, and takes the review up by posting `"finish": null`, which puts the session back to work. Implementation's review needs no such machinery: it is a verdict on the sign-off card, asked before approval, so the session never left work to take it up.
+32 -17
View File
@@ -76,6 +76,10 @@ Scroll down for the utilities. Outside a git repository the **Git** card says so
- **An example you can accept.** Where a question comes with one, an *Autofill
suggestion* button puts it in the box as a real answer for you to edit. It
disappears as soon as you have typed anything of your own.
- **Ask for suggestions.** Unsure on a question with options to pick? The
*Ask for suggestions* button in the notes panel asks Plan2Code what it would
pick and why, and the answer comes back in the same panel. Anything you have
already ticked stays as it is.
- **Answers you have settled read as answers**, not as a form you might still be
able to change: what you chose, stated in words, with everything else locked.
- **A question you have sent is held** until Plan2Code answers it, showing
@@ -543,10 +547,11 @@ the moment lasts, and crashes, splashes, explosions, pickups, combos, bosses,
new bests and game over each get a sound of their own. A game can play
chiptune music too, made the same way, which builds as play heats up (Sunset
Drive has a song for each road, Snake a different one at every level, dealt from ten at
the start of a round so none repeats, Light Trails a different dark grid-electro track in
every arena, dealt from fourteen the same way and fuller once the riders go, and Ghoul Rush a track for each room, played at
one steady level and fuller in a boss fight): turn on **Play game music** in **User Preferences → Sounds &
activities** (it starts off). **Play game sounds** there turns the games'
the start of a round so none repeats, and Ghoul Rush a track for each room, played at
one steady level and fuller in a boss fight), and Light Trails plays five
recorded songs as background music, each in full, one after another in an
order shuffled for every run: turn on **Play game music** in **User
Preferences → Sounds & activities** (it starts off). **Play game sounds** there turns the games'
sounds (the 3, 2, 1 and the new-best burst included) and their music on or
off and leaves the page's own cues alone; the **Play sounds** switch above it
silences all of it, and a paused or closed game goes quiet at once. A game
@@ -648,19 +653,29 @@ Ghoul Rush at 65).
is a run of heats through nine arenas, each with its own scenery: Neon Grid,
Sunset Strip, Crystal Field, Warp Zone, Storm Front, Carnival, Glacier,
Volcano and the Golden Arena. Winning a heat moves you to the next arena; a
crash costs one of your three lives and runs the heat again, and you and the
last rival out at once is a draw that costs nothing. Each arena brings
something: a second rival and **power-up pads** at 2 (**Boost**, a charge;
**Phase**, ride through trails for 3 seconds; **Eraser**, wipes the trails
around you; **Slow-mo**, the rivals crawl; coins; and from arena 4 a
**1UP**), **crystals** at 3, a third rival and a pair of **portals** at 4,
**closing walls** at 5 (from 10 seconds in, the outer ring turns to stone
every 3.5 seconds, flashing red first), and a second pair of portals at 6.
The rivals ride sharper each arena, and grab a pad if they get there first.
Points come for riding (a point a level every 6 cells), for each rival out
while you still ride (10 a level, 5 more when it hit your trail), coins and
each heat won (25 a level). The start and end screens show the furthest
arena you have reached and the next one waiting.
crash costs one of your five lives and runs the heat again, and you and the
last rival out at once is a draw that costs nothing. Every 750 points gives
a life back (up to nine). Each arena brings something: a second rival and
**power-up pads** at 2 (**Boost**, a charge; **Phase**, ride through trails
for 3 seconds; **Eraser**, wipes the trails around you; **Slow-mo**, the
rivals crawl; coins; a beating **Heart**, a life; and a **Shield**, held
from heat to heat until it takes a crash for you, wiping the trails around
you and riding on), **crystals** at 3 with a **Laser** (for 6 seconds it
fires at any rival head in your line up to 16 cells ahead, cutting through
trails but not crystals, three shots, each a rival out with the cut bonus)
and **Score x2** (8 seconds of double points), a third rival and a pair of
**portals** at 4 with a **Wide Trail** (4 seconds of a wall three cells
across) and **Coin Rain** (seven coins over the board), **closing walls**
at 5 (from 10 seconds in, the outer ring turns to stone every 3.5 seconds,
flashing red first) with a **Hyperjump** (straight out to the most open
space on the board), and at 6 a second pair of portals and a rainbow
**Mystery** pad that turns into any of the others. The first pad of each
kind in a run says it is new. The rivals ride sharper each arena, and grab
a pad if they get there first. Points come for riding (a point a level
every 6 cells), for each rival out while you still ride (10 a level, 5 more
when your trail or laser got it), coins and each heat won (25 a level). The
start and end screens show the furthest arena you have reached and the
next one waiting.
- **Bug Hunt** is an arcade shooter. Planny's ship slides along the bottom
(left and right move it, up and down a little too) and fires while space is
held. Each wave of bugs swoops in from the sides into a formation that sways
+3 -1
View File
@@ -14,8 +14,9 @@ All notable changes to Plan2Code will be documented in this file.
- **web console**: the Subagents dialog has a **Helper strength** choice under Helpers: **Balanced** (the default), **Thrifty**, **Best** or **Match my session**, saved per project and skill and delivered to the agent as a `Helper strength:` line. Helper reports may say what each helper ran with (`strength`, `effort`), and the Subagents tab shows each as a colored badge with a small three-bar level mark (teal for low, amber for medium, violet for high; the session's own model in plain gray), while screen readers still hear one line, such as "Standard, medium effort".
- **web console**: picking a spec on the dashboard that is not documented yet now shows its main files as read-only tabs in the top bar, like the **Overview** tab of a documented spec: **Map** for a Pathfinder map (`pathfinder/map.md`) and **Plan draft** for Plan's live `PLAN-DRAFT-*.md`, each when it exists. Once the spec has an `overview.md`, Overview replaces them.
- **web console**: start Pathfinder, Plan or Quick Task (on **Start fresh**) or Revise plan (on a picked spec with no plan change waiting) from a Notebook tab. A lit card's confirm pane offers **Start with a note from your Notebook**, with the tab list, a preview of the whole tab and up to five ticked pictures (the first five start ticked; a tab over 50 KB says so). The skill's first box arrives filled with the tab's text and pictures, editable, and the agent reads it only once you send it; nothing about the tab rides the launch itself. The tab then shows a **sent** badge and a "Sent to <Skill> · <Date>" line in the Notebook, and the Notebook's privacy line now reads: the agent never reads your Notebook, and a tab reaches it only when you start a workflow with it.
- **web console**: **Ask for suggestions**, a chip in the **Notes on this** panel of an open choice, multi or confirm card, asks Plan2Code what it would pick and why, on its own: it sends one request for that card (with anything typed in the note box), and every pick already staged, on that card or another, stays staged. The request shows in the thread tagged **Asked for suggestions** until the agent replies there, with the chip held off meanwhile; `console.md` tells the agent to answer a `Suggestions wanted on <title>:` line in the item's thread with each suggestion and why, re-posting the question only when that helps. A re-post that drops an option clears only the pick staged on it, and a banner names the question.
- **web console**: **Activities**, a die in the top bar right of the megaphone, opens a window of small games to play while you wait, say through a long build. The first is **Snake**, built in-house from local files (arrows or WASD, space or Enter to start, P or Enter to pause and play on, Esc to close). It speeds up as it grows and gets wilder each level: every new level opens in Slow-mo (which eases back to full speed as it runs out, never with a jolt), and every 5 foods brings something new (rocks that flash before they land, mystery boxes, portals, tail-cutting comets, chaos, then ice, where a turn slides two steps before it takes), five power-ups turn up on their own (Shield, Slow-mo, Magnet, Ghost, Scissors), a mystery box holds one of nine surprises (Jackpot, Gold rush, Lights out, Disco fever and more), each level serves its own fruit (an apple, then cherries, an orange, grapes, a banana, a strawberry, watermelon, a peach and a golden apple) on its own scenery (meadow, desert, lagoon, starry night, carnival, ice, volcano, gold), the last food of every odd level from 3 on is a crowned four-cell boss fruit that takes three bites, a runaway fruit on little feet hops away until you corner it or tire it out, quick eating builds a combo up to x5, and passing your best plays a fanfare. A level, power-up or surprise banner opens on the half of the board away from the snake and fades almost clear while the snake is under it or heading into it, so it never hides a crash. The start and end screens count the surprises you have found so far and hint at what waits next. The second is **Mini golf**: goofy holes seen from above on themed courses (see the course dashboard further down), among them Pirate Cove (a shark sea, cannonballs, a kraken, a ghost ship, a skull to putt through) and the Caves of Doom (dark but for the ball's light, with lava, a bottomless pit, mine carts, stone crushers and a sleeping dragon), played arcade style: the aim follows the mouse (or held arrows, turning faster the longer they are held) and points back at the cup after every stop, holding there until the mouse really moves so a click never swings it, one click or space starts a power meter beside the ball and a second sets the power (slow near the bottom for soft putts, fast near the top, with a gold MAX band for a 1.15x putt and a red overswing band past it that shanks the ball), a 6 second shot clock starts the meter for you, a meter left running dribbles the ball, and holding space or the mouse fast-forwards the roll, with par per hole, at most 8 strokes a hole, and its best kept as the lowest full round. Glowing power-up pads help the next putt: a free putt, a cannon shot, a ghost ball that floats over water, a cup magnet, a rubber duck that keeps its speed off walls, a huge cup, and a spyglass that shows where the putt will roll. With two games, a picker chooses between them. A new question, a sign-off or a finish pauses the game at once and shows a banner with **Go to it**, so a game never hides your turn; hiding the page or clicking away pauses it too. While that banner is up, nothing resumes until you click its **Unpause game** button, so a key or click already on its way cannot wave the banner away unread; after **Go to it**, or once you close and reopen the window, a game key or a click on the board plays on. Resuming puts the your-turn banner away until the next question. Every round start and every play-on after a pause counts down 3, 2, 1 first, so a game never moves before you are ready. The window's header shows the current game's best. Best scores (shown beside the score and after each round, cleared by **Reset best scores**; the score line is a pair of colored chips with a meter filling toward the best, which glows when you reach it, turns into a rainbow with a burst of sparks when you pass it, and ends the round with **New best!**) and the last pick are saved privately in `~/.plan2code/console/looks.json` and never reach the agent. **User Preferences → Sounds & activities → Show Activities** hides the die everywhere, and Help has a new Activities topic.
- **web console**: Activities has a third game, **Light Trails**: every rider leaves a glowing wall behind it, and the last one still moving wins the heat. Arrows steer and space spends a boost charge (two a heat, up to three). Riding into something holds you in place for a split second first, so a turn pressed then still gets you out (rivals get no such grace). A round runs through nine arenas, from Neon Grid to the Golden Arena, each on its own scenery: a win moves you on, and a crash costs one of three lives and runs the heat again. Each arena brings a rival more (Zip, Bolt, then Echo, who ride sharper the further you go) or something new: power-up pads at 2 (Boost, Phase through trails, an Eraser that wipes the trails around you, Slow-mo for the rivals, coins and, from 4, a 1UP), crystals at 3, portals at 4 and walls that close in a ring at a time, flashing first, at 5. A rival out while you still ride scores points, and more when it hit your own trail. You ride with Planny's star eye, and the start and end screens show the furthest arena you have reached and what waits next.
- **web console**: Activities has a third game, **Light Trails**: every rider leaves a glowing wall behind it, and the last one still moving wins the heat. Arrows steer and space spends a boost charge (two a heat, up to three). Riding into something holds you in place for a split second first, so a turn pressed then still gets you out (rivals get no such grace). A round runs through nine arenas, from Neon Grid to the Golden Arena, each on its own scenery: a win moves you on, and a crash costs one of five lives and runs the heat again, and every 750 points gives a life back (up to nine). Each arena brings a rival more (Zip, Bolt, then Echo, who ride sharper the further you go) or something new: power-up pads at 2 (Boost, Phase through trails, an Eraser that wipes the trails around you, Slow-mo for the rivals, coins, a beating Heart for a life, and a Shield, held from heat to heat until it takes a crash for you), crystals at 3 with a Laser that zaps rival heads in your line through their trails and Score x2, portals at 4 with a Wide Trail three cells across and Coin Rain, walls that close in a ring at a time, flashing first, at 5 with a Hyperjump out to open space, and at 6 a rainbow Mystery pad that could be any of them; the first pad of each kind in a run says it is new. A rival out while you still ride scores points, and more when your trail or your laser got it. You ride with Planny's star eye, and the start and end screens show the furthest arena you have reached and what waits next.
- **web console**: Activities has a fourth game, **Bug Hunt**, an arcade shooter. Planny's ship slides along the bottom (the arrows move it, held space fires) and squashes waves of bugs that swoop in from the sides into a swaying formation, then break off and dive at you. The first waves each bring a new bug: the everyday **Bug**, a **Beetle** that splits in two, a zigzagging **Race condition**, an **Exception** that throws things, a **Null pointer** that shots pass through while it fades, and a **Firewall** that soaks up shots. Every fifth wave is a boss: the **Memory Leak**, which grows while you wait, the **Spaghetti Monster**, whose tentacles have to go first, and the **Heisenbug**, which is only there when you look, then round again, tougher. Squashed bugs drop coins and now and then a power-up (Spread shot, Rapid fire, Shield, Slow-mo, Magnet, Refactor, which cleans up the screen, and a 1UP), quick kills build a combo up to x5, and a wave cleared without a hit scores extra. The board is Snake's checkerboard scrolling past with bits of code drifting by, with new scenery every five waves (the Codebase, Legacy Code, Production, the Cloud), and the start and end screens count the 16 bugs, bosses and power-ups found so far.
- **web console**: Activities has a fifth game, **Sunset Drive**, a road racer against the clock. Planny drives a convertible down an endless road seen from behind, with bends, hills, traffic and scenery scrolling past: hold up to drive, down to brake, the arrows to steer, and space burns a nitro can for a burst of speed. The clock sits big in the top middle, blinking red and swelling on every tick in its last ten seconds. Each stage ends at a checkpoint that adds time, and just before it the road splits around a median: the side you keep to picks the next of six roads (Sunset Coast, Canyon Road, Maple Valley, Snowcap Pass, Neon City and Starlight Highway), each with its own sky, props, traffic and points bonus, the harder ones worth more. Coins, clocks and nitro cans line the road, a car passed close at speed scores a close call, and catching up with a car or hitting a palm, cactus or rock on the shoulder costs you speed. As the fork is called, a postcard of each road (its sky, hills, road and scenery, with its name and points bonus) shows in the top corner on its side, the side you are on lit. Spinning **?** boxes on the road hold power-ups, queued up to three: while one is held, space fires the oldest instead of a nitro can, and timed ones run side by side (one fired again while it runs adds its time). **Rocket Hop** leaps over the traffic and the shoulder, **Ghost Car** drives right through cars and props, **Coin Magnet** pulls in every coin across the road, **Monster Truck** flings the cars it hits into the sky for points and flattens props, and **Coin Storm** turns the traffic ahead into coins. The round ends when the clock runs out, and the start and end screens count the roads found so far.
- **web console**: Activities has a sixth game, **Stack Deploy**, a one-button tower stacker. A block slides back and forth above the tower and space, up or a click drops it: the overhang is sliced off and tumbles away, so the next block is narrower, and a block that misses the tower ends the round with the camera pulling back over the whole tower. A drop dead on is a **Perfect**: nothing is sliced, the thunk climbs a scale with each one in a row, the bonus multiplies up to x5, and every third in a row grows the block back. Gold blocks from floor 15 are worth more and grow it twice as much. The slide speeds up from floor 10, and the floors bring twists: blocks from either side that may turn back (20), lag spikes that freeze a block for a beat (30) and wind (40), then a rush through the middle (70) and everything faster (90). The tower goes from server racks to office floors, glass towers and rockets under a sky that turns from day to space, Planny rides the top block (and wobbles after a sloppy drop), and a dashed line marks the highest floor ever reached, which the start screen names with the next style to reach.
@@ -32,6 +33,7 @@ All notable changes to Plan2Code will be documented in this file.
- **web console**: Ghoul Rush has four more power-ups that are not about the blaster: a **Lantern** pulls the dark far back for 15 seconds, **Bat wings** give one flap in the air per jump for 12 seconds (a press just before landing still jumps on landing), a **Church bell** holds every monster but a boss still for 4 seconds and lets none in until it stops or you reach the door, and an **Hourglass** puts 20 seconds back on the clock. They lie in the Gallery, Library, Kitchen, Conservatory and Attic and drop from kills, and power-ups now drop twice as often, so the blaster ones turn up as often as before.
- **web console**: every Ghoul Rush room but a boss's now has a **TIME** clock in the HUD (70 to 80 seconds by the room's length), red with a tick a second in its last ten; at none it costs a life and the room starts over with a full clock.
- **web console**: Ghoul Rush has music: a track for each room (a haunted music box in the Foyer, a 9/8 synth in the Portrait Gallery, creeping pizzicato in the Library, a gothic organ for the Rotting Gourd, a cauldron swing in the Kitchen, a 5/4 synth in the Conservatory, a phonograph foxtrot in the Attic and a dark-synth fight with Bones in the Crypt). Each plays only its drone and bass in a quiet stretch and grows fuller as monsters close in and in the clock's last ten seconds, with all of it in a boss fight. It plays under **Play game music**, like Sunset Drive's songs.
- **web console**: Light Trails has background music: five recorded songs that play one after another, each in full, for as long as a run lasts. Every new run shuffles them into a fresh order and starts the first from the top, never the song the last run was playing, and once all five have played they are shuffled again. A pause picks the song up where it stopped. It plays under **Play game music**, at the game's own **Music** slider. The light cycles' engine drones (yours and the nearest rival's) are much quieter now, so the songs carry the run, and the game's other sounds are a little louder (1.4 times), so they still cut through.
- **web console**: a game with music has its own **Music** volume slider in the Activities window, beside **Full screen**, remembered per game. Sunset Drive starts at 70 and Ghoul Rush at 50, so its music sits under the house's sounds. The slider is dimmed, and says why, while **Play game music** is off.
- **web console**: Ghoul Rush hides treasure up high, over each room's key shelf (but a boss's): **crystals** worth 250 points each, and in three rooms **Silver bolts**, a power-up found nowhere else whose bolts go on through every monster they hit for 10 seconds. None of it is reachable with one jump; a jump and a **Bat wings** flap from the key shelf takes it, and each of those rooms now has Bat wings on the way.
- **web console**: in Ghoul Rush, a zombie, crawler, spitter or gourdling that reaches the edge of a pit or a drop now stops for a moment, a "?" over its head as it thinks about it, then leaps: across a pit up to 10 units wide to floor at its own height, further down to a lower floor (the Kitchen's 12-unit pit from the counter to the floor), and straight down off a ledge. Wider pits and floor higher than a step still stop it.
+251 -27
View File
@@ -2090,7 +2090,7 @@ function racing(round) {
const trailsEvents = (round, type) => round.events.filter((e) => e.type === type);
test("Light Trails: a round starts at level 1 with three lives, two boosts and one rival, everyone on the grid", () => {
test("Light Trails: a round starts at level 1 with five lives, two boosts and one rival, everyone on the grid", () => {
const round = trails.newRound(still);
assert.equal(round.level, 1);
assert.equal(round.lives, trails.START_LIVES);
@@ -2323,6 +2323,190 @@ test("Light Trails: pads turn up from level 2, never at level 1", () => {
assert.ok(Object.hasOwn(trails.POWERS, two.items[0].kind));
});
test("Light Trails: five lives to start, a life back every LIFE_SCORE points, never past MAX_LIVES", () => {
const round = racing(trails.newRound(still));
assert.equal(trails.START_LIVES, 5);
assert.equal(round.lives, 5);
round.score = trails.LIFE_SCORE - 1;
trails.awardLives(round);
assert.equal(round.lives, 5, "not yet");
round.score = trails.LIFE_SCORE;
trails.awardLives(round);
assert.equal(round.lives, 6, "one life at the mark");
assert.deepEqual(trailsEvents(round, "bonusLife").map((e) => e.lives), [6]);
round.score = trails.LIFE_SCORE * 3 + 10;
trails.awardLives(round);
assert.equal(round.lives, 8, "one for each mark passed");
round.lives = trails.MAX_LIVES;
round.score = trails.LIFE_SCORE * 10;
trails.awardLives(round);
assert.equal(round.lives, trails.MAX_LIVES, "capped");
assert.equal(round.nextLifeAt, trails.LIFE_SCORE * 11, "and the mark moves on, so none is saved up");
});
test("Light Trails: every pad turns up only from its own arena, a Heart only while there is room for a life, and a Mystery never becomes another", () => {
const round = trails.newRound(still);
let n = 1;
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
for (let level = 2; level <= trails.MAX_LEVEL; level++) {
round.level = level;
const seen = new Set(Array.from({ length: 3000 }, () => trails.pickPower(round, random)));
const due = Object.keys(trails.POWERS).filter((k) => trails.POWERS[k].from <= level);
assert.deepEqual([...seen].sort(), due.sort(), `level ${level} offers exactly the pads due by then`);
}
assert.equal(trails.POWERS.life.from, 2, "a Heart from the first arena with pads");
round.lives = trails.MAX_LIVES;
assert.ok(Array.from({ length: 2000 }, () => trails.pickPower(round, random)).every((k) => k !== "life"), "no Heart at full lives");
round.lives = 3;
assert.ok(Array.from({ length: 2000 }, () => trails.pickPower(round, random, true)).every((k) => k !== "mystery"));
});
test("Light Trails: a Heart pad gives a life", () => {
const round = racing(trails.newRound(still));
trails.applyPower(round, "life");
assert.equal(round.lives, trails.START_LIVES + 1);
});
test("Light Trails: a Shield takes your next crash, wiping the trails round you and riding on, and is held from heat to heat until then", () => {
const round = racing(trails.newRound(still));
const you = round.riders[0];
trails.applyPower(round, "shield");
assert.equal(round.shield, true);
park(round, you, 10, 15, "right");
round.grid[15 * trails.COLS + 11] = 2;
round.grid[14 * trails.COLS + 10] = 2;
round.grid[16 * trails.COLS + 10] = 2;
trails.advance(round, trails.STEP_MS + trails.GRACE_MS + 8, still);
assert.equal(you.alive, true, "boxed in on three sides, and the Shield saved you");
assert.equal(round.shield, false, "it is used up");
assert.equal(trailsEvents(round, "shield").length, 1);
assert.equal(round.grid[15 * trails.COLS + 11] === 2, false, "the trail ahead was wiped");
assert.equal(round.lives, trails.START_LIVES);
// Held through a heat won.
const two = racing(trails.newRound(still));
trails.applyPower(two, "shield");
trails.newHeat(two, still);
assert.equal(two.shield, true, "a new heat keeps it");
// A wall all round is still a crash.
const three = racing(trails.newRound(still));
trails.applyPower(three, "shield");
park(three, three.riders[0], 0, 0, "left");
three.grid[1] = trails.WALL;
three.grid[trails.COLS] = trails.WALL;
trails.advance(three, trails.STEP_MS + trails.GRACE_MS + 8, still);
assert.equal(three.riders[0].alive, false, "nowhere to go");
});
test("Light Trails: a Laser zaps a rival head in your line through trails, scoring the cut, but holds fire behind a crystal", () => {
const round = racing(trails.newRound(still));
const [you, rival] = round.riders;
park(round, you, 5, 15, "right");
park(round, rival, 15, 15, "up");
round.grid[15 * trails.COLS + 9] = 2;
trails.applyPower(round, "laser");
assert.equal(rival.alive, false, "zapped at once");
assert.equal(rival.by, "laser");
assert.equal(round.grid[15 * trails.COLS + 9], 0, "the trail in the beam is cut");
assert.equal(round.shots, trails.LASER_SHOTS - 1);
const [out] = trailsEvents(round, "out");
assert.equal(out.points, trails.OUT_POINTS + trails.CUT_POINTS, "a laser out pays the cut");
assert.equal(trailsEvents(round, "laser").length, 1);
const two = trails.newRound(still);
two.level = 3;
racing(trails.newHeat(two, still));
const [me, foe] = two.riders;
park(two, me, 5, 15, "right");
park(two, foe, 15, 15, "up");
two.grid[15 * trails.COLS + 10] = trails.BLOCK;
trails.applyPower(two, "laser");
assert.equal(foe.alive, true, "a crystal in the way holds the shot");
assert.equal(two.shots, trails.LASER_SHOTS);
park(two, foe, 3, 15, "up");
assert.equal(trails.fireLaser(two), false, "and it only fires ahead");
});
test("Light Trails: Score x2 doubles every point while it runs", () => {
const round = racing(trails.newRound(still));
round.level = 2;
trails.applyPower(round, "coin");
const single = round.score;
trails.applyPower(round, "double");
trails.applyPower(round, "coin");
assert.equal(round.score - single, single * 2);
});
test("Light Trails: a Wide Trail lays your wall three cells wide, and the cells go with the trail", () => {
const round = racing(trails.newRound(still));
const you = round.riders[0];
park(round, you, 10, 15, "right");
trails.applyPower(round, "wide");
trails.advance(round, trails.STEP_MS, still);
assert.equal(you.x, 11);
assert.equal(round.grid[14 * trails.COLS + 11], 1, "above");
assert.equal(round.grid[16 * trails.COLS + 11], 1, "and below");
assert.equal(you.wide.length, 2);
trails.applyPower(round, "eraser");
assert.equal(you.wide.length, 0, "wiped cells leave the list");
});
test("Light Trails: Hyperjump moves you to an open cell clear of everyone, facing open space", () => {
const round = racing(trails.newRound(still));
const you = round.riders[0];
let n = 9;
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
// Fill the left half with trail, so the jump has to take you right.
for (let y = 0; y < trails.ROWS; y++) for (let x = 0; x < 18; x++) if (!(x === you.x && y === you.y)) round.grid[y * trails.COLS + x] = 2;
assert.equal(trails.hyperjump(round, random), true);
assert.ok(you.x >= 18, "out in the open half");
assert.equal(round.grid[you.y * trails.COLS + you.x], 1, "on a cell of your own");
for (const r of round.riders.slice(1)) assert.ok(Math.abs(r.x - you.x) + Math.abs(r.y - you.y) >= 4, "clear of the rivals");
const d = { up: [0, -1], down: [0, 1], left: [-1, 0], right: [1, 0] }[you.dir];
assert.equal(round.grid[(you.y + d[1]) * trails.COLS + you.x + d[0]], 0, "facing an open cell");
assert.equal(trailsEvents(round, "jump").length, 1);
});
test("Light Trails: Coin Rain drops coins all over that never hold back the pads", () => {
const round = trails.newRound(still);
round.level = 4;
racing(trails.newHeat(round, still));
let n = 4;
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
trails.applyPower(round, "rain", random);
const coins = round.items.filter((it) => it.kind === "coin" && it.rain);
assert.equal(coins.length, trails.RAIN_COINS);
round.nextItem = 1;
trails.advance(round, 8, random);
assert.equal(round.items.filter((it) => !it.rain).length, 1, "a pad still turns up");
});
test("Light Trails: a Mystery pad turns into another pad and says which", () => {
const round = trails.newRound(still);
round.level = 9;
racing(trails.newHeat(round, still));
trails.applyPower(round, "mystery", () => 0.1);
const [m] = trailsEvents(round, "mystery");
assert.ok(m && m.kind !== "mystery" && Object.hasOwn(trails.POWERS, m.kind));
assert.deepEqual(trailsEvents(round, "power").map((e) => e.kind), [m.kind], "the pad it became is applied");
});
test("Light Trails game: every new pad, its effects and its events draw and sound without throwing", () => {
const { canvas } = stubCanvas();
const tones = [];
const g = trails.default.create({ canvas, tone: (n) => tones.push(n) });
g.resize(800, 600);
g.start();
g.cheat(true);
const round = g.round;
round.level = 9;
trails.newHeat(round, still);
g.tick(2000);
for (const kind of Object.keys(trails.POWERS)) trails.spawnItem(round, kind);
for (const kind of ["shield", "laser", "double", "wide", "jump", "rain", "mystery", "life"]) trails.applyPower(round, kind);
for (let i = 0; i < 60; i++) g.tick(50);
for (const name of ["trailsHeart", "shieldUp", "trailsJump", "mystery"]) assert.ok(tones.includes(name), `${name} played`);
});
test("Light Trails: from level 5 the walls close in a ring at a time, warning first, and catch anyone on the ring", () => {
const round = trails.newRound(still);
round.level = 5;
@@ -2354,45 +2538,85 @@ test("Light Trails: the start screen reads the furthest arena from the memo and
test("Light Trails: every pill's text reads at 4.5:1 on its backing and its timer's tint, lives and running effects included, in light and dark under every highlight", () => {
checkPills(trails.default, {
setup: (r) => Object.assign(r.effects, { boost: trails.BOOST_MS / 2, phase: 1500, slow: 2000 }),
expect: ["LV 1", "♥", "~BOOST", "~PHASE", "~SLOW-MO", "1 RIVAL"],
setup: (r) => {
Object.assign(r.effects, { boost: trails.BOOST_MS / 2, phase: 1500, slow: 2000, laser: 3000, double: 4000, wide: 2000 });
Object.assign(r, { shield: true, shots: 2 });
},
expect: ["LV 1", "♥", "~BOOST", "~PHASE", "~SLOW-MO", "1 RIVAL", "SHIELD", "~LASER", "x2 SCORE", "WIDE"],
});
});
test("Light Trails: a round deals every track once, never opens on the last opener, and gives each arena its own", () => {
test("Light Trails: its sounds play SFX_LOUDER times as loud, but for the engine drones, left low under the songs", () => {
const { canvas } = stubCanvas();
const tones = [];
const hums = [];
const g = trails.default.create({ canvas, tone: (...a) => tones.push(a), hum: (...a) => hums.push(a) });
g.resize(800, 600);
g.start();
g.cheat(true);
for (let i = 0; i < 200; i++) g.tick(50);
assert.ok(trails.SFX_LOUDER > 1, "louder than made");
assert.ok(tones.length && tones.every((a) => a[3] === trails.SFX_LOUDER), "every tone lifted");
const drones = hums.filter((a) => a[0] === "trails:you" || a[0] === "trails:rival");
assert.ok(drones.length && drones.every((a) => a[4] === 1), "the drones are not");
assert.ok(hums.filter((a) => !drones.includes(a)).every((a) => a[4] === trails.SFX_LOUDER), "every other hum is");
});
test("Light Trails: a deal holds every song once and never opens on the last song", () => {
let n = 11;
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
for (let i = 0; i < 20; i++) {
const last = trails.MUSIC_TRACKS[i % trails.MUSIC_TRACKS.length];
const deck = trails.dealMusic(random, last);
assert.deepEqual([...deck].sort(), [...trails.MUSIC_TRACKS].sort(), "every track once");
assert.notEqual(deck[0], last, "never opens on the last opener");
assert.deepEqual([...deck].sort(), [...trails.MUSIC_TRACKS].sort(), "every song once");
assert.notEqual(deck[0], last, "never opens on the last song");
}
const deck = trails.dealMusic(random, null);
const heard = Array.from({ length: trails.MAX_LEVEL }, (_, i) => trails.trackFor(deck, i + 1));
assert.equal(new Set(heard).size, trails.MAX_LEVEL, "nine arenas hear nine different tracks");
assert.equal(trails.trackFor(deck, 0), deck[0], "a level below one hears the first");
assert.notDeepEqual(trails.dealMusic(random, null), trails.dealMusic(random, null), "a new deal is a new order");
});
test("Light Trails: the music's heat is low while a heat lines up, rises once the riders go, more so down to the last rival, and is full on a boost", () => {
const round = trails.newRound(() => 0.5);
assert.equal(round.phase, "ready");
const waiting = trails.heat(round);
assert.ok(waiting < 0.5, "lining up: no lead yet");
round.level = 2;
trails.newHeat(round, () => 0.5);
round.phase = "race";
assert.ok(round.riders.filter((r) => r.id !== 0).length >= 2, "two rivals at level 2");
const racing = trails.heat(round);
assert.ok(racing >= 0.5 && racing < 1, "racing with rivals left: the lead is in");
for (const r of round.riders.filter((r) => r.id !== 0).slice(1)) r.alive = false;
assert.ok(trails.heat(round) > racing && trails.heat(round) < 1, "down to the last rival it climbs");
round.effects = { ...round.effects, boost: trails.BOOST_MS };
assert.equal(trails.heat(round), 1, "a boost pushes it all the way");
test("Light Trails: a run plays each song in full from the top, moves on only when one ends, and deals again after the last", () => {
const { canvas } = stubCanvas();
const asked = [];
let reply = "playing";
const g = trails.default.create({ canvas, music: (name, intensity, options) => (asked.push({ name, restart: Boolean(options && options.restart) }), reply) });
g.resize(800, 600);
g.start();
g.cheat(true);
g.tick(16);
g.tick(16);
assert.deepEqual(asked.map((a) => a.restart), [true, false], "the first song starts from the top, then plays on");
assert.equal(asked[1].name, asked[0].name, "the same song until it ends");
const heard = [asked[0].name];
for (let i = 0; i < trails.MUSIC_TRACKS.length; i++) {
reply = "ended";
g.tick(16);
reply = "playing";
g.tick(16);
const next = asked.at(-1);
assert.ok(next.restart, "the next song starts from the top");
assert.notEqual(next.name, heard.at(-1), "and is another song");
heard.push(next.name);
}
assert.deepEqual(heard.slice(0, trails.MUSIC_TRACKS.length).sort(), [...trails.MUSIC_TRACKS].sort(), "every song once before any plays again");
});
test("Light Trails: it asks for the deal's track while a round runs, silent before and after, and the next round opens on another", () => {
test("Light Trails: a song the music could not play yet still starts from the top once it can", () => {
const { canvas } = stubCanvas();
const asked = [];
let reply;
const g = trails.default.create({ canvas, music: (name, intensity, options) => (asked.push(Boolean(options && options.restart)), reply) });
g.resize(800, 600);
g.start();
g.cheat(true);
g.tick(16);
g.tick(16);
reply = "playing";
g.tick(16);
g.tick(16);
assert.deepEqual(asked, [true, true, true, false], "the restart is asked for until the music takes it");
});
test("Light Trails: it asks for the deal's song while a round runs, silent before and after, and the next round opens on another", () => {
const { canvas } = stubCanvas();
const asked = [];
const g = trails.default.create({ canvas, music: (name, level) => asked.push([name, level]) });
@@ -2403,7 +2627,7 @@ test("Light Trails: it asks for the deal's track while a round runs, silent befo
g.tick(16);
assert.equal(asked.length, 1, "asked once a tick");
const [first] = asked[0];
assert.ok(trails.MUSIC_TRACKS.includes(first), "a track the game has");
assert.ok(trails.MUSIC_TRACKS.includes(first), "a song the game has");
g.round.lives = 1;
for (let i = 0; i < 2000 && g.state === "running"; i++) g.tick(50);
assert.equal(g.state, "over", "riding straight ends the round");
+1 -1
View File
@@ -2516,7 +2516,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
test("the server serves the activities' scripts, golf's seventeen, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring's two, Rapids Run's two, Hot Potato's two, Crossing Rush's two, Bounce Road's seven, Ghoul Rush's ninety-five, every game's sound effects and the shared pills included", () => {
const server = fs.readFileSync(new URL("../src/web-console/static.mjs", import.meta.url), "utf8");
const servable = server.slice(server.indexOf("const SERVABLE = new Set(["), server.indexOf("]);", server.indexOf("const SERVABLE = new Set([")));
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "activities/snake-music.js", "activities/trails-music.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul-rush/ghoul.js", "activities/ghoul-rush/draw/ghoul-draw.js", "activities/ghoul-rush/core/ghoul-rooms.js", "activities/ghoul-rush/stages/wing/ghoul-bones.js", "activities/ghoul-rush/stages/wing/ghoul-bones-draw.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js", "activities/ghoul-rush/stages/village/ghoul-village.js", "activities/ghoul-rush/stages/village/ghoul-village-draw.js", "activities/ghoul-rush/stages/village/ghoul-village-world.js", "activities/ghoul-rush/stages/village/ghoul-village-wolf.js", "activities/ghoul-rush/stages/mine/ghoul-mine.js", "activities/ghoul-rush/stages/mine/ghoul-mine-draw.js", "activities/ghoul-rush/stages/mine/ghoul-mine-world.js", "activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js", "activities/ghoul-rush/rides/cart/ghoul-cart.js", "activities/ghoul-rush/rides/cart/ghoul-cart-draw.js", "activities/ghoul-rush/rides/sled/ghoul-sled.js", "activities/ghoul-rush/rides/sled/ghoul-sled-draw.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js", "activities/ghoul-rush/rides/banister/ghoul-banister.js", "activities/ghoul-rush/rides/banister/ghoul-banister-draw.js", "activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew.js", "activities/ghoul-rush/rides/pew/ghoul-pew-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew-course.js", "activities/ghoul-rush/rides/pew/ghoul-pew-world.js", "activities/ghoul-rush/rides/mower/ghoul-mower.js", "activities/ghoul-rush/rides/mower/ghoul-mower-draw.js", "activities/ghoul-rush/rides/tray/ghoul-tray.js", "activities/ghoul-rush/rides/tray/ghoul-tray-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js", "activities/ghoul-rush/arms/ghoul-flare.js", "activities/ghoul-rush/stages/bog/ghoul-bog.js", "activities/ghoul-rush/stages/bog/ghoul-bog-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-draw.js", "activities/ghoul-rush/rides/mat/ghoul-mat-room.js", "activities/ghoul-rush/rides/mat/ghoul-mat.js", "activities/ghoul-rush/rides/mat/ghoul-mat-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-dollhouse-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye-draw.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-room.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-pit-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart-draw.js", "activities/ghoul-rush/story/ghoul-ending.js", "activities/ghoul-rush/story/ghoul-ending-draw.js", "activities/ghoul-rush/Line truncated
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "activities/snake-music.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul-rush/ghoul.js", "activities/ghoul-rush/draw/ghoul-draw.js", "activities/ghoul-rush/core/ghoul-rooms.js", "activities/ghoul-rush/stages/wing/ghoul-bones.js", "activities/ghoul-rush/stages/wing/ghoul-bones-draw.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js", "activities/ghoul-rush/stages/village/ghoul-village.js", "activities/ghoul-rush/stages/village/ghoul-village-draw.js", "activities/ghoul-rush/stages/village/ghoul-village-world.js", "activities/ghoul-rush/stages/village/ghoul-village-wolf.js", "activities/ghoul-rush/stages/mine/ghoul-mine.js", "activities/ghoul-rush/stages/mine/ghoul-mine-draw.js", "activities/ghoul-rush/stages/mine/ghoul-mine-world.js", "activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js", "activities/ghoul-rush/rides/cart/ghoul-cart.js", "activities/ghoul-rush/rides/cart/ghoul-cart-draw.js", "activities/ghoul-rush/rides/sled/ghoul-sled.js", "activities/ghoul-rush/rides/sled/ghoul-sled-draw.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js", "activities/ghoul-rush/rides/banister/ghoul-banister.js", "activities/ghoul-rush/rides/banister/ghoul-banister-draw.js", "activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew.js", "activities/ghoul-rush/rides/pew/ghoul-pew-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew-course.js", "activities/ghoul-rush/rides/pew/ghoul-pew-world.js", "activities/ghoul-rush/rides/mower/ghoul-mower.js", "activities/ghoul-rush/rides/mower/ghoul-mower-draw.js", "activities/ghoul-rush/rides/tray/ghoul-tray.js", "activities/ghoul-rush/rides/tray/ghoul-tray-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js", "activities/ghoul-rush/arms/ghoul-flare.js", "activities/ghoul-rush/stages/bog/ghoul-bog.js", "activities/ghoul-rush/stages/bog/ghoul-bog-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-draw.js", "activities/ghoul-rush/rides/mat/ghoul-mat-room.js", "activities/ghoul-rush/rides/mat/ghoul-mat.js", "activities/ghoul-rush/rides/mat/ghoul-mat-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-dollhouse-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye-draw.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-room.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-pit-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart-draw.js", "activities/ghoul-rush/story/ghoul-ending.js", "activities/ghoul-rush/story/ghoul-ending-draw.js", "activities/ghoul-rush/draw/ghoul-picker-draw.js", "aLine truncated
assert.ok(servable.includes(`"${file}"`), `SERVABLE includes ${file}`);
}
});
+133 -9
View File
@@ -8,10 +8,11 @@ import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { HUM_TABLES, TONE_TABLES, hum, humNames, hushTones, tone, toneNames } from "../src/web-console/public/tones.js";
import { HUM_TABLES, LOUDER_MAX, TONE_TABLES, hum, humNames, hushTones, tone, toneNames } from "../src/web-console/public/tones.js";
import { looks } from "../src/web-console/public/looks.js";
import { compileTrack, hushMusic, music, musicNames, noteFreq } from "../src/web-console/public/music.js";
import { MUSIC_TABLES } from "../src/web-console/public/tones.js";
import { SONG_PEAK, compileTrack, hushMusic, music, musicNames, noteFreq, songNames } from "../src/web-console/public/music.js";
import { MUSIC_TABLES, SONG_TABLES } from "../src/web-console/public/tones.js";
import { SERVABLE } from "../src/web-console/static.mjs";
import { REGIONS, ROAD_MUSIC } from "../src/web-console/public/activities/drive.js";
import { MUSIC_TRACKS } from "../src/web-console/public/activities/snake.js";
import snakeSfx from "../src/web-console/public/activities/snake-sfx.js";
@@ -168,6 +169,35 @@ test("a hum starts once, follows each call without starting more, and goes quiet
}
});
test("a game's `louder` lifts a tone and a hum past their usual loudness, never past LOUDER_MAX", () => {
const saved = { sound: looks.sound, ctor: globalThis.AudioContext };
const { Ctx, made } = AUDIO;
globalThis.AudioContext = Ctx;
try {
looks.sound = true;
hushTones();
const tonePeak = (louder) => {
const mark = made.gains.length;
tone("coin", 1, 1, louder);
return Math.max(...made.gains.slice(mark).flatMap((g) => g.gain.ramps.map((r) => r.v)));
};
const base = tonePeak(undefined);
assert.ok(Math.abs(tonePeak(1.4) - base * 1.4) < 1e-9, "a tone 1.4 times as loud");
assert.ok(Math.abs(tonePeak(9) - base * LOUDER_MAX) < 1e-9, "capped at LOUDER_MAX");
const humLevel = (id, louder) => {
const mark = made.gains.length;
hum(id, "wind", 1, 1, louder);
return made.gains.slice(mark).flatMap((g) => g.gain.ramps).filter((r) => r.kind === "target").at(-1).v;
};
const plain = humLevel("plain", undefined);
assert.ok(Math.abs(humLevel("lifted", 1.4) - plain * 1.4) < 1e-9, "a hum 1.4 times as loud");
} finally {
hushTones();
looks.sound = saved.sound;
globalThis.AudioContext = saved.ctor;
}
});
test("every tone or hum a game's source names is one the engine has", () => {
const tones = new Set(toneNames());
const hums = new Set(humNames());
@@ -358,16 +388,110 @@ test("music: Snake lists exactly the tracks it has, each a real track that no ot
}
});
test("music: Light Trails lists exactly the tracks it has, each a real track that no other game defines, enough for every arena", () => {
const tracks = new Set(musicNames());
assert.deepEqual([...TRAILS_TRACKS].sort(), Object.keys(trailsSfx.music).sort(), "the game lists the tracks its sound file has");
assert.ok(TRAILS_TRACKS.length >= 9, "nine arenas, none hearing a track twice");
test("music: Light Trails lists exactly the songs it has, each an mp3 on disk the server serves, and no chiptune tracks", () => {
const songs = new Set(songNames());
assert.equal(trailsSfx.music, undefined, "its music is the songs, not note data");
assert.deepEqual([...TRAILS_TRACKS].sort(), Object.keys(trailsSfx.songs).sort(), "the game lists the songs its sound file has");
for (const name of TRAILS_TRACKS) {
assert.ok(tracks.has(name), `track "${name}" exists`);
assert.equal(MUSIC_TABLES.filter((t) => Object.hasOwn(t, name)).length, 1, `${name} is defined once`);
assert.ok(songs.has(name), `song "${name}" exists`);
assert.equal(SONG_TABLES.filter((t) => Object.hasOwn(t, name)).length, 1, `${name} is defined once`);
assert.ok(!musicNames().includes(name), `${name} is not also a chiptune track`);
const file = trailsSfx.songs[name];
assert.ok(SERVABLE.has(file), `${file} is servable`);
assert.ok(fs.statSync(path.join(ROOT, "src/web-console/public", file)).size > 0, `${file} is on disk`);
}
});
// A stand-in <audio>: records what music.js asks of it.
class FakeAudio {
static made = [];
constructor(src) {
Object.assign(this, { src, volume: 1, paused: true, ended: false, currentTime: 0, plays: 0, loads: 0 });
FakeAudio.made.push(this);
}
play() {
this.paused = false;
this.plays += 1;
return Promise.resolve();
}
pause() {
this.paused = true;
}
load() {
Object.assign(this, { paused: true, ended: false, currentTime: 0, loads: this.loads + 1 });
}
}
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function withSongs(fn) {
const saved = { sound: looks.sound, Audio: globalThis.Audio };
globalThis.Audio = FakeAudio;
looks.sound = true;
hushMusic();
try {
await fn();
} finally {
hushMusic();
looks.sound = saved.sound;
globalThis.Audio = saved.Audio;
}
}
test("music: a song plays from its file, fades in toward its level, says when it has ended, and starts from the top again when asked", () =>
withSongs(async () => {
const [name] = TRAILS_TRACKS;
assert.equal(music(name, 1, 1, { restart: true }), "playing");
const el = FakeAudio.made.find((a) => a.src === `/${trailsSfx.songs[name]}`);
assert.ok(el, "an element for the song's file");
assert.ok(!el.paused && el.plays === 1, "it plays");
for (let i = 0; i < 20; i++) {
music(name, 1, 1);
await sleep(30);
}
assert.ok(Math.abs(el.volume - SONG_PEAK) < 1e-9, "glided up to its level");
assert.equal(el.plays, 1, "asked for again, it is not started again");
el.currentTime = 100;
el.ended = true;
el.paused = true;
assert.equal(music(name, 1, 1), "ended", "a song played through says so");
assert.equal(el.plays, 1, "and is not looped");
assert.equal(music(name, 1, 1, { restart: true }), "playing", "a restart plays it again");
assert.equal(el.loads, 1, "from the top");
assert.equal(el.currentTime, 0);
}));
test("music: a song no longer asked for fades out and pauses where it was, and another song replaces it at once", () =>
withSongs(async () => {
const [first, second] = TRAILS_TRACKS;
music(first, 1, 0.5);
const el = FakeAudio.made.findLast((a) => a.src === `/${trailsSfx.songs[first]}`);
const loads = el.loads;
await sleep(800);
assert.ok(el.paused, "paused once it stops being asked for");
assert.equal(el.volume, 0, "faded to silence");
assert.equal(el.loads, loads, "kept where it was, so it picks up again mid-song");
music(first, 1, 0.5);
assert.ok(!el.paused, "asked for again, it plays on");
music(second, 1, 0.5);
assert.ok(el.paused, "another song stops it");
assert.ok(!FakeAudio.made.at(-1).paused, "and plays");
hushMusic();
assert.ok(FakeAudio.made.every((a) => a.paused), "a hush pauses every song");
}));
test("music: a song plays nothing while Play sounds is off, at a volume of 0, or with no audio", () =>
withSongs(async () => {
const [name] = TRAILS_TRACKS;
looks.sound = false;
assert.equal(music(name, 1, 1), undefined);
looks.sound = true;
assert.equal(music(name, 1, 0), undefined);
globalThis.Audio = undefined;
assert.equal(music(name, 1, 1), undefined);
assert.ok(FakeAudio.made.filter((a) => a.src === `/${trailsSfx.songs[name]}`).every((a) => a.paused), "nothing plays");
}));
test("music: every Sunset Drive road has a song, and every song is a real track", () => {
const tracks = new Set(musicNames());
assert.deepEqual(Object.keys(ROAD_MUSIC).sort(), Object.keys(REGIONS).sort(), "a song for every road");
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,611 +0,0 @@
// Plan2Code Web Console - trails: its music tracks, merged into trails-sfx.js beside the sounds; defines only.
//
// Fourteen tracks, one dealt to each arena of a round (MUSIC_TRACKS and dealMusic in
// trails.js), picked on the pages in prototypes/music/light-trails. Most are dark,
// cinematic grid electro in minor keys at 96 to 120 bpm: a driving sawtooth bass (in
// threes against the beat, or a walking eighth-note ostinato), a sixteenth sequence
// ticking over a held note, sawtooth brass and a long pulse lead; the last three
// lean cyberpunk and synthwave. Each is the shape music.js documents,
// { bpm, rush, voices, patterns, order }, and builds with the heat: the bass, drums
// and sequence while a heat lines up, then the brass and lead once the riders go.
// A name may be defined only once across tones.js and every game's file. No imports.
export const TRAILS_MUSIC = {
// Grid electro: A TRON-style D minor electro at 120: a sequenced sawtooth bass in groups of three
// against the beat, a cold sixteenth sequence that walks its top note, dotted brass stabs, and a
// heroic lead; the chorus rises through B-flat and C to a bright A major.
trailsGridElectro: {
bpm: 120,
rush: 10,
voices: {
bass: { wave: "sawtooth", gain: 0.42, decay: 0.05, sustain: 0.3 },
drums: { kit: true, gain: 0.8, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.2, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.13, decay: 0.1, sustain: 0.7, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C3 C2 C2 A1 A1 A2 A1 A1 A2 C#2 E2",
drums: "k . h . s . h . k . h . s . h . | k . h . s . h . k . h . s . h k | k . h . s . h . k . h . s . h . | k . h . s . h k k . s . s s s s",
seq: "D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 F5 A4 E5 A4 F5 A4 | D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 G5 A4 F5 A4 E5 A4 | D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 G5 Bb4 F5 Bb4 | E5 C5 G5 C5 E5 C5 G5 C5 E5 C#5 A5 C#5 E5 C#5 G5 C#5",
},
B: {
bass: "D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C3 C2 C2 A1 A1 A2 A1 A1 A2 C#2 E2",
drums: "kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h s . s s s s s s",
seq: "D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 F5 A4 E5 A4 F5 A4 | D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 G5 A4 F5 A4 E5 A4 | D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 G5 Bb4 F5 Bb4 | E5 C5 G5 C5 E5 C5 G5 C5 E5 C#5 A5 C#5 E5 C#5 G5 C#5",
brass: "D4^037 - - . . . D4^037 - - . . . D4^037 - - . | D4^037 - - . . . D4^037 - - . . . D4^037 - - . | Bb3^047 - - . . . Bb3^047 - - . . . Bb3^047 - - . | C4^047 - - . . . C4^047 - A3^047 - - . . . A3^047 -",
lead: "D6 - - - - - - - C6 - A5 - - - F5 - | G5 - - - A5 - - - F5 - - - E5 - D5 - | F5 - - - - - - - D6 - - - C6 - Bb5 - | C6 - - - - - - - C#6 - - - E6 - - -",
},
C: {
bass: "Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 C2 C3 A1 A2",
drums: "k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k s s s s s s s s",
seq: "F5 D5 Bb4 D5 F5 D5 Bb4 D5 F5 D5 Bb4 D5 F5 D5 Bb4 D5 | G5 E5 C5 E5 G5 E5 C5 E5 G5 E5 C5 E5 G5 E5 C5 E5 | E5 C#5 A4 C#5 E5 C#5 A4 C#5 E5 C#5 A4 C#5 E5 C#5 A4 C#5 | F5 D5 A4 D5 F5 D5 A4 D5 F5 D5 A4 D5 A5 F5 D5 A4",
brass: "Bb3^047 - - - - - - - - - - - - - - - | C4^047 - - - - - - - - - - - - - - - | A3^047 - - - - - - - - - - - - - - - | D4^037 - - - - - - - - - - - - - - -",
lead: "D6 - - - F6 - - - D6 - - - Bb5 - C6 - | E6 - - - G6 - - - E6 - - - C6 - D6 - | C#6 - - - E6 - - - A5 - - - C#6 - E6 - | D6 - - - - - - - - - - - . . . .",
},
D: {
bass: "D2 - - - - - - - - - - - - - - - | D2 - - - - - - - - - - - - - - - | Bb1 - - - - - - - - - - - - - - - | A1 - - - - - - - A1 - - - A1 - A1 -",
drums: ". . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h . | . . h . . . h . . . h . . . h . | s . s . s . s . s s s s s s s s",
seq: "D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 F5 A4 E5 A4 F5 A4 | D5 A4 F5 A4 D5 A4 F5 A4 D5 A4 G5 A4 F5 A4 E5 A4 | D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 G5 Bb4 F5 Bb4 | E5 C#5 A5 C#5 E5 C#5 A5 C#5 E5 C#5 A5 C#5 G5 E5 C#5 A4",
lead: "A5 - - - - - - - - - - - - - - - | G5 - - - - - - - F5 - - - - - - - | F5 - - - - - - - - - - - - - - - | E5 - - - - - - - C#5 - - - - - - -",
},
},
order: ["A", "B", "C", "D", "B", "C"],
},
// Recognizer: Something huge patrolling overhead at 104: a heavy eighth-note ostinato that walks
// down to G at the end of each bar, big half-time snares and slow brass swells; the chorus pounds
// up through A-flat and B-flat to a high G, and the last section slips onto a menacing D-flat.
trailsRecognizer: {
bpm: 104,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "C2 - C2 - C3 - C2 - C2 - C2 - Bb1 - G1 - | Ab1 - Ab1 - Ab2 - Ab1 - Ab1 - Ab1 - G1 - F1 - | F1 - F1 - F2 - F1 - F1 - F1 - Ab1 - Bb1 - | G1 - G1 - G2 - G1 - G1 - G1 - B1 - D2 -",
drums: "k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . . . . . s . s . s s s s",
seq: "C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 D5 G4 Eb5 G4 | C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 F5 Ab4 Eb5 Ab4 | C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 Bb4 F4 Ab4 F4 | B4 G4 D5 G4 B4 G4 D5 G4 B4 G4 D5 G4 F5 G4 D5 B4",
},
B: {
bass: "C2 - C2 - C3 - C2 - C2 - C2 - Bb1 - G1 - | Ab1 - Ab1 - Ab2 - Ab1 - Ab1 - Ab1 - G1 - F1 - | F1 - F1 - F2 - F1 - F1 - F1 - Ab1 - Bb1 - | G1 - G1 - G2 - G1 - G1 - G1 - B1 - D2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 D5 G4 Eb5 G4 | C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 F5 Ab4 Eb5 Ab4 | C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 Bb4 F4 Ab4 F4 | B4 G4 D5 G4 B4 G4 D5 G4 B4 G4 D5 G4 F5 G4 D5 B4",
brass: "C4^037 - - - - - - - - - - - C4^037 - - - | Ab3^047 - - - - - - - - - - - Ab3^047 - - - | F3^037 - - - - - - - - - - - F3^037 - - - | G3^047 - - - - - - - G3^047a - - - G3^047a - - -",
lead: "G5 - - - - - - - - - - - Ab5 - G5 - | Eb5 - - - - - - - - - - - F5 - Eb5 - | C5 - - - - - - - Eb5 - - - F5 - - - | D5 - - - - - - - B4 - - - - - - -",
},
C: {
bass: "Ab1 Ab1 Ab2 Ab1 Ab1 Ab1 Ab2 Ab1 Ab1 Ab1 Ab2 Ab1 Ab1 Ab2 Ab1 Ab2 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb1 Bb2 Bb1 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C2 C3 C2 C2 C2 C3 C2 C2 C3 C2 C3 | G1 G1 G2 G1 G1 G1 G2 G1 G1 G1 G2 G1 B1 B1 D2 D2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "Eb5 C5 Ab4 C5 Eb5 C5 Ab4 C5 Eb5 C5 Ab4 C5 Eb5 C5 Ab4 C5 | F5 D5 Bb4 D5 F5 D5 Bb4 D5 F5 D5 Bb4 D5 F5 D5 Bb4 D5 | G5 Eb5 C5 Eb5 G5 Eb5 C5 Eb5 G5 Eb5 C5 Eb5 G5 Eb5 C5 Eb5 | G5 D5 B4 D5 G5 D5 B4 D5 G5 D5 B4 D5 F5 D5 B4 G4",
brass: "Ab3^047 - - - - - - - - - - - - - - - | Bb3^047 - - - - - - - - - - - - - - - | C4^037 - - - - - - - - - - - - - - - | G3^047 - - - - - - - - - - - - - - -",
lead: "C6 - - - - - - - Eb6 - - - C6 - Ab5 - | D6 - - - - - - - F6 - - - D6 - Bb5 - | Eb6 - - - - - - - G6 - - - F6 - Eb6 - | D6 - - - - - - - B5 - - - G5 - - -",
},
D: {
bass: "C2 - C2 - C3 - C2 - C2 - C2 - Bb1 - G1 - | Db2 - Db2 - Db3 - Db2 - Db2 - Db2 - C2 - Bb1 - | C2 - C2 - C3 - C2 - C2 - C2 - Bb1 - G1 - | G1 - G1 - G2 - G1 - G1 - G1 - B1 - D2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 D5 G4 Eb5 G4 | Db5 Ab4 F5 Ab4 Db5 Ab4 F5 Ab4 Db5 Ab4 F5 Ab4 Eb5 Ab4 F5 Ab4 | C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 D5 G4 Eb5 G4 | B4 G4 D5 G4 B4 G4 D5 G4 B4 G4 D5 G4 F5 G4 D5 B4",
brass: "C4^037 - - - - - - - - - - - - - - - | Db4^047 - - - - - - - - - - - - - - - | C4^037 - - - - - - - - - - - - - - - | G3^047 - - - - - - - - - - - - - - -",
lead: "C6 - - - - - - - - - - - - - - - | Db6 - - - - - - - - - - - C6 - - - | Eb6 - - - - - - - - - - - D6 - C6 - | B5 - - - - - - - D6 - - - G6 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Mainframe: A minor at 112: a sawtooth bass in threes against the beat, a sequence that ticks
// over a low A pedal and reaches up to G, dotted brass and a lead that leaps a fourth and
// settles; the chorus climbs F, G, A minor to a harmonic-minor E7, and the break slides onto a
// dark B-flat.
trailsMainframe: {
bpm: 112,
rush: 12,
voices: {
bass: { wave: "sawtooth", gain: 0.42, decay: 0.05, sustain: 0.3 },
drums: { kit: true, gain: 0.8, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.2, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.13, decay: 0.12, sustain: 0.75, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "k . h . s . h . k . h . s . h . | k . h . s . h . k . h . s . h k | k . h . s . h . k . h . s . h . | k . h . s . h k k . s . s s s s",
seq: "C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 E5 A4 F5 A4 E5 A4 | C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 G5 A4 F5 A4 E5 A4 | C5 A4 F5 A4 C5 A4 F5 A4 C5 A4 F5 A4 G5 A4 F5 A4 | B4 G#4 E5 G#4 B4 G#4 E5 G#4 B4 G#4 E5 G#4 F5 E5 D5 B4",
},
B: {
bass: "A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h s . s s s s s s",
seq: "C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 E5 A4 F5 A4 E5 A4 | C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 G5 A4 F5 A4 E5 A4 | C5 A4 F5 A4 C5 A4 F5 A4 C5 A4 F5 A4 G5 A4 F5 A4 | B4 G#4 E5 G#4 B4 G#4 E5 G#4 B4 G#4 E5 G#4 F5 E5 D5 B4",
brass: "A3^037 - - . . . A3^037 - - . . . A3^037 - - . | A3^037 - - . . . A3^037 - - . . . A3^037 - - . | F3^047 - - . . . F3^047 - - . . . F3^047 - - . | E3^047 - - . . . E3^047 - - . E3^047 - E3^047 - - .",
lead: "E5 - - - - - - - A5 - - - - - G5 - | E5 - - - - - - - C5 - - - D5 - E5 - | F5 - - - - - - - A5 - - - C6 - - - | B5 - - - - - - - G#5 - - - E5 - - -",
},
C: {
bass: "F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "C5 A4 F5 A4 C5 A4 F5 A4 C5 A4 F5 A4 A5 A4 F5 A4 | D5 B4 G5 B4 D5 B4 G5 B4 D5 B4 G5 B4 B5 B4 G5 B4 | E5 C5 A5 C5 E5 C5 A5 C5 E5 C5 A5 C5 C6 C5 A5 C5 | E5 B4 G#5 B4 E5 B4 G#5 B4 E5 B4 G#5 B4 B5 G#5 E5 B4",
brass: "F3^047 - - - - - - - - - - - - - - - | G3^047 - - - - - - - - - - - - - - - | A3^037 - - - - - - - - - - - - - - - | E3^047 - - - - - - - E3^047a - - - - - - -",
lead: "A5 - - - - - - - C6 - - - F6 - - - | D6 - - - - - - - B5 - - - G5 - - - | C6 - - - - - - - E6 - - - D6 - C6 - | B5 - - - - - - - G#5 - - - E5 - - -",
},
D: {
bass: "A1 - - - - - - - A2 - - - - - - - | Bb1 - - - - - - - Bb2 - - - - - - - | A1 - - - - - - - A2 - - - - - - - | E1 - - - E2 - - - E1 - E1 - E2 E2 E2 E2",
drums: "k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . . . . . s . s . s s s s",
seq: "C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 E5 A4 F5 A4 E5 A4 | D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 G5 Bb4 F5 Bb4 | C5 A4 E5 A4 C5 A4 E5 A4 C5 A4 E5 A4 F5 A4 E5 A4 | B4 G#4 E5 G#4 B4 G#4 E5 G#4 B4 G#4 E5 G#4 F5 E5 D5 B4",
brass: "A3^037 - - - - - - - - - - - - - - - | Bb3^047 - - - - - - - - - - - - - - - | A3^037 - - - - - - - - - - - - - - - | E3^047 - - - - - - - - - - - - - - -",
lead: "A5 - - - - - - - - - - - - - - - | Bb5 - - - - - - - - - - - A5 - - - | C6 - - - - - - - - - - - B5 - A5 - | G#5 - - - - - - - B5 - - - E6 - - -",
},
},
order: ["A", "B", "C", "B", "D", "C"],
},
// Black ICE: Cold F minor at 108: an eighth-note ostinato that dips to the seventh and fifth in
// every bar, half-time snares, swelling brass and a lead that falls in slow steps; the chorus
// switches to the three-against-four bass over D-flat and E-flat, and the last section slips onto
// a Neapolitan G-flat.
trailsBlackIce: {
bpm: 108,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "F1 - F1 - F2 - F1 - Eb2 - F1 - C2 - F1 - | Db2 - Db2 - Db3 - Db2 - C3 - Db2 - Ab1 - Db2 - | Bb1 - Bb1 - Bb2 - Bb1 - Ab2 - Bb1 - F1 - Bb1 - | C2 - C2 - C3 - C2 - Bb2 - C2 - E2 - G2 -",
drums: "k . . . . . h . s . . . . . h . | k . . . . . h . s . . . . . h k | k . . . . . h . s . . . . . h . | k . . . . . h . s . s . s s s s",
seq: "Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Db5 F4 C5 F4 | Ab4 F4 Db5 F4 Ab4 F4 Db5 F4 Ab4 F4 Db5 F4 Eb5 F4 Db5 F4 | Bb4 F4 Db5 F4 Bb4 F4 Db5 F4 Bb4 F4 Db5 F4 Eb5 F4 Db5 F4 | Bb4 E4 C5 E4 G4 E4 C5 E4 Bb4 E4 C5 E4 Db5 C5 Bb4 G4",
},
B: {
bass: "F1 - F1 - F2 - F1 - Eb2 - F1 - C2 - F1 - | Db2 - Db2 - Db3 - Db2 - C3 - Db2 - Ab1 - Db2 - | Bb1 - Bb1 - Bb2 - Bb1 - Ab2 - Bb1 - F1 - Bb1 - | C2 - C2 - C3 - C2 - Bb2 - C2 - E2 - G2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Db5 F4 C5 F4 | Ab4 F4 Db5 F4 Ab4 F4 Db5 F4 Ab4 F4 Db5 F4 Eb5 F4 Db5 F4 | Bb4 F4 Db5 F4 Bb4 F4 Db5 F4 Bb4 F4 Db5 F4 Eb5 F4 Db5 F4 | Bb4 E4 C5 E4 G4 E4 C5 E4 Bb4 E4 C5 E4 Db5 C5 Bb4 G4",
brass: "F3^037 - - - - - - - - - - - F3^037 - - - | Db4^047 - - - - - - - - - - - Db4^047 - - - | Bb3^037 - - - - - - - - - - - Bb3^037 - - - | C4^047 - - - - - - - C4^047a - - - C4^047a - - -",
lead: "C6 - - - - - - - Ab5 - - - G5 - F5 - | F5 - - - - - - - - - - - Eb5 - Db5 - | Db5 - - - - - - - F5 - - - Bb5 - - - | G5 - - - - - - - E5 - - - C5 - - -",
},
C: {
bass: "Db2 Db2 Db3 Db2 Db2 Db3 Db2 Db2 Db3 Db2 Db2 Db3 Db2 Db3 Db2 Db3 | Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb3 Eb2 Eb3 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 E2 G2 Bb2 C3",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "F5 Db5 Ab5 Db5 F5 Db5 Ab5 Db5 F5 Db5 Ab5 Db5 Bb5 Db5 Ab5 Db5 | G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 C6 Eb5 Bb5 Eb5 | Ab5 F5 C6 F5 Ab5 F5 C6 F5 Ab5 F5 C6 F5 Db6 F5 C6 F5 | G5 E5 C6 E5 G5 E5 C6 E5 G5 E5 Bb5 E5 C6 Bb5 G5 E5",
brass: "Db4^047 - - - - - - - - - - - - - - - | Eb4^047 - - - - - - - - - - - - - - - | F3^037 - - - - - - - - - - - - - - - | C4^047 - - - - - - - - - - - - - - -",
lead: "Ab5 - - - - - - - F5 - - - Db6 - - - | Bb5 - - - - - - - G5 - - - Eb6 - - - | C6 - - - - - - - Ab5 - - - F6 - Eb6 - | E6 - - - - - - - C6 - - - G5 - - -",
},
D: {
bass: "F1 - F1 - F2 - F1 - Eb2 - F1 - C2 - F1 - | Gb1 - Gb1 - Gb2 - Gb1 - F2 - Gb1 - Db2 - Gb1 - | F1 - F1 - F2 - F1 - Eb2 - F1 - C2 - F1 - | C2 - C2 - C3 - C2 - Bb2 - C2 - E2 - G2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Db5 F4 C5 F4 | Bb4 Gb4 Db5 Gb4 Bb4 Gb4 Db5 Gb4 Bb4 Gb4 Db5 Gb4 Eb5 Gb4 Db5 Gb4 | Ab4 F4 C5 F4 Ab4 F4 C5 F4 Ab4 F4 C5 F4 Db5 F4 C5 F4 | Bb4 E4 C5 E4 G4 E4 C5 E4 Bb4 E4 C5 E4 Db5 C5 Bb4 G4",
brass: "F3^037 - - - - - - - - - - - - - - - | Gb3^047 - - - - - - - - - - - - - - - | F3^037 - - - - - - - - - - - - - - - | C4^047 - - - - - - - - - - - - - - -",
lead: "F5 - - - - - - - - - - - - - - - | Gb5 - - - - - - - - - - - F5 - - - | Ab5 - - - - - - - - - - - G5 - F5 - | E5 - - - - - - - G5 - - - C6 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Sentinel: E minor at 100, slow and enormous: a deep three-against-four bass under half-time
// drums, a sequence ringing over a high E pedal, and a lead that rises B, E, G like a call; the
// chorus leaps a sixth over C and D, and the bridge leans on a Phrygian F before the last chorus.
trailsSentinel: {
bpm: 100,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.05, sustain: 0.32 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E2 E1 E2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | B1 B1 B2 B1 B1 B2 B1 B1 B2 B1 B1 B2 D#2 F#2 A2 B2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 A5 E5 B5 E5 | G5 E5 C6 E5 G5 E5 C6 E5 G5 E5 C6 E5 D6 E5 C6 E5 | A5 E5 C6 E5 A5 E5 C6 E5 A5 E5 C6 E5 B5 E5 C6 E5 | F#5 D#5 B5 D#5 F#5 D#5 B5 D#5 F#5 D#5 A5 D#5 B5 A5 F#5 D#5",
},
B: {
bass: "E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E2 E1 E2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | B1 B1 B2 B1 B1 B2 B1 B1 B2 B1 B1 B2 D#2 F#2 A2 B2",
drums: "k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . s s s s s s",
seq: "G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 A5 E5 B5 E5 | G5 E5 C6 E5 G5 E5 C6 E5 G5 E5 C6 E5 D6 E5 C6 E5 | A5 E5 C6 E5 A5 E5 C6 E5 A5 E5 C6 E5 B5 E5 C6 E5 | F#5 D#5 B5 D#5 F#5 D#5 B5 D#5 F#5 D#5 A5 D#5 B5 A5 F#5 D#5",
brass: "E4^037 - - - - - - - - - - - E4^037 - - - | C4^047 - - - - - - - - - - - C4^047 - - - | A3^037 - - - - - - - - - - - A3^037 - - - | B3^047 - - - - - - - B3^047a - - - B3^047a - - -",
lead: "B4 - - - E5 - - - G5 - - - - - F#5 - | E5 - - - - - - - - - - - D5 - C5 - | A4 - - - C5 - - - E5 - - - A5 - - - | F#5 - - - - - - - D#5 - - - B4 - - -",
},
C: {
bass: "C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E2 E1 E2 | E1 E1 E2 E1 E1 E2 E1 E1 B1 B1 B2 B1 D#2 F#2 A2 B2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "E5 C5 G5 C5 E5 C5 G5 C5 E5 C5 G5 C5 A5 C5 G5 C5 | F#5 D5 A5 D5 F#5 D5 A5 D5 F#5 D5 A5 D5 B5 D5 A5 D5 | G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 C6 E5 B5 E5 | G5 E5 B5 E5 G5 E5 B5 E5 F#5 D#5 B5 D#5 A5 F#5 D#5 B4",
brass: "C4^047 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - - | E4^037 - - - - - - - - - - - - - - - | E4^037 - - - - - - - B3^047 - - - - - - -",
lead: "G5 - - - - - - - E6 - - - - - D6 - | A5 - - - - - - - F#6 - - - - - E6 - | E6 - - - - - - - B5 - - - G5 - - - | F#5 - - - - - - - D#6 - - - B5 - - -",
},
D: {
bass: "E1 - - - - - - - E2 - - - - - - - | F1 - - - - - - - F2 - - - - - - - | E1 - - - - - - - E2 - - - - - - - | B1 - - - B2 - - - B1 - B1 - B2 B2 B2 B2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 A5 E5 B5 E5 | A5 F5 C6 F5 A5 F5 C6 F5 A5 F5 C6 F5 D6 F5 C6 F5 | G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 A5 E5 B5 E5 | F#5 D#5 B5 D#5 F#5 D#5 B5 D#5 F#5 D#5 A5 D#5 B5 A5 F#5 D#5",
brass: "E4^037 - - - - - - - - - - - - - - - | F4^047 - - - - - - - - - - - - - - - | E4^037 - - - - - - - - - - - - - - - | B3^047 - - - - - - - - - - - - - - -",
lead: "B5 - - - - - - - - - - - - - - - | C6 - - - - - - - - - - - B5 - - - | B5 - - - - - - - G5 - - - E5 - - - | D#5 - - - - - - - F#5 - - - B5 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Throne of the grid: G minor at 116, stately and grim: a three-against-four bass, a marching
// brass figure that hits twice and pauses, and a lead that climbs G, B-flat, then falls; the
// chorus moves to C minor and E-flat and hangs on D7, and a half-time bridge rises a step a bar
// from A-flat to D.
trailsThrone: {
bpm: 116,
rush: 12,
voices: {
bass: { wave: "sawtooth", gain: 0.42, decay: 0.05, sustain: 0.3 },
drums: { kit: true, gain: 0.8, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.2, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.13, decay: 0.1, sustain: 0.7, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb3 Eb2 Eb3 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 F#2 A2 C3 D3",
drums: "k . h . s . h . k . h . s . h . | k . h . s . h . k . h . s . h k | k . h . s . h . k . h . s . h . | k . h . s . h k k . s . s s s s",
seq: "Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 C5 G4 D5 G4 | Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 F5 G4 Eb5 G4 | C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 F5 G4 Eb5 G4 | A4 F#4 D5 F#4 A4 F#4 D5 F#4 A4 F#4 C5 F#4 D5 C5 A4 F#4",
},
B: {
bass: "G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb3 Eb2 Eb3 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 F#2 A2 C3 D3",
drums: "kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h s . s s s s s s",
seq: "Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 C5 G4 D5 G4 | Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 F5 G4 Eb5 G4 | C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 F5 G4 Eb5 G4 | A4 F#4 D5 F#4 A4 F#4 D5 F#4 A4 F#4 C5 F#4 D5 C5 A4 F#4",
brass: "G3^037 - . G3^037 G3^037 - . . G3^037 - . G3^037 G3^037 - . . | Eb3^047 - . Eb3^047 Eb3^047 - . . Eb3^047 - . Eb3^047 Eb3^047 - . . | C4^037 - . C4^037 C4^037 - . . C4^037 - . C4^037 C4^037 - . . | D4^047 - . D4^047 D4^047 - . . D4^047 - . D4^047 D4^047 - . .",
lead: "D5 - - - G5 - - - Bb5 - - - - - A5 - | G5 - - - - - - - Eb5 - - - F5 - G5 - | Eb5 - - - - - - - G5 - - - C6 - - - | A5 - - - - - - - F#5 - - - D5 - - -",
},
C: {
bass: "C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb3 Eb2 Eb3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 F#2 A2 C3 D3",
drums: "k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "Eb5 C5 G5 C5 Eb5 C5 G5 C5 Eb5 C5 G5 C5 Ab5 C5 G5 C5 | G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 C6 Eb5 Bb5 Eb5 | F#5 D5 A5 D5 F#5 D5 A5 D5 F#5 D5 A5 D5 Bb5 D5 A5 D5 | F#5 D5 A5 D5 F#5 D5 C6 D5 F#5 D5 A5 D5 C6 A5 F#5 D5",
brass: "C4^037 - - - - - - - - - - - - - - - | Eb4^047 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - - | D4^047a - - - - - - - - - - - - - - -",
lead: "G5 - - - - - - - C6 - - - Eb6 - - - | Bb5 - - - - - - - Eb6 - - - D6 - C6 - | A5 - - - - - - - D6 - - - F#6 - - - | D6 - - - - - - - - - - - . . . .",
},
D: {
bass: "Ab1 - - - - - - - Ab2 - - - - - - - | Bb1 - - - - - - - Bb2 - - - - - - - | C2 - - - - - - - C3 - - - - - - - | D2 - - - D3 - - - D2 - D2 - D3 D3 D3 D3",
drums: "k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . . . . . s . . . . . . . | k . . . s . . . s . s . s s s s",
seq: "C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 F5 Ab4 Eb5 Ab4 | D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 D5 Bb4 F5 Bb4 G5 Bb4 F5 Bb4 | Eb5 C5 G5 C5 Eb5 C5 G5 C5 Eb5 C5 G5 C5 Ab5 C5 G5 C5 | F#5 D5 A5 D5 F#5 D5 A5 D5 F#5 D5 A5 D5 C6 A5 F#5 D5",
brass: "Ab3^047 - - - - - - - - - - - - - - - | Bb3^047 - - - - - - - - - - - - - - - | C4^037 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - -",
lead: "Eb5 - - - - - - - C5 - - - Ab5 - - - | F5 - - - - - - - D5 - - - Bb5 - - - | G5 - - - - - - - Eb5 - - - C6 - - - | A5 - - - - - - - D6 - - - F#6 - - -",
},
},
order: ["A", "B", "C", "B", "D", "C"],
},
// Siege: B minor at 104: a heavy eighth-note ostinato with a sixteenth pickup in the middle of
// each bar, double-hit snares and slow brass swells, and a lead that drops a fourth and climbs
// back; the chorus lifts through G, A and B minor to a high F#, and the last section turns on a
// Neapolitan C major.
trailsSiege: {
bpm: 104,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "B1 - B1 - B2 - B1 B1 B1 - B1 - A1 - F#1 - | G1 - G1 - G2 - G1 G1 G1 - G1 - F#1 - E1 - | E1 - E1 - E2 - E1 E1 E1 - E1 - G1 - A1 - | F#1 - F#1 - F#2 - F#1 F#1 F#1 - F#1 - A#1 - C#2 -",
drums: "k . . . . . . . s . . s . . . . | k . . . . . . . s . . s . . . . | k . . . . . . . s . . s . . . . | k . . . . . . . s . s . s s s s",
seq: "D5 B4 F#5 B4 D5 B4 F#5 B4 D5 B4 F#5 B4 G5 B4 F#5 B4 | D5 B4 G5 B4 D5 B4 G5 B4 D5 B4 G5 B4 A5 B4 G5 B4 | E5 B4 G5 B4 E5 B4 G5 B4 E5 B4 G5 B4 A5 B4 G5 B4 | C#5 A#4 F#5 A#4 C#5 A#4 F#5 A#4 C#5 A#4 E5 A#4 F#5 E5 C#5 A#4",
},
B: {
bass: "B1 - B1 - B2 - B1 B1 B1 - B1 - A1 - F#1 - | G1 - G1 - G2 - G1 G1 G1 - G1 - F#1 - E1 - | E1 - E1 - E2 - E1 E1 E1 - E1 - G1 - A1 - | F#1 - F#1 - F#2 - F#1 F#1 F#1 - F#1 - A#1 - C#2 -",
drums: "k . h . h . h . s . h s h . h k | k . h . h . h . s . h s h . h k | k . h . h . h . s . h s h . h k | k . h . h . h . s . s s s s s s",
seq: "D5 B4 F#5 B4 D5 B4 F#5 B4 D5 B4 F#5 B4 G5 B4 F#5 B4 | D5 B4 G5 B4 D5 B4 G5 B4 D5 B4 G5 B4 A5 B4 G5 B4 | E5 B4 G5 B4 E5 B4 G5 B4 E5 B4 G5 B4 A5 B4 G5 B4 | C#5 A#4 F#5 A#4 C#5 A#4 F#5 A#4 C#5 A#4 E5 A#4 F#5 E5 C#5 A#4",
brass: "B3^037 - - - - - - - - - - - B3^037 - - - | G3^047 - - - - - - - - - - - G3^047 - - - | E3^037 - - - - - - - - - - - E3^037 - - - | F#3^047 - - - - - - - F#3^047a - - - F#3^047a - - -",
lead: "B5 - - - - - - - F#5 - - - - - - - | G5 - - - - - - - D5 - - - E5 - F#5 - | G5 - - - - - - - B5 - - - E6 - - - | C#6 - - - - - - - A#5 - - - F#5 - - -",
},
C: {
bass: "G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | B1 B1 B2 B1 B1 B2 B1 B1 B2 B1 B1 B2 B1 B2 B1 B2 | F#1 F#1 F#2 F#1 F#1 F#2 F#1 F#1 F#2 F#1 F#1 F#2 A#1 C#2 E2 F#2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "D5 B4 G5 B4 D5 B4 G5 B4 D5 B4 G5 B4 A5 B4 G5 B4 | E5 C#5 A5 C#5 E5 C#5 A5 C#5 E5 C#5 A5 C#5 B5 C#5 A5 C#5 | F#5 D5 B5 D5 F#5 D5 B5 D5 F#5 D5 B5 D5 C#6 D5 B5 D5 | F#5 C#5 A#5 C#5 F#5 C#5 A#5 C#5 F#5 C#5 A#5 C#5 E6 C#6 A#5 F#5",
brass: "G3^047 - - - - - - - - - - - - - - - | A3^047 - - - - - - - - - - - - - - - | B3^037 - - - - - - - - - - - - - - - | F#3^047 - - - - - - - - - - - - - - -",
lead: "D6 - - - - - - - B5 - - - G5 - - - | E6 - - - - - - - C#6 - - - A5 - - - | F#6 - - - - - - - D6 - - - B5 - - - | A#5 - - - - - - - C#6 - - - F#6 - - -",
},
D: {
bass: "B1 - B1 - B2 - B1 B1 B1 - B1 - A1 - F#1 - | C2 - C2 - C3 - C2 C2 C2 - C2 - B1 - A1 - | B1 - B1 - B2 - B1 B1 B1 - B1 - A1 - F#1 - | F#1 - F#1 - F#2 - F#1 F#1 F#1 - F#1 - A#1 - C#2 -",
drums: "k . h . h . h . s . h s h . h k | k . h . h . h . s . h s h . h k | k . h . h . h . s . h s h . h k | k . h . h . h . s . s s s s s s",
seq: "D5 B4 F#5 B4 D5 B4 F#5 B4 D5 B4 F#5 B4 G5 B4 F#5 B4 | E5 C5 G5 C5 E5 C5 G5 C5 E5 C5 G5 C5 A5 C5 G5 C5 | D5 B4 F#5 B4 D5 B4 F#5 B4 D5 B4 F#5 B4 G5 B4 F#5 B4 | C#5 A#4 F#5 A#4 C#5 A#4 F#5 A#4 C#5 A#4 E5 A#4 F#5 E5 C#5 A#4",
brass: "B3^037 - - - - - - - - - - - - - - - | C4^047 - - - - - - - - - - - - - - - | B3^037 - - - - - - - - - - - - - - - | F#3^047 - - - - - - - - - - - - - - -",
lead: "B5 - - - - - - - - - - - - - - - | C6 - - - - - - - - - - - B5 - - - | D6 - - - - - - - - - - - C#6 - B5 - | A#5 - - - - - - - C#6 - - - F#6 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Iron gate: E minor at 104 behind a slow-opening gate: an eighth-note ostinato that dips to the
// seventh and the fifth, half-time snares, a low sequence and swelling brass under a lead that
// steps down from B; the chorus switches to the three-against-four bass over C, D and E minor,
// and the last section leans on a Phrygian F.
trailsIronGate: {
bpm: 104,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "E1 - E1 - E2 - E1 - D2 - E1 - B1 - E1 - | C2 - C2 - C3 - C2 - B2 - C2 - G1 - C2 - | A1 - A1 - A2 - A1 - G2 - A1 - E1 - A1 - | B1 - B1 - B2 - B1 - A2 - B1 - D#2 - F#2 -",
drums: "k . . . . . h . s . . . . . h . | k . . . . . h . s . . . . . h k | k . . . . . h . s . . . . . h . | k . . . . . h . s . s . s s s s",
seq: "G4 E4 B4 E4 G4 E4 B4 E4 G4 E4 B4 E4 C5 E4 B4 E4 | G4 E4 C5 E4 G4 E4 C5 E4 G4 E4 C5 E4 D5 E4 C5 E4 | A4 E4 C5 E4 A4 E4 C5 E4 A4 E4 C5 E4 D5 E4 C5 E4 | F#4 D#4 B4 D#4 F#4 D#4 B4 D#4 F#4 D#4 A4 D#4 B4 A4 F#4 D#4",
},
B: {
bass: "E1 - E1 - E2 - E1 - D2 - E1 - B1 - E1 - | C2 - C2 - C3 - C2 - B2 - C2 - G1 - C2 - | A1 - A1 - A2 - A1 - G2 - A1 - E1 - A1 - | B1 - B1 - B2 - B1 - A2 - B1 - D#2 - F#2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "G4 E4 B4 E4 G4 E4 B4 E4 G4 E4 B4 E4 C5 E4 B4 E4 | G4 E4 C5 E4 G4 E4 C5 E4 G4 E4 C5 E4 D5 E4 C5 E4 | A4 E4 C5 E4 A4 E4 C5 E4 A4 E4 C5 E4 D5 E4 C5 E4 | F#4 D#4 B4 D#4 F#4 D#4 B4 D#4 F#4 D#4 A4 D#4 B4 A4 F#4 D#4",
brass: "E4^037 - - - - - - - - - - - E4^037 - - - | C4^047 - - - - - - - - - - - C4^047 - - - | A3^037 - - - - - - - - - - - A3^037 - - - | B3^047 - - - - - - - B3^047a - - - B3^047a - - -",
lead: "B5 - - - - - - - G5 - - - F#5 - E5 - | E5 - - - - - - - - - - - D5 - C5 - | C5 - - - - - - - E5 - - - A5 - - - | F#5 - - - - - - - D#5 - - - B4 - - -",
},
C: {
bass: "C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E2 E1 E2 | B1 B1 B2 B1 B1 B2 B1 B1 B2 B1 B1 B2 D#2 F#2 A2 B2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "E5 C5 G5 C5 E5 C5 G5 C5 E5 C5 G5 C5 A5 C5 G5 C5 | F#5 D5 A5 D5 F#5 D5 A5 D5 F#5 D5 A5 D5 B5 D5 A5 D5 | G5 E5 B5 E5 G5 E5 B5 E5 G5 E5 B5 E5 C6 E5 B5 E5 | F#5 D#5 B5 D#5 F#5 D#5 B5 D#5 F#5 D#5 A5 D#5 B5 A5 F#5 D#5",
brass: "C4^047 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - - | E4^037 - - - - - - - - - - - - - - - | B3^047 - - - - - - - - - - - - - - -",
lead: "E6 - - - - - - - C6 - - - G5 - - - | F#6 - - - - - - - D6 - - - A5 - - - | E6 - - - - - - - B5 - - - G5 - B5 - | D#6 - - - - - - - F#6 - - - - - - -",
},
D: {
bass: "E1 - E1 - E2 - E1 - D2 - E1 - B1 - E1 - | F1 - F1 - F2 - F1 - Eb2 - F1 - C2 - F1 - | E1 - E1 - E2 - E1 - D2 - E1 - B1 - E1 - | B1 - B1 - B2 - B1 - A2 - B1 - D#2 - F#2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "G4 E4 B4 E4 G4 E4 B4 E4 G4 E4 B4 E4 C5 E4 B4 E4 | A4 F4 C5 F4 A4 F4 C5 F4 A4 F4 C5 F4 D5 F4 C5 F4 | G4 E4 B4 E4 G4 E4 B4 E4 G4 E4 B4 E4 C5 E4 B4 E4 | F#4 D#4 B4 D#4 F#4 D#4 B4 D#4 F#4 D#4 A4 D#4 B4 A4 F#4 D#4",
brass: "E4^037 - - - - - - - - - - - - - - - | F4^047 - - - - - - - - - - - - - - - | E4^037 - - - - - - - - - - - - - - - | B3^047 - - - - - - - - - - - - - - -",
lead: "E5 - - - - - - - - - - - - - - - | F5 - - - - - - - - - - - E5 - - - | G5 - - - - - - - - - - - F#5 - E5 - | D#5 - - - - - - - F#5 - - - B5 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Sky citadel: A minor at 100, vast and slow: a deep three-against-four bass, half-time drums and
// a sequence that rocks against a high note over each chord, under a lead that calls up E, A, C;
// the chorus climbs F and G to high leaps, and the break hangs on D minor and E7.
trailsSkyCitadel: {
bpm: 100,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "A4 E5 C5 E5 A4 E5 C5 E5 A4 E5 C5 E5 B4 E5 C5 E5 | A4 C5 F4 C5 A4 C5 F4 C5 A4 C5 F4 C5 G4 C5 A4 C5 | B4 D5 G4 D5 B4 D5 G4 D5 B4 D5 G4 D5 A4 D5 B4 D5 | G#4 B4 E4 B4 G#4 B4 E4 B4 G#4 B4 D5 B4 E5 D5 B4 G#4",
},
B: {
bass: "A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . s s s s s s",
seq: "A4 E5 C5 E5 A4 E5 C5 E5 A4 E5 C5 E5 B4 E5 C5 E5 | A4 C5 F4 C5 A4 C5 F4 C5 A4 C5 F4 C5 G4 C5 A4 C5 | B4 D5 G4 D5 B4 D5 G4 D5 B4 D5 G4 D5 A4 D5 B4 D5 | G#4 B4 E4 B4 G#4 B4 E4 B4 G#4 B4 D5 B4 E5 D5 B4 G#4",
brass: "A3^037 - - - - - - - - - - - A3^037 - - - | F3^047 - - - - - - - - - - - F3^047 - - - | G3^047 - - - - - - - - - - - G3^047 - - - | E3^047 - - - - - - - E3^047a - - - E3^047a - - -",
lead: "E5 - - - A5 - - - C6 - - - - - B5 - | A5 - - - - - - - - - - - G5 - F5 - | D5 - - - G5 - - - B5 - - - D6 - - - | B5 - - - - - - - G#5 - - - E5 - - -",
},
C: {
bass: "F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | E1 E1 E2 E1 E1 E2 E1 E1 E2 E1 E1 E2 G#1 B1 D2 E2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "C5 A4 F5 A4 C5 A4 F5 A4 C5 A4 F5 A4 G5 A4 F5 A4 | D5 B4 G5 B4 D5 B4 G5 B4 D5 B4 G5 B4 A5 B4 G5 B4 | E5 C5 A5 C5 E5 C5 A5 C5 E5 C5 A5 C5 B5 C5 A5 C5 | E5 B4 G#5 B4 E5 B4 G#5 B4 E5 B4 G#5 B4 B5 G#5 E5 B4",
brass: "F3^047 - - - - - - - - - - - - - - - | G3^047 - - - - - - - - - - - - - - - | A3^037 - - - - - - - - - - - - - - - | E3^047a - - - - - - - - - - - - - - -",
lead: "C6 - - - - - - - F6 - - - - - E6 - | D6 - - - - - - - G6 - - - - - F6 - | E6 - - - - - - - C6 - - - A5 - - - | B5 - - - - - - - G#5 - - - E6 - - -",
},
D: {
bass: "D2 - - - - - - - D3 - - - - - - - | D2 - - - - - - - C3 - - - - - - - | E1 - - - - - - - E2 - - - - - - - | E1 - - - E2 - - - E1 - E1 - E2 E2 E2 E2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "F5 D5 A5 D5 F5 D5 A5 D5 F5 D5 A5 D5 G5 D5 A5 D5 | F5 D5 A5 D5 F5 D5 A5 D5 F5 D5 Bb5 D5 A5 D5 G5 D5 | E5 B4 G#5 B4 E5 B4 G#5 B4 E5 B4 G#5 B4 A5 B4 G#5 B4 | E5 B4 G#5 B4 E5 B4 D6 B4 E5 B4 G#5 B4 D6 B5 G#5 E5",
brass: "D4^037 - - - - - - - - - - - - - - - | D4^037 - - - - - - - - - - - - - - - | E4^047 - - - - - - - - - - - - - - - | E4^047a - - - - - - - - - - - - - - -",
lead: "A5 - - - - - - - - - - - - - - - | F5 - - - - - - - - - - - E5 - D5 - | E5 - - - - - - - - - - - - - - - | G#5 - - - - - - - B5 - - - D6 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Deep core: G minor at 104, deep under the grid: an eighth-note ostinato that dips to the
// seventh and the fifth, half-time snares, a low sequence and swelling brass under a lead that
// falls from D; the chorus switches to the three-against-four bass over E-flat, F and G minor,
// and the last section turns on a Neapolitan A-flat.
trailsDeepCore: {
bpm: 104,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "G1 - G1 - G2 - G1 - F2 - G1 - D2 - G1 - | Eb2 - Eb2 - Eb3 - Eb2 - D3 - Eb2 - Bb1 - Eb2 - | C2 - C2 - C3 - C2 - Bb2 - C2 - G1 - C2 - | D2 - D2 - D3 - D2 - C3 - D2 - F#2 - A2 -",
drums: "k . . . . . h . s . . . . . h . | k . . . . . h . s . . . . . h k | k . . . . . h . s . . . . . h . | k . . . . . h . s . s . s s s s",
seq: "Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 Eb5 G4 D5 G4 | Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 F5 G4 Eb5 G4 | C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 F5 G4 Eb5 G4 | A4 F#4 D5 F#4 A4 F#4 D5 F#4 A4 F#4 C5 F#4 D5 C5 A4 F#4",
},
B: {
bass: "G1 - G1 - G2 - G1 - F2 - G1 - D2 - G1 - | Eb2 - Eb2 - Eb3 - Eb2 - D3 - Eb2 - Bb1 - Eb2 - | C2 - C2 - C3 - C2 - Bb2 - C2 - G1 - C2 - | D2 - D2 - D3 - D2 - C3 - D2 - F#2 - A2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 Eb5 G4 D5 G4 | Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 Bb4 G4 Eb5 G4 F5 G4 Eb5 G4 | C5 G4 Eb5 G4 C5 G4 Eb5 G4 C5 G4 Eb5 G4 F5 G4 Eb5 G4 | A4 F#4 D5 F#4 A4 F#4 D5 F#4 A4 F#4 C5 F#4 D5 C5 A4 F#4",
brass: "G3^037 - - - - - - - - - - - G3^037 - - - | Eb4^047 - - - - - - - - - - - Eb4^047 - - - | C4^037 - - - - - - - - - - - C4^037 - - - | D4^047 - - - - - - - D4^047a - - - D4^047a - - -",
lead: "D6 - - - - - - - Bb5 - - - A5 - G5 - | G5 - - - - - - - - - - - F5 - Eb5 - | Eb5 - - - - - - - G5 - - - C6 - - - | A5 - - - - - - - F#5 - - - D5 - - -",
},
C: {
bass: "Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb2 Eb3 Eb2 Eb3 Eb2 Eb3 | F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F1 F2 F1 F2 F1 F2 | G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 F#2 A2 C3 D3",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 G5 Eb5 Bb5 Eb5 C6 Eb5 Bb5 Eb5 | A5 F5 C6 F5 A5 F5 C6 F5 A5 F5 C6 F5 D6 F5 C6 F5 | Bb5 G5 D6 G5 Bb5 G5 D6 G5 Bb5 G5 D6 G5 Eb6 G5 D6 G5 | A5 F#5 D6 F#5 A5 F#5 D6 F#5 A5 F#5 C6 F#5 D6 C6 A5 F#5",
brass: "Eb4^047 - - - - - - - - - - - - - - - | F3^047 - - - - - - - - - - - - - - - | G3^037 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - -",
lead: "Bb5 - - - - - - - G5 - - - Eb6 - - - | C6 - - - - - - - A5 - - - F6 - - - | D6 - - - - - - - Bb5 - - - G6 - F6 - | F#6 - - - - - - - D6 - - - A5 - - -",
},
D: {
bass: "G1 - G1 - G2 - G1 - F2 - G1 - D2 - G1 - | Ab1 - Ab1 - Ab2 - Ab1 - G2 - Ab1 - Eb2 - Ab1 - | G1 - G1 - G2 - G1 - F2 - G1 - D2 - G1 - | D2 - D2 - D3 - D2 - C3 - D2 - F#2 - A2 -",
drums: "k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . h . h . h k | k . h . h . h . s . s s s s s s",
seq: "Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 Eb5 G4 D5 G4 | C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 C5 Ab4 Eb5 Ab4 F5 Ab4 Eb5 Ab4 | Bb4 G4 D5 G4 Bb4 G4 D5 G4 Bb4 G4 D5 G4 Eb5 G4 D5 G4 | A4 F#4 D5 F#4 A4 F#4 D5 F#4 A4 F#4 C5 F#4 D5 C5 A4 F#4",
brass: "G3^037 - - - - - - - - - - - - - - - | Ab3^047 - - - - - - - - - - - - - - - | G3^037 - - - - - - - - - - - - - - - | D4^047 - - - - - - - - - - - - - - -",
lead: "G5 - - - - - - - - - - - - - - - | Ab5 - - - - - - - - - - - G5 - - - | Bb5 - - - - - - - - - - - A5 - G5 - | F#5 - - - - - - - A5 - - - D6 - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Monolith: D minor at 98, a black slab on the horizon: a deep three-against-four bass under
// half-time drums, a sequence that rocks against a high note over D minor, B-flat, C and A, and a
// lead that calls up A, D, F; the chorus climbs G minor, A, B-flat in long high notes, and the
// break hangs on G minor and A7.
trailsMonolith: {
bpm: 98,
rush: 16,
voices: {
bass: { wave: "sawtooth", gain: 0.44, decay: 0.06, sustain: 0.4 },
drums: { kit: true, gain: 0.82, from: 0.1 },
seq: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
brass: { wave: "sawtooth", gain: 0.14, decay: 0.2, sustain: 0.8, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5, depth: 0.012, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 C#2 E2 G2 A2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "D5 A5 F5 A5 D5 A5 F5 A5 D5 A5 F5 A5 E5 A5 F5 A5 | D5 F5 Bb4 F5 D5 F5 Bb4 F5 D5 F5 Bb4 F5 C5 F5 D5 F5 | E5 G5 C5 G5 E5 G5 C5 G5 E5 G5 C5 G5 D5 G5 E5 G5 | C#5 E5 A4 E5 C#5 E5 A4 E5 C#5 E5 G5 E5 A5 G5 E5 C#5",
},
B: {
bass: "D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D2 D3 D2 D3 D2 D3 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C2 C3 C2 C3 C2 C3 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 C#2 E2 G2 A2",
drums: "k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . h . h . h . | k . h . h . h k s . s s s s s s",
seq: "D5 A5 F5 A5 D5 A5 F5 A5 D5 A5 F5 A5 E5 A5 F5 A5 | D5 F5 Bb4 F5 D5 F5 Bb4 F5 D5 F5 Bb4 F5 C5 F5 D5 F5 | E5 G5 C5 G5 E5 G5 C5 G5 E5 G5 C5 G5 D5 G5 E5 G5 | C#5 E5 A4 E5 C#5 E5 A4 E5 C#5 E5 G5 E5 A5 G5 E5 C#5",
brass: "D4^037 - - - - - - - - - - - D4^037 - - - | Bb3^047 - - - - - - - - - - - Bb3^047 - - - | C4^047 - - - - - - - - - - - C4^047 - - - | A3^047 - - - - - - - A3^047a - - - A3^047a - - -",
lead: "A4 - - - D5 - - - F5 - - - - - E5 - | D5 - - - - - - - - - - - C5 - Bb4 - | G4 - - - C5 - - - E5 - - - G5 - - - | E5 - - - - - - - C#5 - - - A4 - - -",
},
C: {
bass: "G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G1 G2 G1 G2 G1 G2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A2 A1 A2 | Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb1 Bb2 Bb1 Bb2 Bb1 Bb2 | A1 A1 A2 A1 A1 A2 A1 A1 A2 A1 A1 A2 C#2 E2 G2 A2",
drums: "k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h . k . h k s . h k | k . h k s . h k s s s s ks s ks s",
seq: "D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 A5 Bb4 G5 Bb4 | E5 C#5 A5 C#5 E5 C#5 A5 C#5 E5 C#5 A5 C#5 B5 C#5 A5 C#5 | F5 D5 Bb5 D5 F5 D5 Bb5 D5 F5 D5 Bb5 D5 C6 D5 Bb5 D5 | E5 C#5 A5 C#5 E5 C#5 G5 C#5 E5 C#5 A5 C#5 G5 E5 C#5 A4",
brass: "G3^037 - - - - - - - - - - - - - - - | A3^047 - - - - - - - - - - - - - - - | Bb3^047 - - - - - - - - - - - - - - - | A3^047a - - - - - - - - - - - - - - -",
lead: "Bb5 - - - - - - - D6 - - - - - C6 - | C#6 - - - - - - - E6 - - - - - D6 - | D6 - - - - - - - F6 - - - - - - - | E6 - - - - - - - C#6 - - - A5 - - -",
},
D: {
bass: "G1 - - - - - - - G2 - - - - - - - | G1 - - - - - - - F2 - - - - - - - | A1 - - - - - - - A2 - - - - - - - | A1 - - - A2 - - - A1 - A1 - A2 A2 A2 A2",
drums: "k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . . . . . . . | k . . . . . . k s . s . s s s s",
seq: "D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 A5 Bb4 G5 Bb4 | D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 D5 Bb4 G5 Bb4 F5 Bb4 G5 Bb4 | E5 C#5 A5 C#5 E5 C#5 A5 C#5 E5 C#5 A5 C#5 B5 C#5 A5 C#5 | E5 C#5 A5 C#5 E5 C#5 G5 C#5 E5 C#5 A5 C#5 G5 E5 C#5 A4",
brass: "G3^037 - - - - - - - - - - - - - - - | G3^037 - - - - - - - - - - - - - - - | A3^047 - - - - - - - - - - - - - - - | A3^047a - - - - - - - - - - - - - - -",
lead: "D6 - - - - - - - - - - - - - - - | Bb5 - - - - - - - - - - - A5 - G5 - | A5 - - - - - - - - - - - - - - - | C#6 - - - - - - - E6 - - - - - - -",
},
},
order: ["A", "B", "C", "D", "C"],
},
// Netrunner: D minor at 122, jacked into the net: a pulsing sixteenth sawtooth bass with an
// octave kick on two and four, an arp in threes that slides against the beat, gated chord stabs
// that stutter in and out, and a sawtooth lead; the chorus lifts G minor, B-flat, C to a bright A
// major.
trailsNetrunner: {
bpm: 122,
rush: 10,
voices: {
bass: { wave: "sawtooth", gain: 0.42, decay: 0.05, sustain: 0.3 },
drums: { kit: true, gain: 0.8, from: 0.1 },
arp: { wave: "pulse", duty: 0.125, gain: 0.18, decay: 0.03, sustain: 0.25, from: 0.2 },
stab: { wave: "pulse", duty: 0.25, gain: 0.22, decay: 0.03, sustain: 0.1, from: 0.3 },
lead: { wave: "sawtooth", gain: 0.19, decay: 0.1, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
},
patterns: {
A: {
bass: "D2 D2 D2 D2 D3 D2 D2 D2 D2 D2 D2 D2 D3 D2 C3 D2 | Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 A1 Bb1 | F1 F1 F1 F1 F2 F1 F1 F1 F1 F1 F1 F1 F2 F1 E1 F1 | C2 C2 C2 C2 C3 C2 C2 C2 C2 C2 C2 C2 C3 C2 E2 G2",
drums: "k . h . s . h . k . h k s . h . | k . h . s . h . k . h k s . h . | k . h . s . h . k . h k s . h . | k . h . s . h k s s s s s s s s",
arp: "D5 F5 A5 D5 F5 A5 D5 F5 A5 D5 F5 A5 D5 F5 A5 C6 | D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 C6 | C5 F5 A5 C5 F5 A5 C5 F5 A5 C5 F5 A5 C5 F5 A5 C6 | C5 E5 G5 C5 E5 G5 C5 E5 G5 C5 E5 G5 C5 E5 G5 Bb5",
},
B: {
bass: "D2 D2 D2 D2 D3 D2 D2 D2 D2 D2 D2 D2 D3 D2 C3 D2 | Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 A1 Bb1 | F1 F1 F1 F1 F2 F1 F1 F1 F1 F1 F1 F1 F2 F1 E1 F1 | C2 C2 C2 C2 C3 C2 C2 C2 C2 C2 C2 C2 C3 C2 E2 G2",
drums: "kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h kh h kh h sh h h h | kh h h h sh h h h s . s s s s s s",
arp: "D5 F5 A5 D5 F5 A5 D5 F5 A5 D5 F5 A5 D5 F5 A5 C6 | D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 C6 | C5 F5 A5 C5 F5 A5 C5 F5 A5 C5 F5 A5 C5 F5 A5 C6 | C5 E5 G5 C5 E5 G5 C5 E5 G5 C5 E5 G5 C5 E5 G5 Bb5",
stab: "D4^037 D4^037 . D4^037 . D4^037 D4^037 . D4^037 . D4^037 D4^037 . D4^037 . . | Bb3^047 Bb3^047 . Bb3^047 . Bb3^047 Bb3^047 . Bb3^047 . Bb3^047 Bb3^047 . Bb3^047 . . | F4^047 F4^047 . F4^047 . F4^047 F4^047 . F4^047 . F4^047 F4^047 . F4^047 . . | C4^047 C4^047 . C4^047 . C4^047 C4^047 . C4^047 . C4^047 C4^047 . C4^047 . .",
lead: "A5 - - - - - - - F5 - - - D5 - - - | D6 - - - - - - - C6 - - - Bb5 - - - | A5 - - - - - - - C6 - - - F6 - - - | E6 - - - - - - - D6 - - - C6 - - -",
},
C: {
bass: "G1 G1 G1 G1 G2 G1 G1 G1 G1 G1 G1 G1 G2 G1 F1 G1 | Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb1 Bb2 Bb1 A1 Bb1 | C2 C2 C2 C2 C3 C2 C2 C2 C2 C2 C2 C2 C3 C2 Bb1 C2 | A1 A1 A1 A1 A2 A1 A1 A1 A1 A1 A1 A1 A2 A1 C#2 E2",
drums: "k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k k . h k s . h k | k . h k s . h k s s s s ks s ks s",
arp: "D5 G5 Bb5 D5 G5 Bb5 D5 G5 Bb5 D5 G5 Bb5 D5 G5 Bb5 C6 | D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 D5 F5 Bb5 C6 | E5 G5 C6 E5 G5 C6 E5 G5 C6 E5 G5 C6 E5 G5 C6 D6 | C#5 E5 A5 C#5 E5 A5 C#5 E5 A5 C#5 E5 A5 C#5 E5 A5 G5",
stab: "G3^037 - - - - - - - - - - - - - - - | Bb3^047 - - - - - - - - - - - - - - - | C4^047 - - - - - - - - - - - - - - - | A3^047a - - - - - - - - - - - - - - -",
lead: "Bb5 - - - - - - - D6 - - - G6 - - - | F6 - - - - - - - D6 - - - Bb5 - - - | G6 - - - - - - - E6 - - - C6 - - - | C#6 - - - - - - - E6 - - - - - - -",
},
},
order: ["A", "B", "C", "B", "C"],
},
// Overdrive at dusk: F minor outrun at 112 with the sun going down: a big gated snare on two and
// four, an octave-bouncing sawtooth bass, a rolling sixteenth arp and gated chord pulses, and a
// sawtooth lead doubled an octave below; the chorus swings B-flat minor, A-flat, D-flat to a
// bright C major.
trailsOverdrive: {
bpm: 112,
rush: 12,
voices: {
bass: { wave: "sawtooth", gain: 0.4, decay: 0.07, sustain: 0.4 },
drums: { kit: true, gain: 0.8, from: 0.1 },
arp: { wave: "pulse", duty: 0.125, gain: 0.16, decay: 0.03, sustain: 0.3, from: 0.3 },
pad: { wave: "pulse", duty: 0.25, gain: 0.2, decay: 0.05, sustain: 0.3, from: 0.25 },
lead: { wave: "sawtooth", gain: 0.2, decay: 0.12, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
low: { wave: "pulse", duty: 0.5, gain: 0.16, decay: 0.12, sustain: 0.8, from: 0.5 },
},
patterns: {
A: {
bass: "F1 . F2 . F1 . F2 . F1 . F2 . F1 . F2 . | Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . | Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . | Eb2 . Eb3 . Eb2 . Eb3 . Eb2 . Eb3 . Eb2 . G2 Bb2",
drums: "k . h . s . h . k . h k s . h . | k . h . s . h . k . h k s . h . | k . h . s . h . k . h k s . h . | k . h . s . h . s s s s s s s s",
arp: "F4 Ab4 C5 F5 Ab5 F5 C5 Ab4 F4 Ab4 C5 F5 Ab5 F5 C5 Ab4 | F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 | Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 | Eb4 G4 Bb4 Eb5 G5 Eb5 Bb4 G4 Eb4 G4 Bb4 Eb5 G5 Eb5 Bb4 G4",
},
B: {
bass: "F1 . F2 . F1 . F2 . F1 . F2 . F1 . F2 . | Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . | Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . | Eb2 . Eb3 . Eb2 . Eb3 . Eb2 . Eb3 . Eb2 . G2 Bb2",
drums: "k h h h s h h h k h k h s h h h | k h h h s h h h k h k h s h h h | k h h h s h h h k h k h s h h h | k h h h s h h h s . s s s s s s",
arp: "F4 Ab4 C5 F5 Ab5 F5 C5 Ab4 F4 Ab4 C5 F5 Ab5 F5 C5 Ab4 | F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 | Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 | Eb4 G4 Bb4 Eb5 G5 Eb5 Bb4 G4 Eb4 G4 Bb4 Eb5 G5 Eb5 Bb4 G4",
pad: "F4^037 . F4^037 F4^037 . F4^037 . F4^037 F4^037 . F4^037 F4^037 . F4^037 . F4^037 | Db4^047 . Db4^047 Db4^047 . Db4^047 . Db4^047 Db4^047 . Db4^047 Db4^047 . Db4^047 . Db4^047 | Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 . Ab3^047 | Eb4^047 . Eb4^047 Eb4^047 . Eb4^047 . Eb4^047 Eb4^047 . Eb4^047 Eb4^047 . Eb4^047 . Eb4^047",
lead: "C6 - - - - - Ab5 - F5 - - - Ab5 - - - | Db6 - - - - - C6 - Ab5 - - - F5 - - - | Eb6 - - - - - C6 - Ab5 - - - C6 - - - | Bb5 - - - - - - - - - - - . . . .",
low: "C5 - - - - - Ab4 - F4 - - - Ab4 - - - | Db5 - - - - - C5 - Ab4 - - - F4 - - - | Eb5 - - - - - C5 - Ab4 - - - C5 - - - | Bb4 - - - - - - - - - - - . . . .",
},
C: {
bass: "Bb1 . Bb2 . Bb1 . Bb2 . Bb1 . Bb2 . Bb1 . Bb2 . | Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . Ab1 . Ab2 . | Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . Db2 . Db3 . | C2 . C3 . C2 . C3 . C2 . C3 . C2 . E2 G2",
drums: "k h h h s h h h k h k h s h h h | k h h h s h h h k h k h s h h h | k h h h s h h h k h k h s h h h | k h h h s h h h s s s s s s s s",
arp: "F4 Bb4 Db5 F5 Bb5 F5 Db5 Bb4 F4 Bb4 Db5 F5 Bb5 F5 Db5 Bb4 | Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 Eb4 Ab4 C5 Eb5 Ab5 Eb5 C5 Ab4 | F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 F4 Ab4 Db5 F5 Ab5 F5 Db5 Ab4 | E4 G4 C5 E5 G5 E5 C5 G4 E4 G4 C5 E5 G5 E5 C5 G4",
pad: "Bb3^037 . Bb3^037 Bb3^037 . Bb3^037 . Bb3^037 Bb3^037 . Bb3^037 Bb3^037 . Bb3^037 . Bb3^037 | Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 Ab3^047 . Ab3^047 . Ab3^047 | Db4^047 . Db4^047 Db4^047 . Db4^047 . Db4^047 Db4^047 . Db4^047 Db4^047 . Db4^047 . Db4^047 | C4^047 . C4^047 C4^047 . C4^047 . C4^047 C4^047 . C4^047 C4^047 . C4^047 . C4^047",
lead: "Db6 - - - - - - - F6 - - - Db6 - - - | C6 - - - - - - - Eb6 - - - C6 - - - | Ab5 - - - - - - - Db6 - - - F6 - - - | E6 - - - - - - - G6 - - - E6 - - -",
low: "Db5 - - - - - - - F5 - - - Db5 - - - | C5 - - - - - - - Eb5 - - - C5 - - - | Ab4 - - - - - - - Db5 - - - F5 - - - | E5 - - - - - - - G5 - - - E5 - - -",
},
},
order: ["A", "B", "C", "B", "C"],
},
// Laser highway: G minor at 120 on an empty highway of light: a pushing octave bass, a pad that
// pumps on every beat like it is breathing with the kick, a sequence ticking over each chord, and
// a lead with an echo trailing a dotted eighth behind it; the chorus climbs C minor, B-flat,
// E-flat to F.
trailsLaserHighway: {
bpm: 120,
rush: 10,
voices: {
bass: { wave: "sawtooth", gain: 0.4, decay: 0.06, sustain: 0.35 },
drums: { kit: true, gain: 0.78, from: 0.1 },
pad: { wave: "sine", gain: 0.22, decay: 0.2, sustain: 0.6, from: 0.2 },
seq: { wave: "pulse", duty: 0.125, gain: 0.16, decay: 0.03, sustain: 0.25, from: 0.35 },
lead: { wave: "pulse", duty: 0.25, gain: 0.34, decay: 0.12, sustain: 0.8, vibrato: { rate: 5.5, depth: 0.01, delay: 0.2 }, from: 0.5 },
echo: { wave: "pulse", duty: 0.25, gain: 0.12, decay: 0.12, sustain: 0.6, from: 0.55 },
},
patterns: {
A: {
bass: "G1 . G2 . G1 G1 G2 . G1 . G2 . G1 G1 G2 F2 | Eb2 . Eb3 . Eb2 Eb2 Eb3 . Eb2 . Eb3 . Eb2 Eb2 Eb3 D3 | Bb1 . Bb2 . Bb1 Bb1 Bb2 . Bb1 . Bb2 . Bb1 Bb1 Bb2 A2 | F1 . F2 . F1 F1 F2 . F1 . F2 . F1 F1 F2 A1",
drums: "k . h k s . h . k . h k s . h . | k . h k s . h . k . h k s . h . | k . h k s . h . k . h k s . h . | k . h k s . h . s s s s s s s s",
pad: "G3^037 - - . G3^037 - - . G3^037 - - . G3^037 - - . | Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . | Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . | F3^047 - - . F3^047 - - . F3^047 - - . F3^047 - - .",
seq: "G4 D5 Bb4 D5 G4 D5 Bb4 D5 G4 D5 Bb4 D5 A4 D5 Bb4 D5 | G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 F4 Eb5 Bb4 Eb5 | F4 D5 Bb4 D5 F4 D5 Bb4 D5 F4 D5 Bb4 D5 G4 D5 Bb4 D5 | F4 C5 A4 C5 F4 C5 A4 C5 F4 C5 A4 C5 Eb5 C5 A4 C5",
},
B: {
bass: "G1 . G2 . G1 G1 G2 . G1 . G2 . G1 G1 G2 F2 | Eb2 . Eb3 . Eb2 Eb2 Eb3 . Eb2 . Eb3 . Eb2 Eb2 Eb3 D3 | Bb1 . Bb2 . Bb1 Bb1 Bb2 . Bb1 . Bb2 . Bb1 Bb1 Bb2 A2 | F1 . F2 . F1 F1 F2 . F1 . F2 . F1 F1 F2 A1",
drums: "kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h s . s s s s s s",
pad: "G3^037 - - . G3^037 - - . G3^037 - - . G3^037 - - . | Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . | Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . | F3^047 - - . F3^047 - - . F3^047 - - . F3^047 - - .",
seq: "G4 D5 Bb4 D5 G4 D5 Bb4 D5 G4 D5 Bb4 D5 A4 D5 Bb4 D5 | G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 F4 Eb5 Bb4 Eb5 | F4 D5 Bb4 D5 F4 D5 Bb4 D5 F4 D5 Bb4 D5 G4 D5 Bb4 D5 | F4 C5 A4 C5 F4 C5 A4 C5 F4 C5 A4 C5 Eb5 C5 A4 C5",
lead: "D5 - - - G5 - - - Bb5 - - - A5 - G5 - | G5 - - - - - - - Eb5 - - - Bb4 - - - | D5 - - - F5 - - - Bb5 - - - C6 - D6 - | C6 - - - - - - - A5 - - - F5 - - -",
echo: ". - - D5 - - - G5 - - - Bb5 - - - A5 | - G5 - G5 - - - - - - - Eb5 - - - Bb4 | - - - D5 - - - F5 - - - Bb5 - - - C6 | - D6 - C6 - - - - - - - A5 - - - F5",
},
C: {
bass: "C2 . C3 . C2 C2 C3 . C2 . C3 . C2 C2 C3 Bb2 | Bb1 . Bb2 . Bb1 Bb1 Bb2 . Bb1 . Bb2 . Bb1 Bb1 Bb2 A2 | Eb2 . Eb3 . Eb2 Eb2 Eb3 . Eb2 . Eb3 . Eb2 Eb2 Eb3 D3 | F1 . F2 . F1 F1 F2 . F1 . F2 . F1 F1 F2 A1",
drums: "kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h kh h h kh sh h h h | kh h h kh sh h h h s s s s s s s s",
pad: "C4^037 - - . C4^037 - - . C4^037 - - . C4^037 - - . | Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . Bb3^047 - - . | Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . Eb4^047 - - . | F3^047 - - . F3^047 - - . F3^047 - - . F3^047 - - .",
seq: "G4 Eb5 C5 Eb5 G4 Eb5 C5 Eb5 G4 Eb5 C5 Eb5 F4 Eb5 C5 Eb5 | F4 D5 Bb4 D5 F4 D5 Bb4 D5 F4 D5 Bb4 D5 G4 D5 Bb4 D5 | G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 G4 Eb5 Bb4 Eb5 Ab4 Eb5 Bb4 Eb5 | F4 C5 A4 C5 F4 C5 A4 C5 F4 C5 A4 C5 Eb5 C5 A4 C5",
lead: "Eb6 - - - - - - - D6 - - - C6 - - - | D6 - - - - - - - Bb5 - - - F5 - - - | G5 - - - - - - - Bb5 - - - Eb6 - - - | F6 - - - - - - - C6 - - - A5 - - -",
echo: ". - - Eb6 - - - - - - - D6 - - - C6 | - - - D6 - - - - - - - Bb5 - - - F5 | - - - G5 - - - - - - - Bb5 - - - Eb6 | - - - F6 - - - - - - - C6 - - - A5",
},
},
order: ["A", "B", "C", "B", "C"],
},
};
@@ -1,15 +1,21 @@
// Plan2Code Web Console - trails: its own sound effects and music, merged into tones.js beside the shared kit; defines only.
// Plan2Code Web Console - trails: its own sound effects and songs, merged into tones.js beside the shared kit; defines only.
//
// `tones` are one-shot sounds played with tone(name, level, pitch); `hums` are
// held sounds kept going with hum(id, name, level, pitch). Both take the shapes
// tones.js documents, as plain objects (tones.js freezes them). A name may be
// defined only once across tones.js and every game's file. The music is in
// trails-music.js, merged in below as `music`: that file is the only import.
import { TRAILS_MUSIC } from "./trails-music.js";
// defined only once across tones.js and every game's file. No imports.
export default {
music: TRAILS_MUSIC,
// The music: recorded songs, each a name to an mp3 the server serves
// (listed in SERVABLE), played by music.js one after another in the order
// trails.js deals them.
songs: {
trailsSong1: "activities/light-trails/1.mp3",
trailsSong2: "activities/light-trails/2.mp3",
trailsSong3: "activities/light-trails/3.mp3",
trailsSong4: "activities/light-trails/4.mp3",
trailsSong5: "activities/light-trails/5.mp3",
},
tones: {
// A turn taken: a short, bright synth chirp (the game nudges its pitch a
// little each time, so steering never sounds like one repeated beep).
@@ -133,6 +139,42 @@ export default {
{ type: "triangle", from: 440, to: 440, seconds: 0.7, delay: 0.4, gain: 0.4 },
],
},
// The Laser firing: a bright beam tearing down the grid, a crackle along
// it and a low thump where it lands.
trailsLaser: {
layers: [
{ type: "sawtooth", from: 3200, to: 420, seconds: 0.22, gain: 0.45, filter: { type: "lowpass", from: 6000, to: 1200, q: 3 } },
{ type: "square", from: 1600, to: 200, seconds: 0.18, gain: 0.25, filter: { type: "bandpass", from: 2400, to: 600, q: 2 } },
{ type: "noise", seconds: 0.2, gain: 0.3, filter: { type: "highpass", from: 5000, to: 2000 } },
{ type: "sine", from: 140, to: 50, seconds: 0.25, delay: 0.12, gain: 0.6 },
],
},
// A Shield taking the crash: a glassy dome shattering into a ring of bells.
trailsShieldPop: {
layers: [
{ type: "noise", seconds: 0.35, gain: 0.45, filter: { type: "bandpass", from: 7000, to: 1500, q: 1 } },
{ type: "triangle", notes: [2093, 1568, 2637, 1976], seconds: 0.4, gain: 0.4 },
{ type: "sine", from: 600, to: 1800, seconds: 0.3, delay: 0.05, gain: 0.35 },
{ type: "brown", seconds: 0.4, gain: 0.5, filter: { type: "lowpass", from: 800, to: 120 } },
],
},
// Hyperjump: sucked down a tunnel of light and flung out the far end.
trailsJump: {
layers: [
{ type: "sawtooth", from: 900, to: 90, seconds: 0.25, gain: 0.4, filter: { type: "lowpass", from: 4000, to: 400, q: 6 } },
{ type: "sawtooth", from: 120, to: 1800, seconds: 0.3, delay: 0.22, gain: 0.4, filter: { type: "lowpass", from: 500, to: 6000, q: 6 } },
{ type: "pink", seconds: 0.5, attack: 0.2, gain: 0.3, filter: { type: "bandpass", from: 300, to: 5000, q: 2 } },
],
},
// A Heart, or a life won with points: a warm lub-dub and a rising chime.
trailsHeart: {
layers: [
{ type: "sine", from: 110, to: 70, seconds: 0.12, gain: 0.8 },
{ type: "sine", from: 120, to: 75, seconds: 0.14, delay: 0.16, gain: 0.9 },
{ type: "triangle", notes: [784, 988, 1175, 1568], seconds: 0.45, delay: 0.22, gain: 0.4 },
{ type: "sine", from: 3136, to: 3136, seconds: 0.3, delay: 0.55, gain: 0.15 },
],
},
// Ridden out of your grace in time: a quick rush of air and a lift.
trailsSave: {
layers: [
@@ -144,6 +186,7 @@ export default {
hums: {
// Your light cycle: detuned saws over a sub, a sine body and a thin whine,
// through a resonant lowpass, with a faint flutter; pitch follows speed.
// Kept low (a third of its old 0.045) so it sits under the songs.
trailsCycle: {
parts: [
{ type: "sawtooth", freq: 82 },
@@ -155,7 +198,7 @@ export default {
noise: { color: "brown", gain: 0.08 },
filter: { type: "lowpass", freq: 900, q: 5, follow: 0.9 },
pulse: { rate: 30, depth: 0.15 },
peak: 0.045,
peak: 0.015,
},
// Riding alongside a rival's wall (or held up against one): an electric
// crackle, louder the more walls are at your side.
+483 -84
View File
@@ -9,9 +9,10 @@
//
// Every rider leaves a glowing wall behind it, and running into any wall is
// out. A round is a string of heats in arenas: the last rider still moving
// wins the heat and moves on to the next arena, and a crash costs one of three
// lives and runs the heat again. Each arena brings a rival more or something
// new (power-ups, crystals, portals, then walls that close in), and the
// wins the heat and moves on to the next arena, and a crash costs one of five
// lives and runs the heat again (a life back every LIFE_SCORE points, and from
// a Heart pad). Each arena brings a rival more or something new (power-ups,
// crystals, portals, then walls that close in, and more kinds of pad), and the
// rivals get sharper as the levels go. Space spends a boost charge. The memo
// keeps the furthest arena ever reached, so the start and end screens can say
// what is still ahead.
@@ -34,8 +35,11 @@ export const BOOST_PACE = 0.55;
const SLOW_PACE = 1.7;
export const MAX_LEVEL = 9;
export const START_LIVES = 3;
const MAX_LIVES = 5;
export const START_LIVES = 5;
export const MAX_LIVES = 9;
// A life back for every LIFE_SCORE points scored, up to MAX_LIVES.
export const LIFE_SCORE = 750;
// A heat holds still for READY_MS so everyone can see where they are headed
// (the first one only briefly: the window has just counted 3, 2, 1), and
@@ -77,6 +81,19 @@ const ITEM_TTL_MS = 9000;
const MAX_ITEMS = 2;
export const ERASE_REACH = 6;
// A Shield pops when your grace runs out, wiping the trails this close and
// riding on the first way clear (straight, then either side).
export const SHIELD_REACH = 3;
// A Laser fires at a rival head in your line, up to LASER_REACH cells ahead,
// through trails (which it cuts) but not crystals, walls or portals; it holds
// LASER_SHOTS shots for as long as it runs.
export const LASER_REACH = 16;
export const LASER_SHOTS = 3;
// Coin Rain drops this many coins round the board, over and above the pads.
export const RAIN_COINS = 7;
// The closing walls: the first ring SHRINK_FIRST_MS into a heat, then one
// every SHRINK_MS, each flashing for SHRINK_WARN_MS first. MAX_RING leaves
// room to play.
@@ -96,7 +113,6 @@ export const WALL = -2;
const ITEMS_LEVEL = 2;
const BLOCKS_LEVEL = 3;
const PORTALS_LEVEL = 4;
const LIFE_LEVEL = 4;
const SHRINK_LEVEL = 5;
const TWO_PORTALS_LEVEL = 6;
@@ -105,14 +121,22 @@ const deepFreeze = (o) => Object.freeze(Object.fromEntries(Object.entries(o).map
const GOLD = "#f5b301";
// The pads. A timed one lasts `ms`; the rest act at once. `weight` is how
// often each turns up against the others.
// often each turns up against the others, and `from` the first arena it can.
// A Heart turns up only while you have room for another life.
export const POWERS = deepFreeze({
boost: { name: "Boost", blurb: "One more boost charge", color: "#ff8a1f", weight: 3 },
phase: { name: "Phase", blurb: "Ride straight through trails", color: "#a466ff", ms: 3000, weight: 2 },
eraser: { name: "Eraser", blurb: "Wipes the trails around you", color: "#1fb6d9", weight: 2 },
slow: { name: "Slow-mo", blurb: "Your rivals crawl", color: "#57b54a", ms: 4000, weight: 2 },
coin: { name: "Coin", blurb: "", color: GOLD, weight: 3 },
life: { name: "1UP", blurb: "An extra life", color: "#ff4fa3", weight: 1 },
boost: { name: "Boost", blurb: "One more boost charge", color: "#ff8a1f", weight: 3, from: 2 },
phase: { name: "Phase", blurb: "Ride straight through trails", color: "#a466ff", ms: 3000, weight: 2, from: 2 },
eraser: { name: "Eraser", blurb: "Wipes the trails around you", color: "#1fb6d9", weight: 2, from: 2 },
slow: { name: "Slow-mo", blurb: "Your rivals crawl", color: "#57b54a", ms: 4000, weight: 2, from: 2 },
coin: { name: "Coin", blurb: "", color: GOLD, weight: 3, from: 2 },
life: { name: "Heart", blurb: "One more life", color: "#ff4fa3", weight: 2, from: 2 },
shield: { name: "Shield", blurb: "Shrugs off your next crash", color: "#3d7bff", weight: 2, from: 2 },
laser: { name: "Laser", blurb: "Zaps rivals in your line", color: "#ff2e4d", ms: 6000, weight: 2, from: 3 },
double: { name: "Score x2", blurb: "Every point counts twice", color: "#ffd23f", ms: 8000, weight: 2, from: 3 },
wide: { name: "Wide Trail", blurb: "Your wall rides three cells wide", color: "#18c7b0", ms: 4000, weight: 2, from: 4 },
rain: { name: "Coin Rain", blurb: "Coins all over the grid", color: "#e6a800", weight: 1, from: 4 },
jump: { name: "Hyperjump", blurb: "Warps you into open space", color: "#d06bff", weight: 1, from: 5 },
mystery: { name: "Mystery", blurb: "Could be anything", color: "#9b7bff", weight: 1, from: 6 },
});
// Each arena: its rivals, how sharp they ride (0 to 1), and what it adds.
@@ -131,13 +155,23 @@ export const ARENAS = deepFreeze({
export const arenaFor = (level) => ARENAS[Math.min(Math.max(1, level || 1), MAX_LEVEL)];
// The music: fourteen tracks (trails-music.js), one for each arena of a round.
// A round deals them in a fresh order, so a run hears a different track in
// every arena and none twice (nine arenas, fourteen tracks), and a round never
// opens on the track the last one opened on.
export const MUSIC_TRACKS = Object.freeze(["trailsGridElectro", "trailsRecognizer", "trailsMainframe", "trailsBlackIce", "trailsSentinel", "trailsThrone", "trailsSiege", "trailsIronGate", "trailsSkyCitadel", "trailsDeepCore", "trailsMonolith", "trailsNetrunner", "trailsOverdrive", "trailsLaserHighway"]);
// The music: five recorded songs (trails-sfx.js), background music for the
// whole run rather than one a level. A run deals them in a fresh order and
// plays each in full, one after another, starting from the top of the first;
// once the last has played they are dealt again, never opening on the song
// that just ended, and a new run never opens on the song the last was playing.
export const MUSIC_TRACKS = Object.freeze(["trailsSong1", "trailsSong2", "trailsSong3", "trailsSong4", "trailsSong5"]);
// Every track in a new order, shuffled with the given random, the first never `last`.
// How loud the nearest rival's engine drone is at its closest, a share of the
// shared `cycle` hum's level: low, so the songs carry the run.
const RIVAL_HUM = 0.35;
// How much louder than made the game's sounds play (tones.js's `louder`),
// all but the engine drones, the hums in DRONES.
export const SFX_LOUDER = 1.4;
const DRONES = new Set(["trails:you", "trails:rival"]);
// Every song in a new order, shuffled with the given random, the first never `last`.
export function dealMusic(random = Math.random, last = null) {
const deck = [...MUSIC_TRACKS];
for (let i = deck.length - 1; i > 0; i--) {
@@ -148,23 +182,6 @@ export function dealMusic(random = Math.random, last = null) {
return deck;
}
// The deal's track for an arena: the first for level 1, the second for level 2.
export const trackFor = (deck, level) => deck[(Math.max(1, level) - 1) % deck.length];
// How hot play is for the music, 0 to 1. While a heat lines up or shows how
// it went, HEAT_WAIT: the bass, drums and sequence. Once the riders go,
// HEAT_RACE brings in the brass and lead; down to the last rival it is
// HEAT_DUEL, and a boost pushes it all the way, the tempo with it.
const HEAT_WAIT = 0.3;
const HEAT_RACE = 0.7;
const HEAT_DUEL = 0.85;
export function heat(round) {
if (round.phase !== "race") return HEAT_WAIT;
if (active(round, "boost")) return 1;
const rivals = round.riders.filter((r) => r.id !== 0 && r.alive).length;
return rivals <= 1 ? HEAT_DUEL : HEAT_RACE;
}
const LEVEL_COLORS = Object.freeze(["#1fb6d9", "#1fb6d9", "#ff8a1f", "#a466ff", "#4f7cff", "#7a7f99", "#ff4fa3", "#8fd3ff", "#e2553f", "#f5b301"]);
const levelColor = (level) => LEVEL_COLORS[Math.min(level, LEVEL_COLORS.length - 1)];
@@ -240,7 +257,7 @@ export function pace(round, rider) {
}
function makeRider(id, spawn) {
return { id, x: spawn.x, y: spawn.y, dir: spawn.dir, queue: [], alive: true, acc: 0, stall: null, prev: { x: spawn.x, y: spawn.y }, path: [{ x: spawn.x, y: spawn.y }], fade: 0, by: null };
return { id, x: spawn.x, y: spawn.y, dir: spawn.dir, queue: [], alive: true, acc: 0, stall: null, prev: { x: spawn.x, y: spawn.y }, path: [{ x: spawn.x, y: spawn.y }], wide: [], fade: 0, by: null };
}
const portalAt = (round, x, y) => round.portals.find((p) => p.x === x && p.y === y) || null;
@@ -297,6 +314,7 @@ export function newHeat(round, random = Math.random, readyMs = READY_MS) {
if (round.level >= BLOCKS_LEVEL) placeBlocks(round, random);
round.items = [];
round.effects = {};
round.shots = 0;
round.charges = START_CHARGES;
round.ring = 0;
round.nextRing = SHRINK_FIRST_MS;
@@ -310,7 +328,8 @@ export function newHeat(round, random = Math.random, readyMs = READY_MS) {
}
export function newRound(random = Math.random) {
const round = { level: 1, lives: START_LIVES, score: 0, heatsWon: 0, outs: 0, over: false, events: [] };
// A Shield, once taken, is held until it saves you, from heat to heat.
const round = { level: 1, lives: START_LIVES, score: 0, nextLifeAt: LIFE_SCORE, shield: false, heatsWon: 0, outs: 0, over: false, events: [] };
return newHeat(round, random, FIRST_READY_MS);
}
@@ -419,6 +438,24 @@ export function choose(round, r, random = Math.random) {
/* --------------------------------------------------------------- moving */
// Points scored, doubled while Score x2 runs; returns what was scored.
function gain(round, points) {
const scored = active(round, "double") ? points * 2 : points;
round.score += scored;
return scored;
}
// A life back for every LIFE_SCORE points, up to MAX_LIVES: past the cap the
// mark still moves on, so a life is never saved up for later.
export function awardLives(round) {
while (round.score >= round.nextLifeAt) {
round.nextLifeAt += LIFE_SCORE;
if (round.lives >= MAX_LIVES) continue;
round.lives += 1;
round.events.push({ type: "bonusLife", lives: round.lives, at: round.nextLifeAt - LIFE_SCORE });
}
}
function crash(round, r, by) {
r.alive = false;
r.fade = FADE_MS;
@@ -432,27 +469,32 @@ function crash(round, r, by) {
}
let points = 0;
if (you.alive) {
points = OUT_POINTS * round.level + (by === 0 ? CUT_POINTS * round.level : 0);
round.score += points;
// Your trail or your laser: either way it was you, and pays the cut.
points = gain(round, OUT_POINTS * round.level + (by === 0 || by === "laser" ? CUT_POINTS * round.level : 0));
round.outs += 1;
}
round.events.push({ type: "out", id: r.id, x: r.x, y: r.y, by, points });
}
// Drops every trail cell that is no longer its rider's from that rider's
// path, after an eraser, a closing wall or a faded crash.
// path (and a Wide Trail's side cells), after an eraser, a closing wall, a
// laser or a faded crash.
function trimPaths(round) {
for (const r of round.riders) r.path = r.path.filter((c) => round.grid[at(c.x, c.y)] === r.id + 1);
for (const r of round.riders) {
const mine = (c) => round.grid[at(c.x, c.y)] === r.id + 1;
r.path = r.path.filter(mine);
r.wide = r.wide.filter(mine);
}
}
function erase(round) {
function erase(round, reach = ERASE_REACH) {
const you = round.riders[0];
let count = 0;
for (let y = 0; y < ROWS; y++) {
for (let x = 0; x < COLS; x++) {
const i = at(x, y);
if (round.grid[i] <= 0) continue;
if ((x - you.x) ** 2 + (y - you.y) ** 2 > ERASE_REACH ** 2) continue;
if ((x - you.x) ** 2 + (y - you.y) ** 2 > reach ** 2) continue;
if (round.riders.some((r) => r.alive && r.x === x && r.y === y)) continue;
round.grid[i] = 0;
count += 1;
@@ -462,17 +504,110 @@ function erase(round) {
return count;
}
export function applyPower(round, kind) {
// A pad taken. A Mystery turns into another pad first, and says which.
export function applyPower(round, kind, random = Math.random) {
const you = round.riders[0];
const spec = POWERS[kind];
if (kind === "mystery") {
const pick = pickPower(round, random, true);
round.events.push({ type: "mystery", kind: pick, x: you.x, y: you.y });
return applyPower(round, pick, random);
}
let points = 0;
if (spec.ms) round.effects[kind] = spec.ms;
if (kind === "boost") round.charges = Math.min(MAX_CHARGES, round.charges + 1);
else if (kind === "eraser") erase(round);
else if (kind === "coin") points = COIN_POINTS * round.level;
else if (kind === "coin") points = gain(round, COIN_POINTS * round.level);
else if (kind === "life") round.lives = Math.min(MAX_LIVES, round.lives + 1);
else if (spec.ms) round.effects[kind] = spec.ms;
round.score += points;
else if (kind === "shield") round.shield = true;
else if (kind === "laser") round.shots = LASER_SHOTS;
else if (kind === "rain") {
for (let n = 0; n < RAIN_COINS; n++) {
const coin = spawnItem(round, "coin", random);
if (coin) coin.rain = true;
}
}
round.events.push({ type: "power", kind, x: you.x, y: you.y, points });
if (kind === "jump") hyperjump(round, random);
if (kind === "laser") fireLaser(round);
}
// The Laser's shot: a rival head straight ahead within LASER_REACH, with only
// open cells and trails between, is out, and the trails the beam crossed are
// cut. A crystal, a wall, a portal or the edge in the way and it holds fire.
export function fireLaser(round) {
const you = round.riders[0];
if (!you.alive || !active(round, "laser") || !(round.shots > 0)) return false;
const d = DIRS[you.dir];
const beam = [];
for (let k = 1; k <= LASER_REACH; k++) {
const x = you.x + d.x * k;
const y = you.y + d.y * k;
if (!inside(x, y)) return false;
const target = round.riders.find((o) => o.id !== 0 && o.alive && o.x === x && o.y === y);
if (target) {
for (const c of beam) round.grid[at(c.x, c.y)] = 0;
trimPaths(round);
round.shots -= 1;
if (round.shots <= 0) delete round.effects.laser;
round.events.push({ type: "laser", id: target.id, from: { x: you.x, y: you.y }, to: { x, y } });
crash(round, target, "laser");
return true;
}
const cell = round.grid[at(x, y)];
if (cell < 0 || portalAt(round, x, y)) return false;
beam.push({ x, y });
}
return false;
}
// Hyperjump: you, gone from where you were and out in the open cell (of a
// good many tried) with the most room round it, facing the way with most room.
export function hyperjump(round, random = Math.random) {
const you = round.riders[0];
let best = null;
for (let tries = 0; tries < 160; tries++) {
const x = round.ring + 1 + Math.floor(random() * (COLS - 2 * round.ring - 2));
const y = round.ring + 1 + Math.floor(random() * (ROWS - 2 * round.ring - 2));
if (!inside(x, y) || round.grid[at(x, y)] !== 0 || portalAt(round, x, y)) continue;
if (round.items.some((it) => it.x === x && it.y === y)) continue;
if (round.riders.some((r) => r.alive && near(r, { x, y }) < 4)) continue;
const space = room(round, at(x, y), 400);
if (!best || space > best.space) best = { x, y, space };
}
if (!best) return false;
let dir = you.dir;
let most = -1;
for (const [name, d] of Object.entries(DIRS)) {
const nx = best.x + d.x;
const ny = best.y + d.y;
if (!inside(nx, ny) || round.grid[at(nx, ny)] !== 0) continue;
const space = room(round, at(nx, ny), 200);
if (space > most) [most, dir] = [space, name];
}
const from = { x: you.x, y: you.y };
Object.assign(you, { x: best.x, y: best.y, prev: { x: best.x, y: best.y }, dir, queue: [], stall: null, acc: 0 });
if (!active(round, "phase")) {
round.grid[at(best.x, best.y)] = 1;
you.path.push({ x: best.x, y: best.y });
}
round.events.push({ type: "jump", from, to: { x: best.x, y: best.y } });
return true;
}
// Wide Trail: the cells either side of your head turn to your trail too,
// where they are open.
function widen(round, r) {
const d = DIRS[r.dir];
for (const side of [-1, 1]) {
const x = r.x - d.y * side;
const y = r.y + d.x * side;
if (!inside(x, y) || round.grid[at(x, y)] !== 0 || portalAt(round, x, y)) continue;
if (round.items.some((it) => it.x === x && it.y === y)) continue;
if (round.riders.some((o) => o.alive && o.x === x && o.y === y)) continue;
round.grid[at(x, y)] = r.id + 1;
r.wide.push({ x, y });
}
}
// Where `dir` takes rider r next, through a portal if one is there, and what
@@ -498,7 +633,7 @@ function stepRider(round, r, random) {
if (r.queue.length) r.dir = r.queue.shift();
} else r.dir = choose(round, r, random);
const to = landing(round, r, r.dir);
if (to.by === null) return move(round, r, to);
if (to.by === null) return move(round, r, to, random);
if (r.id !== 0) return crash(round, r, to.by);
// You hold where you are, still heading the way you came, so a turn either
// way is open; holdOn() rides out or crashes. The grace counts from the
@@ -510,24 +645,45 @@ function stepRider(round, r, random) {
// Your grace, a slice at a time: the queued turn (or the way you were held
// up on) is tried again, so a turn or a trail fading clear rides out at once,
// and when GRACE_MS runs out it is a crash.
function holdOn(round, r, ms) {
// and when GRACE_MS runs out it is a crash, unless a Shield pops first.
function holdOn(round, r, ms, random) {
const dir = r.queue.length ? r.queue.shift() : r.stall.dir;
const to = landing(round, r, dir);
if (to.by === null) {
r.stall = null;
r.dir = dir;
r.acc = 0;
return move(round, r, to);
return move(round, r, to, random);
}
r.stall.dir = dir;
r.stall.ms -= ms;
if (r.stall.ms > 0) return;
if (round.shield && shieldSave(round, r, dir, random)) return;
r.dir = dir;
crash(round, r, to.by);
}
function move(round, r, to) {
// The Shield's save: it pops, the trails within SHIELD_REACH go, and you ride
// on the first way now clear (the way you were going, then either side). A
// wall or the edge all round still holds, and that is a crash after all.
function shieldSave(round, r, dir, random) {
round.shield = false;
erase(round, SHIELD_REACH);
round.events.push({ type: "shield", x: r.x, y: r.y });
for (const name of [dir, LEFT_OF[dir], RIGHT_OF[dir]]) {
if (name === BACK_OF[r.dir]) continue;
const to = landing(round, r, name);
if (to.by !== null) continue;
r.stall = null;
r.dir = name;
r.acc = 0;
move(round, r, to, random);
return true;
}
return false;
}
function move(round, r, to, random = Math.random) {
const { x, y, portal } = to;
r.prev = { x: r.x, y: r.y };
if (portal) {
@@ -541,16 +697,18 @@ function move(round, r, to) {
if (!(r.id === 0 && active(round, "phase"))) {
round.grid[i] = r.id + 1;
r.path.push({ x, y });
if (r.id === 0 && active(round, "wide")) widen(round, r);
}
const item = round.items.findIndex((it) => it.x === x && it.y === y);
if (item >= 0) {
const [it] = round.items.splice(item, 1);
if (r.id === 0) applyPower(round, it.kind);
if (r.id === 0) applyPower(round, it.kind, random);
else round.events.push({ type: "snatch", id: r.id, x, y });
}
if (r.id === 0) {
round.steps += 1;
if (round.steps % SURVIVE_STEPS === 0) round.score += round.level;
if (round.steps % SURVIVE_STEPS === 0) gain(round, round.level);
fireLaser(round);
}
}
@@ -570,8 +728,10 @@ export function spawnItem(round, kind, random = Math.random) {
return null;
}
function pickPower(round, random) {
const kinds = Object.keys(POWERS).filter((k) => k !== "life" || (round.level >= LIFE_LEVEL && round.lives < MAX_LIVES));
// A pad for the arena: any whose `from` it has reached, a Heart only while
// there is room for a life, and for a Mystery to become, anything but another.
export function pickPower(round, random = Math.random, mystery = false) {
const kinds = Object.keys(POWERS).filter((k) => round.level >= POWERS[k].from && (k !== "life" || round.lives < MAX_LIVES) && !(mystery && k === "mystery"));
const total = kinds.reduce((sum, k) => sum + POWERS[k].weight, 0);
let roll = random() * total;
for (const k of kinds) {
@@ -608,6 +768,7 @@ function fadeRiders(round, ms) {
r.fade = 0;
for (let i = 0; i < round.grid.length; i++) if (round.grid[i] === r.id + 1) round.grid[i] = 0;
r.path = [];
r.wide = [];
}
}
@@ -616,8 +777,7 @@ function endHeat(round, result) {
round.phaseMs = DONE_MS;
round.result = result;
if (result === "win") {
const points = WIN_POINTS * round.level;
round.score += points;
const points = gain(round, WIN_POINTS * round.level);
round.heatsWon += 1;
round.events.push({ type: "win", points, level: round.level });
} else if (result === "lose") {
@@ -655,7 +815,8 @@ function race(round, ms, random) {
round.nextItem -= ms;
if (round.nextItem <= 0) {
round.nextItem = ITEM_MS + random() * ITEM_SPREAD_MS;
if (round.items.length < MAX_ITEMS) spawnItem(round, pickPower(round, random), random);
// Coin Rain's coins come on top: they never hold back a pad.
if (round.items.filter((it) => !it.rain).length < MAX_ITEMS) spawnItem(round, pickPower(round, random), random);
}
}
if (round.level >= SHRINK_LEVEL && round.ring < MAX_RING) {
@@ -670,7 +831,7 @@ function race(round, ms, random) {
for (const r of round.riders) {
if (!r.alive) continue;
if (r.stall) {
holdOn(round, r, ms);
holdOn(round, r, ms, random);
continue;
}
r.acc += ms;
@@ -706,6 +867,7 @@ export function advance(round, ms, random = Math.random) {
fadeRiders(round, slice);
if (round.phaseMs <= 0) nextHeat(round, random);
} else race(round, slice, random);
awardLives(round);
}
return round.over ? "over" : round.phase;
}
@@ -898,13 +1060,72 @@ function glyph(ctx, kind, x, y, s) {
ctx.lineTo(x + s * 0.35, y);
ctx.stroke();
} else if (kind === "life") {
ctx.moveTo(x, y + s * 0.8);
ctx.bezierCurveTo(x - s * 1.1, y, x - s * 0.6, y - s * 0.9, x, y - s * 0.35);
ctx.bezierCurveTo(x + s * 0.6, y - s * 0.9, x + s * 1.1, y, x, y + s * 0.8);
heartPath(ctx, x, y, s);
ctx.fill();
} else if (kind === "shield") {
ctx.moveTo(x, y - s * 0.85);
ctx.lineTo(x + s * 0.7, y - s * 0.55);
ctx.quadraticCurveTo(x + s * 0.65, y + s * 0.45, x, y + s * 0.9);
ctx.quadraticCurveTo(x - s * 0.65, y + s * 0.45, x - s * 0.7, y - s * 0.55);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x, y - s * 0.45);
ctx.lineTo(x, y + s * 0.5);
ctx.stroke();
} else if (kind === "laser") {
ctx.arc(x, y, s * 0.55, 0, Math.PI * 2);
for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
ctx.moveTo(x + dx * s * 0.3, y + dy * s * 0.3);
ctx.lineTo(x + dx * s * 0.95, y + dy * s * 0.95);
}
ctx.stroke();
ctx.beginPath();
ctx.arc(x, y, s * 0.14, 0, Math.PI * 2);
ctx.fill();
} else if (kind === "double" || kind === "mystery") {
// Dark on the bright yellow pad, white on the rest.
ctx.fillStyle = kind === "double" ? "#1d1a17" : "#ffffff";
ctx.font = `900 ${Math.round(s * (kind === "double" ? 1.25 : 1.7))}px system-ui, -apple-system, "Segoe UI", sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(kind === "double" ? "x2" : "?", x, y + s * 0.08);
} else if (kind === "wide") {
for (const dx of [-0.55, 0, 0.55]) {
ctx.moveTo(x + dx * s, y - s * 0.75);
ctx.lineTo(x + dx * s, y + s * 0.75);
}
ctx.stroke();
} else if (kind === "rain") {
for (const [dx, dy] of [[-0.45, -0.35], [0.45, -0.35], [0, 0.4]]) {
ctx.moveTo(x + dx * s + s * 0.32, y + dy * s);
ctx.arc(x + dx * s, y + dy * s, s * 0.32, 0, Math.PI * 2);
}
ctx.fill();
} else if (kind === "jump") {
// A spiral into an arrow: in here, out somewhere else.
ctx.arc(x - s * 0.1, y + s * 0.1, s * 0.55, Math.PI * 0.2, Math.PI * 1.6);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x + s * 0.25, y - s * 0.35);
ctx.lineTo(x + s * 0.9, y - s * 0.9);
ctx.moveTo(x + s * 0.4, y - s * 0.9);
ctx.lineTo(x + s * 0.9, y - s * 0.9);
ctx.lineTo(x + s * 0.9, y - s * 0.4);
ctx.stroke();
}
}
function heartPath(ctx, x, y, s) {
ctx.beginPath();
ctx.moveTo(x, y + s * 0.8);
ctx.bezierCurveTo(x - s * 1.1, y, x - s * 0.6, y - s * 0.9, x, y - s * 0.35);
ctx.bezierCurveTo(x + s * 0.6, y - s * 0.9, x + s * 1.1, y, x, y + s * 0.8);
}
// A Mystery pad's color, cycling through the rainbow.
const mysteryColor = (clock) => `hsl(${Math.round(clock / 6) % 360}, 85%, 58%)`;
function drawBoard(ctx, round, cell, colors, clock) {
const w = COLS * cell;
const h = ROWS * cell;
@@ -992,7 +1213,24 @@ function drawItems(ctx, round, cell, clock) {
ctx.fillRect(x - cell * 0.05 * w, y - cell * 0.22, cell * 0.1 * w, cell * 0.44);
continue;
}
const color = POWERS[item.kind].color;
if (item.kind === "life") {
// A Heart is just a heart, beating: lub-dub, then a rest.
const t = (clock % 900) / 900;
const beat = 1 + 0.16 * Math.max(0, Math.sin(t * Math.PI * 4)) * (t < 0.5 ? 1 : 0);
const s = cell * 0.62 * beat;
ctx.shadowColor = POWERS.life.color;
ctx.shadowBlur = cell * 1.1;
ctx.fillStyle = POWERS.life.color;
heartPath(ctx, x, y + cell * 0.05, s);
ctx.fill();
ctx.shadowBlur = 0;
ctx.fillStyle = "#ffd1e6";
ctx.beginPath();
ctx.arc(x - s * 0.38, y - s * 0.18, s * 0.16, 0, Math.PI * 2);
ctx.fill();
continue;
}
const color = item.kind === "mystery" ? mysteryColor(clock + item.x * 40) : POWERS[item.kind].color;
const s = cell * 0.62 * (1 + 0.1 * Math.sin(clock / 120 + item.x));
ctx.shadowColor = color;
ctx.shadowBlur = cell * 0.8;
@@ -1036,7 +1274,7 @@ function tracePath(ctx, r, cell, head) {
}
function drawTrail(ctx, round, r, cell, colors, clock, head) {
if (!r.path.length && !head) return;
if (!r.path.length && !head && !r.wide.length) return;
const color = riderColor(r, colors);
let alpha = 1;
if (!r.alive) {
@@ -1044,6 +1282,17 @@ function drawTrail(ctx, round, r, cell, colors, clock, head) {
if (Math.floor(clock / 60) % 2) alpha *= 0.5;
}
ctx.globalAlpha = alpha;
// A Wide Trail's side cells: glowing blocks either side of the line.
if (r.wide.length) {
ctx.shadowColor = color;
ctx.shadowBlur = cell * 0.5;
ctx.fillStyle = color;
for (const c of r.wide) {
roundRect(ctx, c.x * cell + cell * 0.16, c.y * cell + cell * 0.16, cell * 0.68, cell * 0.68, cell * 0.2);
ctx.fill();
}
ctx.shadowBlur = 0;
}
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.shadowColor = color;
@@ -1117,6 +1366,44 @@ function drawHead(ctx, round, r, cell, colors, clock, h, state) {
}
}
}
// A held Shield: a hexagon of light turning round your head.
if (r.id === 0 && r.alive && round.shield) {
ctx.strokeStyle = POWERS.shield.color;
ctx.globalAlpha = 0.6 + 0.3 * Math.sin(clock / 160);
ctx.lineWidth = Math.max(2, cell * 0.12);
ctx.beginPath();
for (let k = 0; k <= 6; k++) {
const a = clock / 700 + (k * Math.PI) / 3;
const px = h.x + Math.cos(a) * cell * 1.05;
const py = h.y + Math.sin(a) * cell * 1.05;
if (k) ctx.lineTo(px, py);
else ctx.moveTo(px, py);
}
ctx.stroke();
ctx.globalAlpha = 1;
}
// A running Laser: a dotted sight line out ahead of you.
if (r.id === 0 && r.alive && active(round, "laser") && round.phase === "race") {
ctx.strokeStyle = POWERS.laser.color;
ctx.globalAlpha = 0.35 + 0.2 * Math.sin(clock / 80);
ctx.lineWidth = Math.max(1, cell * 0.08);
if (typeof ctx.setLineDash === "function") ctx.setLineDash([cell * 0.2, cell * 0.35]);
ctx.beginPath();
ctx.moveTo(h.x + d.x * cell * 0.7, h.y + d.y * cell * 0.7);
ctx.lineTo(h.x + d.x * cell * LASER_REACH, h.y + d.y * cell * LASER_REACH);
ctx.stroke();
if (typeof ctx.setLineDash === "function") ctx.setLineDash([]);
ctx.globalAlpha = 1;
}
// Score x2: gold sparks wheeling round you.
if (r.id === 0 && r.alive && active(round, "double")) {
ctx.fillStyle = POWERS.double.color;
for (let k = 0; k < 3; k++) {
const a = clock / 260 + (k * Math.PI * 2) / 3;
star(ctx, h.x + Math.cos(a) * cell * 0.95, h.y + Math.sin(a) * cell * 0.95, cell * 0.2, cell * 0.08, a);
ctx.fill();
}
}
if (r.id === 0 && r.alive && active(round, "phase")) {
ctx.strokeStyle = POWERS.phase.color;
ctx.globalAlpha = 0.55 + 0.35 * Math.sin(clock / 90);
@@ -1148,6 +1435,35 @@ function drawHead(ctx, round, r, cell, colors, clock, h, state) {
}
}
// The Laser's shots: a hot white core in a red glow, fading fast.
function drawBeams(ctx, beams, cell) {
for (const b of beams) {
const t = b.life / b.max;
const ax = (b.from.x + 0.5) * cell;
const ay = (b.from.y + 0.5) * cell;
const bx = (b.to.x + 0.5) * cell;
const by = (b.to.y + 0.5) * cell;
ctx.lineCap = "round";
ctx.globalAlpha = t;
ctx.shadowColor = POWERS.laser.color;
ctx.shadowBlur = cell * 1.2;
ctx.strokeStyle = POWERS.laser.color;
ctx.lineWidth = cell * 0.55 * t + 2;
ctx.beginPath();
ctx.moveTo(ax, ay);
ctx.lineTo(bx, by);
ctx.stroke();
ctx.shadowBlur = 0;
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = Math.max(1, cell * 0.16 * t);
ctx.beginPath();
ctx.moveTo(ax, ay);
ctx.lineTo(bx, by);
ctx.stroke();
}
ctx.globalAlpha = 1;
}
function pill(ctx, x, y, h, text, color, fill = 1) {
ctx.font = `800 ${Math.round(h * 0.62)}px system-ui, -apple-system, "Segoe UI", sans-serif`;
const w = h * 0.7 + text.length * h * 0.42;
@@ -1155,10 +1471,10 @@ function pill(ctx, x, y, h, text, color, fill = 1) {
return w;
}
const EFFECT_LABELS = Object.freeze({ phase: "PHASE", slow: "SLOW-MO" });
const EFFECT_LABELS = Object.freeze({ phase: "PHASE", slow: "SLOW-MO", laser: "LASER", double: "x2 SCORE", wide: "WIDE" });
// The level, lives, boost charges, rivals left and each running effect,
// small along the top.
// The level, lives, boost charges, rivals left, a held Shield and each
// running effect (a Laser with its shots left), small along the top.
function drawHud(ctx, round, cell) {
const h = Math.max(14, cell * 0.78);
let x = cell * 0.35;
@@ -1169,9 +1485,11 @@ function drawHud(ctx, round, cell) {
x += pill(ctx, x, y, h, `BOOST ${charges}`, POWERS.boost.color, active(round, "boost") ? round.effects.boost / BOOST_MS : 1) + 6;
const left = round.riders.slice(1).filter((r) => r.alive).length;
x += pill(ctx, x, y, h, left === 1 ? "1 RIVAL" : `${left} RIVALS`, "#ffffff") + 6;
if (round.shield) x += pill(ctx, x, y, h, "SHIELD", POWERS.shield.color) + 6;
for (const [kind, ms] of Object.entries(round.effects)) {
if (!EFFECT_LABELS[kind]) continue;
x += pill(ctx, x, y, h, EFFECT_LABELS[kind], POWERS[kind].color, ms / POWERS[kind].ms) + 6;
const text = kind === "laser" ? `LASER ${"●".repeat(Math.max(0, round.shots))}` : EFFECT_LABELS[kind];
x += pill(ctx, x, y, h, text, POWERS[kind].color, ms / POWERS[kind].ms) + 6;
}
}
@@ -1242,13 +1560,19 @@ function teaser(furthest) {
const MAX_PARTS = 400;
function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onScore = () => {}, best = () => 0, memo = null }) {
function create({ canvas, tone: playTone = () => {}, hum: playHum = () => {}, music = () => {}, onScore = () => {}, best = () => 0, memo = null }) {
// Every sound a little louder than made, so it carries over the songs; the
// engine drones are left as they are, low under them.
const tone = (name, level = 1, pitch = 1) => playTone(name, level, pitch, SFX_LOUDER);
const hum = (id, name, level = 1, pitch = 1) => playHum(id, name, level, pitch, DRONES.has(id) ? 1 : SFX_LOUDER);
const ctx = canvas.getContext("2d");
let colors = null;
let round = newRound();
// The round's deal of tracks, and the one it opened on (so the next round opens on another).
// The run's deal of songs, the one playing in it, and whether that one
// still has to be started from the top (cleared once the music takes it).
let deck = [];
let opener = null;
let songAt = 0;
let fresh = false;
let state = "ready";
let cell = MIN_CELL;
let bestAtStart = 0;
@@ -1262,7 +1586,7 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
// Sparks, floating points, the big banners, the shake and the flash, all
// in cell units and ms, so a resize mid-round keeps them in place.
let fx = null;
const resetFx = () => (fx = { parts: [], floats: [], banners: [], shake: 0, shakeMag: 0, flash: null, clock: 0 });
const resetFx = () => (fx = { parts: [], floats: [], banners: [], beams: [], shake: 0, shakeMag: 0, flash: null, clock: 0 });
resetFx();
const burst = (p, color, n, speed = 6) => {
@@ -1291,7 +1615,9 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
// and whether you were held up, grazing a wall or passing a rival. It only
// reads the round; nothing here changes a rule or a score.
let sfx = null;
const resetSfx = () => (sfx = { later: [], effects: {}, items: new Set(), stalled: false, grazing: false, close: false, swooshAt: 0, whooshAt: 0 });
// The kinds of pad taken this run, so the first of each says it is new.
let seenPowers = new Set();
const resetSfx = () => (sfx = { later: [], effects: {}, items: new Set(), stalled: false, grazing: false, close: false, swooshAt: 0, whooshAt: 0, mystery: false });
resetSfx();
const later = (ms, name, level = 1, pitch = 1) => sfx.later.push({ at: fx.clock + ms, name, level, pitch });
const vary = (spread = 0.08) => 1 - spread / 2 + Math.random() * spread;
@@ -1321,7 +1647,8 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
if (e.by === 0 && e.points) later(120, "trailsCutOff", 0.7);
burst(p, color, 34, 9);
shake(200, 0.15);
if (e.points) float(p, e.by === 0 ? `Cut off! +${e.points}` : `+${e.points}`, e.by === 0 ? GOLD : color);
if (e.points && e.by === "laser") float(p, `Zapped! +${e.points}`, POWERS.laser.color);
else if (e.points) float(p, e.by === 0 ? `Cut off! +${e.points}` : `+${e.points}`, e.by === 0 ? GOLD : color);
else float(p, "Out!", color);
} else if (e.type === "crash") {
tone("crash");
@@ -1332,7 +1659,9 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
flash(DANGER, 320);
} else if (e.type === "power") {
const spec = POWERS[e.kind];
if (e.kind === "coin") {
const fromMystery = sfx.mystery;
sfx.mystery = false;
if (e.kind === "coin" && !fromMystery) {
tone("coin");
tone("sparkle", 0.5, vary());
burst(p, GOLD, 10, 4);
@@ -1343,7 +1672,24 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
if (e.kind === "boost") tone("trailsCharge", 0.8);
else if (e.kind === "phase") tone("trailsPhaseIn", 0.8);
else if (e.kind === "slow") tone("trailsSlowmo", 0.8);
else if (e.kind === "life") later(150, "extraLife", 0.8);
else if (e.kind === "life") {
tone("trailsHeart", 0.9);
later(300, "extraLife", 0.7);
float(p, "+1 ♥", POWERS.life.color);
} else if (e.kind === "shield") tone("shieldUp", 0.8);
else if (e.kind === "laser") tone("laser", 0.7);
else if (e.kind === "double") {
tone("coinUp", 0.8);
later(160, "sparkle", 0.6);
} else if (e.kind === "wide") tone("riser", 0.7);
else if (e.kind === "rain") {
tone("coinUp", 0.8);
for (let k = 1; k <= 4; k++) later(k * 110, "coin", 0.4, 1 + k * 0.08);
for (const it of round.items) if (it.rain) burst(it, GOLD, 8, 3);
} else if (e.kind === "coin") {
tone("coin");
float(p, `+${e.points}`, GOLD);
}
burst(p, spec.color, 26, 8);
if (e.kind === "eraser") {
tone("sizzle");
@@ -1351,7 +1697,40 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
burst(p, spec.color, 60, 14);
shake(180, 0.12);
}
banner(spec.name, spec.blurb, spec.color, 1400);
// The first of a kind in a run says it is new; a Mystery says what it was.
const b = banner(fromMystery ? `Mystery: ${spec.name}!` : spec.name, spec.blurb, spec.color, 1400);
if (b && !seenPowers.has(e.kind)) b.tag = "NEW POWER-UP";
seenPowers.add(e.kind);
} else if (e.type === "mystery") {
tone("mystery");
sfx.mystery = true;
burst(p, POWERS.mystery.color, 20, 7);
burst(p, GOLD, 12, 5);
} else if (e.type === "laser") {
tone("trailsLaser", 0.9, vary());
fx.beams.push({ from: e.from, to: e.to, life: 260, max: 260 });
burst(e.to, POWERS.laser.color, 30, 9);
shake(180, 0.15);
} else if (e.type === "shield") {
tone("trailsShieldPop");
later(200, "trailsSave", 0.8);
burst(p, POWERS.shield.color, 50, 11);
burst(p, "#ffffff", 16, 6);
shake(260, 0.2);
flash(POWERS.shield.color, 300);
banner("Shield!", "It took the crash for you", POWERS.shield.color, 1400);
} else if (e.type === "jump") {
tone("trailsJump");
burst(e.from, POWERS.jump.color, 24, 7);
burst(e.to, POWERS.jump.color, 34, 9);
flash(POWERS.jump.color, 220);
} else if (e.type === "bonusLife") {
tone("trailsHeart");
later(320, "extraLife", 0.8);
const you = round.riders[0];
burst(you, POWERS.life.color, 30, 8);
float(you, "+1 ♥", POWERS.life.color);
banner("Extra life!", `${e.at} points scored`, POWERS.life.color, 1600);
} else if (e.type === "snatch") {
tone("trailsSnatch", 0.6);
burst(p, RIVALS[e.id].color, 10, 4);
@@ -1437,11 +1816,12 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
}
const racing = round.phase === "race";
const you = round.riders[0];
const on = { boost: active(round, "boost"), phase: active(round, "phase"), slow: active(round, "slow") };
const on = Object.fromEntries(["boost", "phase", "slow", "laser", "double", "wide"].map((k) => [k, active(round, k)]));
if (racing && you.alive) {
if (sfx.effects.boost && !on.boost) tone("trailsBoostOut", 0.7);
if (sfx.effects.phase && !on.phase) tone("trailsPhaseOut", 0.7);
if (sfx.effects.slow && !on.slow) tone("trailsSlowEnd", 0.7);
for (const k of ["laser", "double", "wide"]) if (sfx.effects[k] && !on[k]) tone("powerDown", 0.5);
}
sfx.effects = on;
if (round.phase === "ready") {
@@ -1467,7 +1847,8 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
const d = Math.hypot(r.x - you.x, r.y - you.y);
if (d < gap) [rival, gap] = [r, d];
}
if (rival) hum("trails:rival", "cycle", Math.max(0, 1 - gap / 18), (0.8 + 0.25 * (STEP_MS / pace(round, rival))) * (1 + rival.id * 0.04));
// The nearest rival's drone, kept low under the songs (the shared hum is louder).
if (rival) hum("trails:rival", "cycle", RIVAL_HUM * Math.max(0, 1 - gap / 18), (0.8 + 0.25 * (STEP_MS / pace(round, rival))) * (1 + rival.id * 0.04));
const close = gap <= 2.5;
if (close && !sfx.close && fx.clock >= sfx.whooshAt) {
tone("whoosh", 0.6, vary(0.2));
@@ -1521,6 +1902,7 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
b.life -= ms;
if (b.life <= 0) fx.banners.shift();
}
fx.beams = fx.beams.filter((b) => (b.life -= ms) > 0);
fx.shake = Math.max(0, fx.shake - ms);
if (fx.flash) {
fx.flash.life -= ms;
@@ -1550,6 +1932,7 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
const heads = new Map(order.map((r) => [r, r.alive || r.fade > 0 ? headPoint(round, r, cell, state) : null]));
for (const r of order) drawTrail(ctx, round, r, cell, colors, clock, r.alive ? heads.get(r) : null);
for (const r of order) if (heads.get(r)) drawHead(ctx, round, r, cell, colors, clock, heads.get(r), state);
drawBeams(ctx, fx.beams, cell);
for (const p of fx.parts) {
ctx.globalAlpha = Math.max(0, p.life / p.max);
ctx.fillStyle = p.color;
@@ -1578,11 +1961,13 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
const start = () => {
colors = null;
round = newRound();
deck = dealMusic(Math.random, opener);
opener = deck[0];
deck = dealMusic(Math.random, deck[songAt] ?? null);
songAt = 0;
fresh = true;
state = "running";
resetFx();
resetSfx();
seenPowers = new Set();
try {
bestAtStart = Number(best()) || 0;
} catch {
@@ -1593,6 +1978,20 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
paint();
};
// Keeps the song going; once it has played through, the next in the deal,
// and after the last a fresh deal.
const playMusic = () => {
const heard = music(deck[songAt], 1, fresh ? { restart: true } : undefined);
if (heard) fresh = false;
if (heard !== "ended") return;
songAt += 1;
if (songAt >= deck.length) {
deck = dealMusic(Math.random, deck.at(-1));
songAt = 0;
}
fresh = true;
};
const end = () => {
state = "over";
tone("crash");
@@ -1642,7 +2041,7 @@ function create({ canvas, tone = () => {}, hum = () => {}, music = () => {}, onS
if (round.over) end();
else {
listen();
if (deck.length) music(trackFor(deck, round.level), heat(round));
if (deck.length) playMusic();
}
paint();
},
+10 -6
View File
@@ -2705,11 +2705,15 @@
though you hold in place for a split second first, so a quick
turn still gets you clear.
Win a heat to move on through nine arenas; a crash costs one of
three lives and runs the heat again. The arenas bring more rivals,
power-up pads (Boost, Phase through trails, an Eraser, Slow-mo for
the rivals, coins and a 1UP), crystals, portals, and walls that
close in a ring at a time, flashing red first. A rival out scores,
and more if it hit your trail.
five lives and runs the heat again, and every 750 points or a
Heart pad gives one back. The arenas bring more rivals, crystals,
portals, walls that close in a ring at a time (flashing red
first) and ever more power-up pads: Boost, Phase through trails,
an Eraser, Slow-mo for the rivals, coins, a Heart and a Shield that
takes a crash, then a Laser that zaps rivals in your line, Score
x2, a Wide Trail three cells across, Coin Rain, a Hyperjump to open
space and a Mystery pad that could be any of them. A rival out
scores, and more if your trail or your laser got it.
</li>
<li>
<strong>Bug Hunt</strong>: fly Planny's ship along the bottom and
@@ -3645,7 +3649,7 @@
<label><input type="checkbox" id="looks-activities" checked /> <span>Show Activities</span></label>
<label><input type="checkbox" id="looks-activity-sounds" checked /> <span>Play game sounds</span></label>
<label><input type="checkbox" id="looks-game-music" /> <span>Play game music</span></label>
<p class="help">The die in the top bar opens small games to play while you wait. Play game sounds turns the games' sounds on or off, and Play game music their chiptune music; Play sounds, above, silences them too.</p>
<p class="help">The die in the top bar opens small games to play while you wait. Play game sounds turns the games' sounds on or off, and Play game music their music; Play sounds, above, silences them too.</p>
</fieldset>
</section>
</div>
+1 -1
View File
@@ -37,7 +37,7 @@ export const DEFAULT_LOOKS = {
// course (activityBestGolfPirate), each a flat key for cleanLooks().
hideActivities: false,
activitySounds: true,
// Whether a game plays its chiptune music too: off until asked for.
// Whether a game plays its music too (chiptune or recorded songs): off until asked for.
gameMusic: false,
lastActivity: "",
...Object.fromEntries(ACTIVITIES.flatMap((a) => bestKeys(a).map((key) => [key, 0]))),
+97 -5
View File
@@ -1,7 +1,7 @@
// Plan2Code Web Console - the games' music: a small chiptune sequencer over tones.js's audio, silent unless Play sounds and the game's own switches allow it; defines only.
// Plan2Code Web Console - the games' music: a small chiptune sequencer over tones.js's audio, and recorded songs, silent unless Play sounds and the game's own switches allow it; defines only.
import { looks } from "./looks.js";
import { MUSIC_TABLES, audioOut } from "./tones.js";
import { MUSIC_TABLES, SONG_TABLES, audioOut } from "./tones.js";
/* -------------------------------------------------------------- music
@@ -374,16 +374,107 @@ function tick() {
}
}
/* ---------------------------------------------------------- the songs
A game may play recorded songs instead: mp3 files named under `songs` in
its `activities/<id>-sfx.js`, a name to a path the server serves. It asks
for one the same way, music(name, intensity, volume, options), every frame
it wants it (the intensity does nothing here), and the song fades out
within MUSIC_HOLD_MS once it stops being asked for, paused where it was, so
a paused game picks it up again mid-song. A song plays once through, never
looped: music() returns "playing" while it does and "ended" once it is
over, which is the game's cue to ask for the next, and { restart: true }
plays it from the top. It returns nothing while it plays nothing. */
const SONGS = Object.freeze(Object.assign({}, ...SONG_TABLES));
export const songNames = () => Object.keys(SONGS);
// A recording is mastered far louder than the chip voices: this keeps one
// under the game's own sounds at full volume.
export const SONG_PEAK = 0.45;
// A song's fade in or out, from silence to SONG_PEAK.
const SONG_FADE_MS = 400;
// One element a song, made the first time it is asked for, so nothing is
// downloaded for a game nobody plays.
const songAudio = new Map();
// The song playing now: its name, its element, the volume it is headed for
// and when the game last asked for it.
let song = null;
let songTicker = null;
function songElement(name) {
if (!songAudio.has(name)) {
const el = new Audio(`/${SONGS[name]}`);
el.preload = "auto";
el.volume = 0;
songAudio.set(name, el);
}
return songAudio.get(name);
}
function hushSong() {
if (songTicker) clearInterval(songTicker);
songTicker = null;
if (!song) return;
try {
song.el.pause();
song.el.volume = 0;
} catch {}
song = null;
}
// Glides the volume toward where it is headed; a song no longer asked for
// glides to silence and pauses there.
function songTick() {
const p = song;
if (!p) return hushSong();
const held = looks.sound && performance.now() - p.seen <= MUSIC_HOLD_MS;
const target = held ? p.target : 0;
const step = (SONG_PEAK * TICK_MS) / SONG_FADE_MS;
const v = p.el.volume;
p.el.volume = target > v ? Math.min(target, v + step) : Math.max(target, v - step);
if (!held && p.el.volume <= 0) hushSong();
}
function playSong(name, level, options) {
if (typeof Audio !== "function") return undefined;
if (song && song.name !== name) hushSong();
const el = songElement(name);
// load() is the way back to the top: it needs no seeking, which a file
// served without byte ranges cannot always do.
if (options && options.restart && (el.ended || el.currentTime > 0)) el.load();
if (!song) song = { name, el, target: 0, seen: 0, starting: false };
const p = song;
p.seen = performance.now();
p.target = SONG_PEAK * level;
if (el.ended) return "ended";
if (el.paused && !p.starting) {
p.starting = true;
Promise.resolve(el.play())
.catch(() => {})
.finally(() => (p.starting = false));
}
if (!songTicker) songTicker = setInterval(songTick, TICK_MS);
return "playing";
}
// Keeps the track `name` playing for another moment at `intensity` (0 to 1,
// how hot play is: it brings voices in and pushes the tempo). Asking for a
// different track crossfades from the last one to this one over
// CROSSFADE_S. `volume` (0 to 1) scales the whole track; at 0 it is not
// asked for, so it fades out. Silence, never an error, while Play sounds is
// off or audio cannot play.
export function music(name, intensity = 0.5, volume = 1) {
// off or audio cannot play. A song (above) plays instead when `name` is one,
// and what it returns is the song's "playing" or "ended".
export function music(name, intensity = 0.5, volume = 1, options = undefined) {
try {
const level = Math.min(1, Math.max(0, Number(volume) || 0));
if (!Object.hasOwn(TRACKS, name) || !looks.sound || level <= 0) return;
if (!looks.sound || level <= 0) return undefined;
if (Object.hasOwn(SONGS, name)) return playSong(name, level, options);
if (!Object.hasOwn(TRACKS, name)) return;
const a = audioOut();
if (!a) return;
let ramp = 0.25;
@@ -414,4 +505,5 @@ export function music(name, intensity = 0.5, volume = 1) {
// Quiets the music at once: the window stopped ticking a game.
export function hushMusic() {
hushAll(audioOut());
hushSong();
}
+5 -3
View File
@@ -31,9 +31,11 @@ const hum = (...args) => {
if (looks.activitySounds) playHum(...args);
};
// And the music, which also needs Play game music, at the game's own
// music volume (the window's Music slider).
const musicFor = (entry) => (name, intensity) => {
if (looks.activitySounds && looks.gameMusic) playMusic(name, intensity, musicLevel(entry, looks[musicKey(entry.id)]));
// music volume (the window's Music slider). A song's "playing" or "ended"
// goes back to the game, which moves on to its next song on "ended".
const musicFor = (entry) => (name, intensity, options) => {
if (looks.activitySounds && looks.gameMusic) return playMusic(name, intensity, musicLevel(entry, looks[musicKey(entry.id)]), options);
return undefined;
};
const MUSIC_TITLE = "This game's music volume";
const MUSIC_OFF_TITLE = "Turn on Play game music in User Preferences to hear it";
+14 -6
View File
@@ -388,6 +388,8 @@ export const TONE_TABLES = Object.freeze([BLIPS, RICH, ...GAME_SFX.map((s) => de
export const HUM_TABLES = Object.freeze([HUMS, ...GAME_SFX.map((s) => deepFreeze(s.hums || {}))]);
// And each game's chiptune tracks, which music.js plays.
export const MUSIC_TABLES = Object.freeze(GAME_SFX.map((s) => deepFreeze(s.music || {})));
// And their recorded songs (a name to an mp3 the server serves), which music.js plays too.
export const SONG_TABLES = Object.freeze(GAME_SFX.map((s) => deepFreeze(s.songs || {})));
const TONES = Object.freeze(Object.assign({}, ...TONE_TABLES));
const ALL_HUMS = Object.freeze(Object.assign({}, ...HUM_TABLES));
@@ -575,18 +577,24 @@ function voice(c, p, t0, peak, k) {
src.stop(end);
}
// The most a game may lift its own sounds by with `louder`.
export const LOUDER_MAX = 2;
const loudness = (louder) => Math.min(LOUDER_MAX, Math.max(0, Number(louder ?? 1) || 0));
// Plays one named blip, at `level` (0 to 1) of the usual loudness: a soft
// putt sounds soft. `pitch` scales every frequency (2 is an octave up, kept
// between two octaves down and two up), so a game can climb a scale on one
// blip. An unknown name, Play sounds off, or a context that is missing,
// suspended or closed all mean silence, not an error.
export function tone(name, level = 1, pitch = 1) {
// suspended or closed all mean silence, not an error. `louder` scales a
// game's sounds as a whole past the usual loudness (1 is as made, kept
// between 0 and LOUDER_MAX), for a game whose sounds sit under its music.
export function tone(name, level = 1, pitch = 1, louder = 1) {
try {
const spec = Object.hasOwn(TONES, name) ? TONES[name] : null;
if (!spec || !looks.sound) return;
const c = audioContext();
if (!c || c.state !== "running") return;
const peak = Math.max(FLOOR * 10, PEAK * Math.min(1, Number(level) || 0));
const peak = Math.max(FLOOR * 10, PEAK * Math.min(1, Number(level) || 0) * loudness(louder));
const t0 = c.currentTime;
const k = Math.min(4, Math.max(0.25, Number(pitch) || 1));
if (spec.layers) {
@@ -696,8 +704,8 @@ function watch() {
// 1) of its loudness and `pitch` (1 is its own, kept between 0.25 and 4).
// Asking under a different name restarts it as that one. Like tone(), it is
// silence, never an error, while Play sounds is off or the audio is not
// running.
export function hum(id, name, level = 1, pitch = 1) {
// running. `louder` is tone()'s.
export function hum(id, name, level = 1, pitch = 1, louder = 1) {
try {
const spec = Object.hasOwn(ALL_HUMS, name) ? ALL_HUMS[name] : null;
const c = audioContext();
@@ -716,7 +724,7 @@ export function hum(id, name, level = 1, pitch = 1) {
v.seen = performance.now();
const t = c.currentTime;
const k = Math.min(4, Math.max(0.25, Number(pitch) || 1));
const loud = spec.peak * Math.min(1, Math.max(0, Number(level) || 0));
const loud = spec.peak * Math.min(1, Math.max(0, Number(level) || 0)) * loudness(louder);
v.level.gain.setTargetAtTime(loud, t, GLIDE);
v.oscs.forEach((o, i) => o.frequency.setTargetAtTime(spec.parts[i].freq * k, t, GLIDE));
if (v.filter) v.filter.frequency.setTargetAtTime(Math.min(18000, spec.filter.freq * k ** (spec.filter.follow ?? 1)), t, GLIDE);
+3 -1
View File
@@ -623,9 +623,11 @@ function onListening(port) {
try {
process.send?.({ type: "listening", port });
} catch {}
// Warm the asset cache while the browser is still on its way.
// Warm the asset cache while the browser is still on its way. Not with a
// game's songs: megabytes read for a game that may never be played.
setImmediate(() => {
for (const rel of SERVABLE) {
if (rel.startsWith("activities/") && rel.endsWith(".mp3")) continue;
try {
asset(rel);
} catch {}
+5 -1
View File
@@ -222,7 +222,11 @@ export const SERVABLE = new Set([
"activities/snake-music.js",
"activities/golf-sfx.js",
"activities/trails-sfx.js",
"activities/trails-music.js",
"activities/light-trails/1.mp3",
"activities/light-trails/2.mp3",
"activities/light-trails/3.mp3",
"activities/light-trails/4.mp3",
"activities/light-trails/5.mp3",
"activities/bugs-sfx.js",
"activities/drive-sfx.js",
"activities/stack-sfx.js",