Skip to content

feat(console): persistent music, per-theme tunes - #5

Merged
jjsnack merged 2 commits into
mainfrom
feat/theme-tunes
Jul 28, 2026
Merged

feat(console): persistent music, per-theme tunes#5
jjsnack merged 2 commits into
mainfrom
feat/theme-tunes

Conversation

@jjsnack

@jjsnack jjsnack commented Jul 28, 2026

Copy link
Copy Markdown
Owner

What

Console soundtrack now persists across the site and has a tune per theme.

Persistence

  • Music state (music) and musicVolume saved to localStorage, restored on load.
  • Autoplay policy blocks a gesture-less resume, so restore arms a one-time interaction listener instead of calling on() at load — which previously left resume() pending while playing stayed true, wedging every later music play.
  • Closing the console no longer stops playback; music stop does.

Per-theme tunes (assets/js/tunes.js, new)

  • Note data extracted out of the engine, keyed by theme; engine swaps live on theme set.
  • default (light/dark/auto): original C-major, unchanged.
  • dracula: A-minor, hollow square lead, slower — moody.
  • valentine: F-major, soft sine lead — sweet.
  • paper: D-major folk, triangle lead, plagal turnaround — cozy.
  • dracula/valentine/paper are 8-bar phrases that resolve to the tonic so the loop wraps seamlessly.

console.html concats tunes.js + console.js so window.TUNES exists before the engine reads it.

Test

  • node assets/js/console.js self-check passes.
  • pnpm build clean; bundle carries all tunes and is referenced in HTML.
  • Tune data validated: 32/64 steps, lead/bass lengths match, each theme resolves to its tonic.
  • Not verified by ear — browser extension wasn't connected in this environment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbMGFzZfHUfbhid95FjBKb

jjsnack and others added 2 commits July 28, 2026 13:41
Music state now survives navigation and console close:
- persist `music`/`musicVolume` to localStorage, restore on load
  (falls back to first user gesture when autoplay is blocked)
- closing the console no longer stops playback; `music stop` does

Tunes extracted to assets/js/tunes.js, keyed by theme. Engine reads
the active theme's tune and swaps live on `theme set`:
- default (light/dark/auto): original C-major triangle, unchanged
- dracula: A-minor square lead, slower — moody but chill
- valentine: F-major sine lead — soft and sweet

console.html concats tunes.js + console.js so window.TUNES exists
before the engine reads it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbMGFzZfHUfbhid95FjBKb
- add a distinct `paper` soundtrack (D-major folk, plagal turnaround)
- extend dracula/valentine to 8-bar phrases that resolve to the tonic
  so the loop wraps seamlessly
- fix music not playing: the load-time restore called on() with no
  user gesture, leaving resume() pending while `playing` stayed true,
  which wedged every later `music play`. Restore now arms a one-time
  gesture listener instead; on() clears any stale interval.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbMGFzZfHUfbhid95FjBKb
@jjsnack
jjsnack merged commit 1c7167e into main Jul 28, 2026
1 check passed
@jjsnack
jjsnack deleted the feat/theme-tunes branch July 28, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant