Skip to content

feat(audio): shuffle the soundtrack across gauntlet/contract runs + trim dead air - #42

Merged
prabu-openclaw merged 2 commits into
mainfrom
audio/shuffle-run-and-trim-silence
Jul 24, 2026
Merged

feat(audio): shuffle the soundtrack across gauntlet/contract runs + trim dead air#42
prabu-openclaw merged 2 commits into
mainfrom
audio/shuffle-run-and-trim-silence

Conversation

@prabu-openclaw

Copy link
Copy Markdown
Collaborator

Two related audio fixes for the replay modes.

1. Runs shuffle instead of looping one track

Gauntlet/Contract picked one random track and set numberOfLoops = -1 — so an entire run was that same song on repeat.

A run is now a shuffle: play a random pool track once, then hand off to a fresh random pick 1s before it ends, for as long as the run lasts. The next pick always excludes the current track, so nothing plays back to back.

  • playMissionMusic is idempotent — crossing a room boundary keeps the run going rather than restarting on a new song.
  • Menu loops, boss tracks, boss chains, and stop() all take over the shuffle.
  • Ducking (mini-games) defers through the existing deferredResumeKind, via a new .shuffleRun case.
  • A missing file retries up to 3 other picks rather than stranding the run in silence.

2. Trimmed trailing dead air (29 tracks)

Most tracks ended with 2–13s of sub -45dB tail. Harmless while a track looped, but under the shuffle each tail became an audible gap between songs.

Trimmed to the last non-silent moment with a stream copy (ffmpeg -c copy) — a container-level cut, no re-encode, no quality loss. 148s of dead air removed; longest cuts intro_m5_music (-12.8s), m2_a (-12.7s), drop_intro (-8.3s).

Validation

Ran a gauntlet floor in the iOS Simulator for ~90 minutes:

  • 35 handoffs across 25 distinct tracks, zero back-to-back repeats
  • Handoff pacing matches trimmed durations exactly (e.g. intro_m1(60) + intro_m5_5(114) + m6_b(204) + m5_5_coldtrace(180) + intro_m4_5(118) = 676s, observed 11:38→11:50)
  • Trimmed assets confirmed live in the build (m6_b reports 204s, not 210s)

Assets only + one Swift file; no files added/removed, so no XcodeGen regeneration needed.

🤖 Generated with Claude Code

Prabu and others added 2 commits July 22, 2026 13:22
…g one track

Replay modes picked one random track and looped it forever
(numberOfLoops = -1), so a whole run was the same song on repeat.

Now a run is a shuffle: play a random pool track once, then hand off to a
fresh random pick 1s before it ends, for as long as the run lasts. The next
pick always excludes the current track, so nothing plays back to back.

- shuffleRunActive/shuffleCurrentTrack track the run; playMissionMusic is
  idempotent so crossing a room boundary keeps the run going rather than
  restarting on a new song.
- Menu loops, boss tracks, boss chains and stop() all take over the shuffle.
- Ducking (mini-games) defers via the existing deferredResumeKind, with a
  new .shuffleRun case.
- A missing file retries up to 3 other picks rather than stranding the run
  in silence.

Verified in-simulator over a 90-minute gauntlet run: 35 handoffs across 25
distinct tracks, zero back-to-back repeats.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Most tracks ended with 2-13s of sub -45dB tail. Harmless when a track
looped, but with the run shuffle each tail became an audible gap between
songs.

Trimmed each track to its last non-silent moment with a stream copy
(ffmpeg -c copy), so this is a container-level cut with no re-encode and
no quality loss. 148s of dead air removed across 29 files; the longest
cuts were intro_m5_music (-12.8s), m2_a (-12.7s) and drop_intro (-8.3s).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@prabu-openclaw
prabu-openclaw merged commit 28a47b2 into main Jul 24, 2026
7 checks passed
@prabu-openclaw
prabu-openclaw deleted the audio/shuffle-run-and-trim-silence branch July 24, 2026 01:29
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