Skip to main content
adaptive-music is a skill from the Summer skill library: a guide your AI agent reads when the task matches, so it builds the good version on the first try. Wire music stems to game state: combat, explore, boss and tension crossfades on a shared bus.

When your agent uses it

  • Wiring music stems to game state — combat / explore / boss / tension crossfades on a shared bus
  • Layered or vertical music that changes when combat starts

Install

summer setup installs every skill for your agent. To add only this one:
Swap claude-code for your agent, such as codex or cursor. See Skills for every option.

The skill

Overview

This skill wires music; it does not generate it. It connects 3–5 music stems (or full tracks) to a game state machine so the music follows the player’s situation — exploration → tension → combat → victory → exploration — with crossfades, ducking, and bus routing. This skill assumes the stems already exist. If they don’t, run /music-track first for each state, or generate matching stems (same tempo, same key, same bar count) so they layer/crossfade cleanly.

When to use

  • The audio bible specifies a dynamic music model (layered stems / vertical re-orchestration / horizontal sequencing).
  • You have at least two music tracks for two different states and want the engine to switch between them.
  • Player-state-driven crossfades, not random shuffling.

When NOT to use

  • Generating the stems themselves → /music-track.
  • Single static loop with no state changes → /music-track and an AudioStreamPlayer is enough.

Steps

1. Read the audio bible’s dynamic music plan

Quote the plan back. Example:
Bible plan: Layered stems. States CALM / TENSION / COMBAT / VICTORY. CALM → TENSION on enemy detect (2s crossfade). TENSION → COMBAT on first damage (instant drum stem). COMBAT → VICTORY on last enemy dies (drum cuts, brass swell). VICTORY → CALM after 4s. Music ducks -6 dB on dialogue.
If the plan is absent, run /audio-direction step 6 first.

2. Pick the wiring model

For most games, horizontal sequencing is right. It is cheaper to author and easier to swap.

3. Confirm stems exist (or generate them)

You need (typical case):
  • audio/music/calm.mp3 — exploration loop, sparse
  • audio/music/tension.mp3 — same tempo/key, denser, no drums
  • audio/music/combat.mp3 — same tempo/key, full drums, urgent
  • (optional) audio/music/boss.mp3 — distinct from combat
  • (optional) audio/music/victory.mp3 — short linear sting (4–8s)
If any are missing, run /music-track for each. Use the same BPM, key, time signature, and bar length for all of them so they overlap cleanly.

4. Verify / extend the bus layout

The Music bus must exist and route to Master. If /audio-direction ran, it does. Verify:
You want this structure:
If Music bus is missing, run /audio-direction step 8. For ducking, add a sidechain compressor on the Music bus with the Voice bus as the sidechain source. Or implement ducking in code (simpler — see step 7).

5. Build the player rig

For horizontal sequencing, instantiate one AudioStreamPlayer per state, all on the Music bus, all autoplay, all looping, all starting at -60 dB except the active state. One script builds the whole rig (scenePath is the exact scene to change; ctx.save_scene() writes it):
A fourth state (Boss) is one more entry in states, not five more calls. Loop the streams on the imported files (loop in the import settings, or AudioStreamMP3.loop), not on the player. All three play simultaneously, in sync, but only one is audible. State transitions tween volumes — the music never restarts, only fades. This is why same BPM / same key / same bar length matter: all three are at the same playhead at all times.

6. The MusicDirector script

Attach it under /root/Game/Music, hook the exported player slots to the four players. The director is the single point of truth for music state.

7. Drive state from gameplay signals

Where does set_state() get called from? The game state machine. Hook signals from combat / detection / encounter logic:
If your project doesn’t have an EventBus autoload yet, add one — adaptive music depends on event-driven signals, not polling. Wire the connections via summer_connect_signal so they survive a scene reload.

8. Layered stems variant (alternative to step 6)

If the bible says layered stems instead of horizontal sequencing, the rig is the same (multiple AudioStreamPlayers, all looping in sync, all on Music bus) but the volume map is different: The director method is the same _apply_state pattern — just more players and per-player target_db tables.

9. Bar-locked snap (vertical re-orchestration)

For the third model, snapping must happen on a bar boundary (not mid-phrase). All players run in sync; on state change, schedule the snap for the next bar:
Use this for boss reveals, story beats — anywhere a snap-on-bar is more dramatic than a crossfade.

10. Test the transitions

Run the game (summer_play) and trigger each transition. Listen for:
  • Crossfade artifacts at crossfade_seconds = 2.0. Too fast: fades are choppy. Too slow: state changes feel disconnected from gameplay.
  • Out-of-sync stems. If combat enters and the drums hit on the wrong beat, the stems weren’t generated at the same BPM/bar length. Regenerate.
  • Ducking that’s too aggressive (music disappears) or too subtle (voice still buried). The -6 dB is a starting value; tune in step 7.
  • Victory sting that loops (it shouldn’t). Set victory_sting to a non-loop AudioStream.

11. Edge case: scene transitions

When the player changes scenes, the MusicDirector either: a) Persists as an autoload. New scenes call MusicDirector.set_state() to take over. b) Per-scene, fades out the previous before the scene changes (set_state(CALM) then crossfade to -60 dB on all then change scene). Persistent is preferred for open-world; per-scene for level-based games.

Reference card — bus map

Anti-patterns

  • Stems generated at different BPM/key. They will not crossfade cleanly. Same BPM, same key, same bar count.
  • Restarting tracks on state change. Players hear the restart. Always crossfade volumes; never play() mid-state.
  • No autoplay on the silent stems. They can’t fade in to phase if they never started.
  • Polling state in _process. Use signals. Music director listens to EventBus, not to game state every frame.
  • Hardcoding volumes in set_state. Use the table-driven _apply_state so adding a new state doesn’t fork the function.
  • Ducking music to silence on dialogue. The bible says -6 dB (so music drops from -8 to -14), not muted. Voice should sit on a present bed, not a dead one.
  • Boss music as a louder combat track. Distinct, named instrument; ideally different tempo or key. The bible’s Boss music is its own track rule.

Edge cases

  • Player triggers TENSION → COMBAT in 0.2s. The instant_states = [State.COMBAT] makes COMBAT snap so it lands on the swing connect. The intermediate fade is wrong — combat must feel immediate.
  • Player flees combat back to TENSION → CALM. Use the regular crossfade_seconds = 2.0; the de-escalation can breathe.
  • Multiple enemies aware → one dies → none aware. The state machine should hysteresis: only fall back to CALM after no_enemies_aware AND no_recent_damage_for=8s.
  • Audio service not ready on _ready. If AudioServer.get_bus_index("Music") returns -1, the bus layout failed to load. Verify default_bus_layout.tres.
  • Stems generated at 60s but you want a 5-minute combat. They loop. Crossfade is volume-only, not time-based, so loops are invisible to the director.

Fallback (no MCP)

Print the bus layout, node tree, and GDScript. The user constructs it manually in Summer Engine.

Handoff

MusicDirector wired. Calm / Tension / Combat play in sync, only one audible. State driven by EventBus. Music ducks -6 dB on dialogue. Next:
  • Run summer_play and trigger each transition; listen for sync issues.
  • If COMBAT lands on the wrong beat, the stems are off-tempo — regenerate via /music-track with identical BPM and bar count.
  • For boss-specific music, generate boss.mp3 with /music-track and the director picks it up automatically.

See also

  • audio-direction — defines the dynamic music plan and bus layout
  • music-track — generates the stems
  • voice-line — the voice bus that triggers ducking
  • summer_docs_read id reference/godot-version — Summer compatibility for AudioServer and Tween APIs

From a shell

No Summer MCP tools in this session? Run each one as a command; when summer --version is missing or below 4.0, use npx -y summer-engine@latest in place of summer. Fields are flags in kebab-case (--scene-path res://main.tscn) or one --input '<json>', and summer ops describe <op> prints the exact input. The summer-cli skill has the rest.
  • audio-direction: Define the game’s sound (music style, SFX vocabulary, dynamic music) as .summer/audio-bible.md.
  • music-track: Generate a music track: game loops of 30s or more with a loop point, or linear cinematic cues.

Source: library/skills/adaptive-music/SKILL.md, rendered from summer-engine@4.3.0 on npm.