[GH-ISSUE #5161] Game music: persistent per-area and per-enemy-tier tracks, generated once and selected in play — not per-turn 30-second clips #2856

Closed
opened 2026-10-21 05:56:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5161

Originally assigned to: @kolacheee on GitHub.

The problem, as it plays today: turn on Game music (an ElevenLabs audio connection with Music enabled, since #5146), start a game, and walk between a few locations. The scene analyzer writes a fresh free-text mood prompt as scenes change, and every new prompt generates a brand-new 30-second instrumental clip (music_length_ms: 30_000 is hardcoded in the game-audio route). The result: music that lurches to a different track every turn or two, 30-second loops that were never composed to loop, and a metered generation call for every distinct mood sentence the analyzer happens to phrase. That's a soundtrack for a slideshow, not a game.

Try it yourself: enable Game music, play ~5 turns crossing two locations and starting one combat, and count the distinct clips in game-assets/music/generated/ — then listen to how often the music restarts.

The redesign — persistent, context-bound tracks, selected rather than generated:

  1. A small track set per game, generated once into the game-assets library. One track per map/area (exterior zones and notable interiors — the same location slugs that already key background images), one per enemy tier (common / miniboss / boss / special), plus a default/travel track. Each lands in the game's music library like an uploaded track — visible in Game Assets, auditionable, replaceable — tagged with its context (location slug or tier).
  2. Generated lazily, like backgrounds. Backgrounds already generate on first visit to a new location; music should ride the same trigger (first entry to an area → its track generates once; first miniboss → the miniboss track). No new batch pre-generation machinery needed, and the set stays bounded: N areas + 4 tiers + 1 default per game, ever — versus unbounded per-turn clips.
  3. Selection during play replaces prompt-writing. The engine already has a tag-scoring selector that picks bundled CC0 tracks by scene tags; when the track library exists, the analyzer stops emitting free-text music prompts and the same selection mechanism picks from the generated set by location and combat context (encounter tier → tier track). Music then only changes when context changes — entering a new area, combat starting/escalating — and otherwise keeps playing.
  4. Longer, loopable compositions. Per-track length becomes a real parameter (the API accepts longer music_length_ms; response-size caps need raising accordingly), with prompts asking for loop-friendly instrumental beds. One 2–3 minute track per context beats six 30-second clips in every way, including cost.
  5. Sound effects stay exactly as they are — on-demand generation with the prompt-hash cache is the right model for one-shot effects.

What this builds on (all merged): #5146 audio connections carry the per-game connection and the Music capability flag plus the per-game toggles; the game-audio route, the prompt-hash cache under game-assets/music/generated/, the tag-scoring selector for the bundled library, and location-slug asset keying all exist. This issue is about when music generates (once per context, not per turn) and how it's chosen (selection from a stable library, not prompt churn).

Origin: this replaces the design that #5145 was closed for — the per-turn mood-clip surfacing was rejected in favor of this model when audio connections (#5146) were chosen as the foundation.

Originally created by @kolacheee on GitHub (Aug 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5161 Originally assigned to: @kolacheee on GitHub. **The problem, as it plays today:** turn on Game music (an ElevenLabs audio connection with Music enabled, since #5146), start a game, and walk between a few locations. The scene analyzer writes a fresh free-text mood prompt as scenes change, and every new prompt generates a brand-new **30-second instrumental clip** (`music_length_ms: 30_000` is hardcoded in the game-audio route). The result: music that lurches to a different track every turn or two, 30-second loops that were never composed to loop, and a metered generation call for every distinct mood sentence the analyzer happens to phrase. That's a soundtrack for a slideshow, not a game. **Try it yourself:** enable Game music, play ~5 turns crossing two locations and starting one combat, and count the distinct clips in `game-assets/music/generated/` — then listen to how often the music restarts. **The redesign — persistent, context-bound tracks, selected rather than generated:** 1. **A small track set per game, generated once into the game-assets library.** One track per map/area (exterior zones and notable interiors — the same location slugs that already key background images), one per enemy tier (**common / miniboss / boss / special**), plus a default/travel track. Each lands in the game's music library like an uploaded track — visible in Game Assets, auditionable, replaceable — tagged with its context (location slug or tier). 2. **Generated lazily, like backgrounds.** Backgrounds already generate on first visit to a new location; music should ride the same trigger (first entry to an area → its track generates once; first miniboss → the miniboss track). No new batch pre-generation machinery needed, and the set stays bounded: N areas + 4 tiers + 1 default per game, ever — versus unbounded per-turn clips. 3. **Selection during play replaces prompt-writing.** The engine already has a tag-scoring selector that picks bundled CC0 tracks by scene tags; when the track library exists, the analyzer stops emitting free-text music prompts and the same selection mechanism picks from the generated set by location and combat context (encounter tier → tier track). Music then only *changes* when context changes — entering a new area, combat starting/escalating — and otherwise keeps playing. 4. **Longer, loopable compositions.** Per-track length becomes a real parameter (the API accepts longer `music_length_ms`; response-size caps need raising accordingly), with prompts asking for loop-friendly instrumental beds. One 2–3 minute track per context beats six 30-second clips in every way, including cost. 5. **Sound effects stay exactly as they are** — on-demand generation with the prompt-hash cache is the right model for one-shot effects. **What this builds on (all merged):** #5146 audio connections carry the per-game connection and the Music capability flag plus the per-game toggles; the game-audio route, the prompt-hash cache under `game-assets/music/generated/`, the tag-scoring selector for the bundled library, and location-slug asset keying all exist. This issue is about *when* music generates (once per context, not per turn) and *how* it's chosen (selection from a stable library, not prompt churn). **Origin:** this replaces the design that #5145 was closed for — the per-turn mood-clip surfacing was rejected in favor of this model when audio connections (#5146) were chosen as the foundation.
bsakaguchi 2026-10-21 05:56:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2856
No description provided.