Godot 4's built-in audio bus system is powerful but low-level — it gives you volume, effects, and routing, not a concept of "game states" or crossfades. This tutorial builds that layer from scratch using a score exported from Mowjera, so you end up with a reusable AudioManager autoload that any of your future projects can reuse.
What you'll have at the end
A singleton (autoload) that exposes one function — transition_to(state_name) — and handles crossfading between an arbitrary number of looping music states, sample-accurately, with zero audible seams.
Step 1: Export a score for Godot
From any Mowjera score's detail page, click Get bundle. The ZIP includes a godot/ folder with Mowjera.gd and a stems/ folder with one WAV per track per state:
Mowjera_MyScore/
godot/
Mowjera.gd
stems/
Explore_melody.wav
Explore_bass.wav
Combat_melody.wav
Combat_bass.wav
...Step 2: Import audio with looping enabled
Godot doesn't loop WAV files by default. For each stem:
- Select the file in the FileSystem dock.
- Open the Import tab.
- Under Loop Mode, set it to Forward.
- Click Reimport.
Missing this step is the single most common reason a "looping" track has an audible click every time it repeats.
Step 3: Add the autoload
- Copy
godot/Mowjera.gdinto your project'sscripts/folder. - Go to Project → Project Settings → Autoload.
- Add the script, name it
AudioManager.
Step 4: Call transitions from gameplay code
func _on_enemy_spotted():
AudioManager.transition_to("Combat")
func _on_area_cleared():
AudioManager.transition_to("Explore")
func _on_boss_defeated():
AudioManager.transition_to("Victory")The autoload handles fading the previous state's AudioStreamPlayer nodes out and the new state's nodes in, timed to the next bar boundary at your score's BPM — the same crossfade logic Mowjera previews live in the browser editor.
Common Godot-specific gotchas
- AudioStreamPlayer vs AudioStreamPlayer2D/3D: for non-positional game music, use the plain
AudioStreamPlayernode, not the 2D/3D variants — those attenuate by distance, which you don't want for background music. - Bus routing: route all music players to a dedicated "Music" bus (not "Master") so players can control music/SFX volume independently in your settings menu.
- Export templates: WAV files can bloat your exported game size. For a shipping build, consider re-exporting stems as Ogg Vorbis at quality 0.7 — Godot's importer handles the conversion, and looping still works correctly.
Testing the crossfade
Play your scene, trigger a state change, and listen on headphones. If you hear a "double" of the melody for a fraction of a second before the old state fades fully out, that's expected — it's the crossfade working. If you hear a hard cut or a click, check that both states' stems share the exact same BPM and loop length (Mowjera guarantees this automatically; hand-edited stems don't).
Browse adaptive scores on the Mowjera marketplace — every one ships with a Godot bundle ready for this exact workflow.