Custom soundtracks, 2026-10-12

Supported original XBE SHA256:
B5207C40C11D7C5B5E129EF555F7632FA3584A4240BD0421C2B1B9AD9BFED7BF

Original code and storage contract

The original soundtrack directory at 002C8D3C and database path at 002C8D78 are
\Device\Harddisk0\Partition1\TDATA\FFFE0000\MUSIC\ and its ST.DB file.
The counted ANSI database name is at 002C8D70. Original XapiOpenStDbAndReadHeader
at 000E0B83 opens it with NtCreateFile and reads a 512-byte header through E0B45.

XFindFirstSoundtrack at E0C86, XFindNextSoundtrack at E0C67 and the helper E0BE9
read soundtrack records at (enumeration index + 1) * 512. Records have magic
00021371, ID at +4, song count at +8, group IDs at +12, duration at +348 and
UTF-16 name at +352. The original API copies 32 UTF-16 code units into its public
name field, so imported display names use at most 31 units plus termination.
The original game enumerates these APIs at C8D70 and caches that enumeration
using 0057C204. A fresh game session therefore applies catalogue changes.

XGetSoundtrackSongInfo at E0D35 indexes six-song groups and reads the group at
(group ID + 101) * 512. It validates magic 00031073 and the soundtrack ID.
Song IDs start at +16, durations at +40 and six UTF-16 names at +64, 64 bytes
per name. XOpenSoundtrackSong at E0F5E formats the original %s%04x\%08x.WMA
path, using song ID >> 16 for the folder and the full ID for the filename.
XFindClose at E17F6 closes the original catalogue enumeration.

The original XapiInitProcess creates its LocalAlloc heap at E609C and stores it
at 005A8974. The isolated diagnostic must initialize that heap as well as the
CRT heap at 005A619C; normal startup already does so. These are diagnostic setup
requirements, not replacement soundtrack APIs or game-code patches.

Implementation

Audio settings select a folder and import up to 500 files as one soundtrack.
The folder name supplies the collection name, and filenames supply song names.
Windows Media Foundation reads supported local formats and writes stereo 44.1
kHz WMA version 2, targeting about 128 kbps. Windows reports the relevant output
formats as 16002 or 16005 bytes/second, rather than exactly 16000. Treat both as
nominal 128 kbps and select the shortest encoded-block layout. The earlier
nearest-byte-rate selection chose the larger layout and caused an early stop
in the original decoder, as detailed below.

Import runs on a cancellable worker while gameplay is stopped. Files are streamed
in bounded PCM packets; complete songs are not held in memory. A completed
catalogue replaces the previous generated cache after all files succeed.
Cancellation leaves the previous library intact. Original music files are only
read. Cache ownership and resolved paths are checked before generated-directory
removal or replacement. Media Foundation is delay-loaded and needed only for
importing, not normal game startup or cached-song playback.

The native file provider mounts this private cache, read-only, at the original
soundtrack path when custom music is enabled. The original compiled SDK and game
perform discovery, menu construction, song selection and WMA playback. No menu
availability flag, invented callback, runtime decoder or CPU fallback is added.

References:
https://xboxdevwiki.net/Soundtracks
https://learn.microsoft.com/en-us/windows/win32/medfound/tutorial--decoding-audio
https://learn.microsoft.com/en-us/windows/win32/medfound/tutorial--using-the-sink-writer-to-encode-video
https://learn.microsoft.com/en-us/windows/win32/medfound/supported-media-formats-in-media-foundation

Native verification logs and generated fixtures are private under
build/checks/custom-music and build/checks/overnight-240/custom-music-*.

Validation

native-05/custom-music.json reports 114 passing checks with seven songs across
the six-song group boundary, Unicode metadata, cancelled replacement preserving
the existing catalogue, original soundtrack discovery/open/close and original
WMA decoding. Eight packets decoded 16384 stereo frames at 44100 Hz; measured
peak was 0.2020874 for a 0.2-amplitude source. No game boot or audio device was
needed for these checks. Release build custom-music-build-07 and hidden settings
check custom-music-window-01 passed, including the saved custom-music preferences.

Isolated live startup reached the Load/Save menu with custom music enabled and
no unexpected native boundary or audio error. It did not reach Music Selection.
The user requested manual checking, so in-game menu selection and listening
remain unverified. User saves and the existing settings file were unchanged.

Follow-up, 2026-10-12

The user confirmed imported music playback and Music Selection controls work.
A roughly 3.5-minute song restarts after roughly two minutes while remaining on
the same screen or driving. They also requested a volume audit against Burnout 1
music and reserved all future in-game checking for manual verification.

The original MP3 reports 210.200 seconds at stereo 48000 Hz. The imported WMA
reports 210.279 seconds at stereo 44100 Hz; the catalogue stores 210253 ms.
The cache therefore contains the whole song with a matching catalogue duration.
Whole-song verification uses the original decoder and optional read-only cache,
streaming packet statistics without retaining the entire decoded song in memory.

Root cause and correction

Windows reports two 44.1 kHz stereo formats at nominal 128 kbps: 16002 bytes/sec
with 5945-byte encoded blocks, and 16005 bytes/sec with 2973-byte blocks. The
first selection used the smaller bitrate error, picking the larger-block layout.
The original decoder stops that imported file at 96502 ms, despite 210253 ms
in the catalogue and 210279 ms in the ASF file. A bounded native debugger capture
shows its reader reaching the 128 KiB input-buffer boundary at file offset
0017FFFC. Original 24B50E clamps reads to that boundary; 24BDB9 supplies that
reader to the ASF/WMA code. The modern larger-block layout encounters a partial
read that the old reader/decoder cannot complete successfully.

Changing only the ASF media-object numbering in a private copy did not change
the stop. The unchanged original Burnout 1 file decodes past that point. Importing
the same source with the 2973-byte layout instead produces 9273344 decoded
stereo frames, or 210279 ms, through the same original decoder and file provider.
No game-code patch, replacement decoder, timer change or padded fake song is used.
The importer now groups the encoder's reported rates by nominal kbps and selects
the smallest block at 128 kbps, rather than comparing byte-rate rounding errors.
The existing local imported library was refreshed from its original source folder.

The complete-song diagnostic also retains PCM from a final E_FAIL packet. Original
24B44D writes both the produced size and E_FAIL when its reader reaches the end;
a final packet can therefore contain valid tail samples. A complete-duration
comparison still rejects a premature end. This changes diagnostic accounting,
not gameplay's original WMA methods. Cancellation is reported as untested (null)
when checking an existing read-only library instead of generated fixtures.

Volume audit

FFmpeg's streaming volumedetect measured the source MP3 at -9.7 dB mean and the
first imported WMA at -9.6 dB. The corrected layout's original-decoder RMS is
0.3308366 (about -9.6 dB). Import does not add gain or loudness normalization.
The original Burnout 1 track music1/b1wma/01.wma measures -16.6 dB mean: about
7 dB quieter in the recording itself. This comparison describes these two files,
not every built-in or user-selected song. Shared original volume/headroom
binding checks and native audio checks passed; the master gain remains shared.

Relevant Windows format and container documentation:
https://learn.microsoft.com/en-us/windows/win32/medfound/windowsmediaaudioencoder
https://learn.microsoft.com/en-us/windows/win32/medfound/asf-file-structure

Final verification

The rebuilt canonical b2.exe passes the updated 252-case catalogue/import fixture,
including Unicode, cancellation and complete final-packet accounting. The refreshed
user library decodes all 9273344 stereo frames (210279 ms) through the original
WMA methods. The known incompatible private copy still fails at 96502 ms, so
accepting the decoder's final E_FAIL packet does not hide the premature stop.
Native audio checks pass 70 cases; binding checks pass 74 cases, alongside
54 spatial cases and 1000 original calculations. No game was booted or audio
device opened during this follow-up. Existing settings remain byte-for-byte
unchanged. Manual in-game verification of the correction remains with the user.

Loop Track in Music Selection (2026-10-19)

The native Music Selection screen now has a third row, Loop Track, with Off/On
values. It defaults to Off and saves its confirmed value as loop_track in the
PC preferences. Original game saves are unchanged. The original menu's row
descriptor at screen+1F9C and selector table at screen+1F68 share the extended
three-row table. Hook 462DA installs it before the original view binds its rows.
Native navigation handles the new string-valued row. Hook 46510 commits after
the original soundtrack/song selections; Back leaves the setting unchanged.

Looping uses the original XACT playlist repeat flag (playlist+58, bit 2), with
one selected song in its queue. Original C91D0 builds that queue. The included
Burnout 1 filename table is indexed by the selected song at C91F7; C92D3 queues
one entry. Imported music's descriptor at C92F9 changes from original type 3
(soundtrack) to verified type 4 (one song), carrying the selected song ID and
index. Original 20DDB8 and 20DDBD create and advance both kinds of queue. Their
repeat handling wraps the single entry without replacing the decoder or mixer.
Loop mode skips C9333's initial song-index compensation and CA348's later index
increment so playback notifications retain the selected song. Off preserves
the original full playlist and song advancement. The game's normal Burnout 2
course music already loops and is unaffected by this selected-music path.

The supported original XBE hash was verified before inspecting these bounded
address ranges. The existing custom-music diagnostic now passes 1319 cases:
native menu navigation/confirmation/cancellation and first/middle/last songs
from the included and seven-song imported catalogues, with Loop Track on/off.
Forty further original queue advances per selection verify repeat/advancement.
No audio device or game window is needed for these checks. The rebuilt Release
also passes target verification, 155 audio bindings, 54 spatial cases and 1000
original calculations, 77 audio cases, 67 effects cases, all 12 included music
files, 52 CPU groups, and the offscreen settings persistence check.

Evidence: build/checks/loop-track-20261019/verified. Live menu layout and gameplay
verification are left to the user for their manual check.

Initial secondary placement and uninterrupted loop changes (2026-10-19)

The user confirmed looping works, requested the same toggle under Pause >
Options, and reported that confirming a loop change restarts the menu music.
The earlier implementation explicitly called C91D0 when confirming Loop Track.
That function stops playback and destroys/recreates the playlist. This is the
restart's cause. The single-song queue strategy above is superseded here.

Keep the complete original playlist and change only its natural EOF advance.
Original 2142D8 calls playlist Next (2106EF). That calls 210616, which closes
the completed decoder/file, advances the current entry and reopens it through
the original playback path. At 21066E, retaining the current link rather than
reading its next link repeats that entry. The hook checks the active title
playlist at 57C1F4 and the two verified caller return addresses, 21072C and
2142DD. Initial song selection at C9317, explicit Next at C6123 and other audio
playlists retain their original advancement. Changing the setting touches no
playlist, decoder or stream. The next EOF uses the new setting.

The original first-start index compensation at C9333 is restored. A repeated
EOF records that the following start notification repeats the current song;
CA348 consumes that fact instead of advancing its displayed index. A toggle
between EOF and notification therefore does not misidentify the playing song.

The screen initially mistaken for Pause Options uses the descriptor at screen+E8, with Music Volume
and SFX Volume at screen+108 and +120. Hook 4C5B4 appends the shared Loop Track
row before the view binds this descriptor. Native 45F40/45F60 provide its
left/right controls. Hook 4BAE0 copies the volume values back to their original
embedded fields before the original live-volume handler; it also saves a loop
change immediately, matching the pause menu's live adjustment behavior. Both
menus initialize their row from the same PC preference. New menu storage remains
one page for the session. Only bounded original address ranges were inspected.

Correction: this descriptor belongs to front-end Audio, not the race pause
Options menu. The user identified the wrong placement; it is removed below.
The two-row menu checks in this first validation exercised front-end Audio.

Release validation passed: 2055 custom-music cases, including native pause
navigation, shared setting persistence, preserved volume fields, first/middle/
last songs from both catalogues, 40 consecutive EOF advances, toggling in both
menus with the playlist/decoder handle unchanged, pending notification changes,
explicit Next and unrelated playlists. Existing target, audio, spatial/bindings,
effects, all 12 included songs, CPU and offscreen settings checks also passed.
Evidence is under build/checks/loop-track-pause-20261019/verified. The Release
executable was rebuilt; no game session or audio device was opened. The user
retains live layout and playback verification. Installation.zip was produced by
cmake/package.ps1 from the current build inputs; its 95-file payload was checked
against those sources, with private/generated files absent and HEAD/index intact.

Correct race pause Options location (2026-10-19)

User evidence: build/windows/Release/build/captures/frame-121493606200/frame.png,
captured 2026-10-19 at 13:57 local time, 1920x1440. It shows the race paused on
OPTIONS: Music Volume, Effects Volume, Soundtrack, Track and Vibration. This is
the requested location, distinct from front-end Audio. The new order places
Loop Track between Track and Vibration. The original Music Selection toggle
remains, sharing the same PC preference.

Original 47330 builds the race pause screen. Its descriptor is at screen+80,
with five 24-byte rows at screen+A0. The music selector at screen+208 binds to
that table with soundtrack/track rows 2/3. Hook 4788F runs after the original
row setup; it adds Loop Track at row 4 and moves Vibration to row 5 in external
storage. Descriptor+4 and selector+1F64 share the extended table. The original
screen allocation and embedded fields are preserved.

Pause initialization at 46DB0, its navigation at 47AE0 and generic row handlers
45F40/45F60 are retained. Verified embedded-row accesses at 46E84, 46EB6, 47C87,
47C8E, 47CB4 and 47CE5 now read the descriptor's table. The original fixed
five-row reset/cap at 46DDF, 46DFC and 46E04 uses the descriptor's count, so the
sixth row stays reachable and focused. Hook 46EDA refreshes volume/vibration
values and the loop preference before binding the Options view.

The original live-volume handler at 47190 receives synchronized embedded fields
B0/C8. Confirmation at 47220 also synchronizes Vibration at 110 and saves the
loop setting. A confirms and Start resumes through that same original commit;
B cancels, with an unconfirmed loop edit discarded on reopening. No playlist
rebuild is introduced. The prior 4C5B4/4BAE0 front-end Audio hooks are removed.
All addresses were checked against the same supported original XBE bytes.

The rebuilt Release passes 2071 custom-music cases. These now check the actual
race menu's six-row descriptor and music-selector binding, the captured row
labels/order, native navigation from Track to Loop Track to Vibration, the final
row boundary, confirmation/cancellation, volume and vibration synchronization,
and the absence of a third front-end Audio row. Existing looping/continuous
playback checks and target, spatial/audio bindings, audio, effects, twelve-song,
CPU and hidden settings checks pass. Evidence: build/checks/loop-track-location-
20261019/verified. No game or audio device was opened. Live verification remains
with the user.
