Audio: fix POISONED calibration rate (raw-offset garbage) + calibrated audio clock (task #50)

Two real bugs found + fixed chasing the footstep volume:

1. BTL4Application::MakeAudioRenderer read sample_rate from a raw 1995-layout
   offset (divisionParameters+0x10) -- the databinding trap: it yielded
   -1.6e14 (measured), poisoning Renderer::calibrationRate for the ENTIRE
   audio system.  Every AudioTime conversion (sequence event scheduling,
   compression curve durations, Seconds_To_Frames) was garbage.  Sanity-clamp
   to the authored 1000 frames/sec default (BT_AUDIO_LOG logs the value).

2. AudioHead::Execute fed audioFrameCount raw OS ticks; now converts
   ticks -> calibrated frames via SystemClock::GetTicksPerSecond (1000ms
   fallback when the static isn't measured yet), so AudioTime consumers see
   the rate they were calibrated for.  With rate=1000 + ms ticks the units
   now align end-to-end.

Footstep status: chain verified through pulse -> matcher -> Start -> renderer;
the volume mixer's two inputs receive only value-0 AudioControlSequence events
even with correct timing -- the authored event VALUES need decoding next
(sequence tempo/divisions ctor dump; possibly Verify()-stripped tempo garbage
or the events are resets and the true volume rides another control id).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-16 00:31:55 -05:00
co-authored by Claude Opus 4.8
parent 99757a947d
commit f4b2a7f87f
2 changed files with 26 additions and 1 deletions
+11
View File
@@ -290,6 +290,17 @@ BTL4Application::SharedData
divisionParameters
? (RendererRate)*reinterpret_cast<float*>(divisionParameters + 0x10)
: (RendererRate)1000.0f;
// DATABINDING GUARD (task #50): divisionParameters is a raw engine block
// pointer and +0x10 is a 1995-layout offset; on the port it read GARBAGE
// (-1.6e14 measured), poisoning calibrationRate -> every AudioTime
// conversion (sequence event scheduling, compression durations) broke,
// which is why AudioControlSequence timeline events (footstep volumes!)
// never landed. Sanity-clamp to the authored 1000 frames/sec default.
if (!(sample_rate > 0.0f && sample_rate <= 100000.0f))
sample_rate = (RendererRate)1000.0f;
if (getenv("BT_AUDIO_LOG"))
DEBUG_STREAM << "[audio] renderer sample_rate=" << sample_rate
<< " (divisionParameters=" << (void*)divisionParameters << ")" << "\n" << std::flush;
return
new BTL4AudioRenderer(