# Game Music That Switches States on the Beat

> Name your level's states and get exploration, combat and victory cues in one key and tempo, with loops cut to whole bars so your game switches on the beat.

---

## Messages to send, and what they made

### “Make the music for one level of my sci-fi roguelite: an exploration loop, a combat loop and a victory stinger, all in the same key and tempo so they can crossfade.”

- [Exploration loop · 16 bars](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/3b2b611b-936f-4dfe-a3e8-6472bc8706da/audio-generation-2026-09-25-201943.mp3)
- [Combat loop · 16 bars](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/866d754f-1b17-4aac-8e87-af33865645d5/audio-generation-2026-09-25-201943.mp3)
- [Victory stinger · 4 bars](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/a36399d2-b3d7-4105-be01-bc0dd5081b6f/audio-generation-2026-09-25-201943.mp3)

Exploration and combat share A minor and 120 BPM, and both loops run exactly 32 seconds, so your game can cut from one to the other on a bar line.

### “Create menu music, in-game music and a game-over sting for my casual puzzle game, all matching.”

- [Menu loop](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/ce17cfa0-65c2-4e25-b04e-88c529fec61d/menu_screen_background_music_for_a_casual_puzzle_game_instrumental-2026-09-25-204025.mp3)
- [In-game loop](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/fd3892d6-05ae-43fd-b36d-1ddbd78c7d2e/ingame_background_music_for_a_casual_puzzle_game_instrumental_use_the-2026-09-25-204025.mp3)
- [Game-over sting](https://media.app.layer.ai/workspaces/9602107e-865b-47e5-b66e-87b1bec5e3d5/files/186cdd16-cb89-4e96-a6bc-e72757f14ce3/gameover_musical_sting_for_a_casual_puzzle_game_instrumental_same-2026-09-25-204025.mp3)

The in-game loop keeps the menu's palette and adds motion, and the 4-second sting shares their C major and 120 BPM, so it can close either loop.

---

The exploration track is in D at 100 BPM and the combat track is in F sharp at 132, so every time a fight starts the music lurches. Cues written one at a time rarely share the ground a clean switch needs.

Tell Layer which states the level has, in the words your design doc already uses, like an exploration loop, a combat loop and a victory sting. It picks the key, the tempo and the palette for the set first and composes each cue on that ground, so you never retune or time-stretch a track to make it fit.

## Shared Ground, Settled Before the First Cue

Music that swaps cues on game state only works when every cue shares a tempo and a key. Nothing in a first cue reveals that a second one is coming, which is why tracks written separately clash at the join. Layer decides the shared ground once and holds it for every cue in the set, and the density and register carry the difference between calm and combat.

**Loops in whole bars**
Each loop is planned to the bar, so it wraps without a gap or a stumble.

**Stings with an ending**
A victory or game-over sting resolves the loop under it, in the same key and tempo.

## A Menu Bed Never Peaks

Each cue has its own job. A menu bed the player sits inside should hold steady, while the gameplay cue is allowed to climb. Combat can run shorter than exploration, because the player's attention is on the fight. The puzzle set above has a bright menu loop, an in-game loop with the same palette and more motion, and a gentle game-over sting.

## Wiring the Set

Download MP3 or WAV and wire the cues into your engine or audio middleware. Keep the tempo, the key and the state each cue belongs to with the files, so nobody has to rediscover the plan by ear. See [audio generation](/features/audio-generation) for more on music generation in Layer.

For cues timed to a scene, see [orchestral game music](/use-cases/orchestral-game-music). To score from your art, see [music from your game art](/use-cases/image-to-game-music).

## Frequently Asked Questions

### Why do the cues need to share a key and tempo?

So the switch lands. Two cues at different tempos cannot be crossfaded or cut on a beat, and two in unrelated keys clash for the whole crossfade. Layer fixes the key, the tempo and the palette for the set before the first cue is composed, because none of them can be added to a finished track.

### Will the loops repeat cleanly?

Yes. Each loop is planned in whole bars, so 16 bars of 4/4 at 120 BPM arrives at exactly 32 seconds and wraps on the bar line, as both loops in the sci-fi set do.

### Can I add a boss loop later?

Yes. Ask in the same session and Layer writes it to the key, tempo and palette the set already has. In a new session, name the key and tempo of the existing set in your message so the new cue lands on the same ground.

### Can I get intensity layers that play together?

Not from a set like this. These cues are written to switch between states, and playing two of them at once doubles the material. Layers that stack need true stems split from a single cue.

### How does a stinger fit over the loop?

It plays on top of whatever is running, so it is written short, in the loop's key and tempo, and with an ending. A victory sting that fades out has no moment, so Layer writes it to resolve the music the player was already hearing.

### What does my audio programmer need from the set?

The tempo, the key and which cue belongs to which state. Name them in your message and Layer holds every cue to them. Write them down with the set, because neither is reliably recoverable by ear later.

---

Create a free Layer account and name the states your level needs.

---

[View original](https://layer.ai/use-cases/adaptive-game-music) | [All Use Cases](https://layer.ai/use-cases)
