Audio: footsteps arrive on the FIRST stride -- the 10-20 s warm-up bug
User report: footfalls silent for the first 10-20 s of every mission (all
mechs), then solid. Root cause was three interlocking layers, each measured
with timestamped traces:
1. The authored footstep volume chain (LocalAcceleration [0,10]->ctl100 +
LocalVelocity [0,0.6]->ctl101 through authored N=30/N=15
AudioControlSmoothers, fill 0) hangs off the SOURCE's watcher chain
(scale watches smoother watches mixer watches source), and an idle
source's chain executes only at Start attempts -- one smoother sample
per stride.
2. Each hop is frame-gated (AudioComponent::ExecuteWatchers,
DefaultAudioFrameDelay), so any burst collapses to one execution.
3. The transient drop gate (vol < 0.3, AUDREND) rejected every Start while
the smoother average crawled up 1/30th per attempt -> ~25 dropped strides
before the first audible step, then per-frame execution while playing
kept it warm forever ("solid after that").
Fixes (engine-level, each documented in place):
- AudioScaleOf<T>::Execute now sends EVERY poll (scales are continuous
value-feeders; the base bitwise change-gate -- Motion::operator== is
memcmp -- froze on our deterministic gait math, where the original's
noisy physics floats never bit-repeated. Triggers/matchers keep the
change gate: their semantics are edge-based).
- Component/AudioComponent::PrimeWatchers(passes): recursive, GATE-FREE
watcher pump; AUDREND runs 30 passes on every transient Start request so
the authored smoothers evaluate at their true steady state before the
drop gate reads the volume.
- localAcceleration derives via the binary's exact structure: 15-sample
ring buffers of the raw position derivative + dt (ctor part_012.c:9836,
derive :15169-15195), in the PerformAndWatch tail so it runs every frame.
- AttributeWatcherOf::GrabCurrentValue private -> protected (the scale
override calls it).
Verified (30 s walk from cold start): drops 25 -> 3 (the survivors are
authentic quiet-stride gating: first gentle strides at vol ~0.28 vs the 0.3
gate), footfalls deliver from the first stride, 43 delivered with live
per-stride gain variation. Diag traces added: [accwatch]/[fsscale]/
[smooth]/[smoothcfg]/[motionscalecfg] + timestamps on DROP/volset.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
a8f14e1c24
commit
a11a697824
@@ -3692,23 +3692,26 @@ void
|
||||
// velocity the same way; this filter reconstructs that stage.
|
||||
{
|
||||
Scalar alpha = dt / (dt + 0.25f);
|
||||
Scalar fwdPrev = fwdSpeedFiltered;
|
||||
Scalar vertPrev = vertSpeedFiltered;
|
||||
fwdSpeedFiltered += alpha * (fwdSpeed - fwdSpeedFiltered);
|
||||
vertSpeedFiltered += alpha * (worldLinearVelocity.y - vertSpeedFiltered);
|
||||
// (AUDIO_FIDELITY F19) publish localAcceleration EXACTLY as the
|
||||
// binary does: the derivative of the (averaged) published
|
||||
// velocity (part_012.c:15186-15195 -- (avgVel - prev)/avgDt into
|
||||
// localAcceleration.linear). The AUTHORED footstep chain reads
|
||||
// |localAcceleration.linear| [0,10] -> mixer ctl100 (the
|
||||
// per-stride kick) on top of |localVelocity| [0,0.6] -> ctl101
|
||||
// (the 0.4 moving base); with this member never written the
|
||||
// kick input read 0 and step volume lost its dynamics.
|
||||
if (dt > 1.0e-4f)
|
||||
localAcceleration.linearMotion = Vector3D(
|
||||
0.0f,
|
||||
(vertSpeedFiltered - vertPrev) / dt,
|
||||
-((fwdSpeedFiltered - fwdPrev) / dt));
|
||||
// binary does: FIVE 15-sample RING BUFFERS hold the RAW velocity
|
||||
// components + dt (ctor part_012.c:9836-9840), and the accel is
|
||||
// the frame-to-frame derivative of the ring MEAN over the mean
|
||||
// dt (part_012.c:15169-15195). The ring mean keeps jittering
|
||||
// as samples rotate, so the accel ATTRIBUTE changes on every
|
||||
// watcher poll -- feeding the authored N=30 footstep smoother
|
||||
// continuously (ctl100 |accel| [0,10] -> the per-stride kick on
|
||||
// top of ctl101's 0.4 moving base). A first cut derived accel
|
||||
// from the 0.25s-filtered velocity: its derivative goes
|
||||
// epsilon-flat between strides, the watcher stopped firing, and
|
||||
// the smoother took 10-20 s to warm from its fill=0 (the
|
||||
// late-footsteps bug). NOTE: the RAW components feed only the
|
||||
// rings; the PUBLISHED velocity keeps the 0.25s filter (a [T3]
|
||||
// accommodation for our ground-snap ripple, see above).
|
||||
// (the ring push itself lives in the PerformAndWatch tail so it
|
||||
// provably runs EVERY frame -- this conditional path skips
|
||||
// frames in some gait states, which starved the accel watcher)
|
||||
}
|
||||
localVelocity.linearMotion = Vector3D(0.0f, vertSpeedFiltered, -fwdSpeedFiltered);
|
||||
localVelocity.angularMotion = Vector3D(0.0f, turn * authTurnRate, 0.0f);
|
||||
@@ -5303,6 +5306,46 @@ void
|
||||
}
|
||||
}
|
||||
|
||||
// (AUDIO_FIDELITY F19) the localAcceleration feed, EXACTLY the binary's
|
||||
// structure: 15-sample RING BUFFERS of the raw per-frame position
|
||||
// derivative + dt (ctor part_012.c:9836-9840, fill 0); accel = the
|
||||
// frame-to-frame derivative of the ring MEAN over the mean dt
|
||||
// (part_012.c:15169-15195). Runs HERE, right before the watcher poll,
|
||||
// so the accel attribute updates EVERY polled frame -- the ring mean's
|
||||
// rotation jitter keeps the change-gate open and the authored N=30
|
||||
// footstep smoother fed (fed per-stride only, it took 10-20 s to warm
|
||||
// from fill=0: the late-footsteps bug).
|
||||
{
|
||||
Scalar rdx = localOrigin.linearPosition.x - accelPrevPos.x;
|
||||
Scalar rdy = localOrigin.linearPosition.y - accelPrevPos.y;
|
||||
Scalar rdz = localOrigin.linearPosition.z - accelPrevPos.z;
|
||||
accelPrevPos = localOrigin.linearPosition;
|
||||
if (dt > 1.0e-4f)
|
||||
{
|
||||
velRingFwd[velRingCursor] = (Scalar)sqrtf(rdx * rdx + rdz * rdz) / dt;
|
||||
velRingVert[velRingCursor] = rdy / dt;
|
||||
velRingDt[velRingCursor] = dt;
|
||||
velRingCursor = (velRingCursor + 1) % 15;
|
||||
}
|
||||
Scalar fwdMean = 0.0f, vertMean = 0.0f, dtMean = 0.0f;
|
||||
for (int vr = 0; vr < 15; ++vr)
|
||||
{
|
||||
fwdMean += velRingFwd[vr];
|
||||
vertMean += velRingVert[vr];
|
||||
dtMean += velRingDt[vr];
|
||||
}
|
||||
fwdMean *= (1.0f / 15.0f);
|
||||
vertMean *= (1.0f / 15.0f);
|
||||
dtMean *= (1.0f / 15.0f);
|
||||
if (dtMean > 1.0e-4f) // binary: _DAT_004ab9d4 guard
|
||||
localAcceleration.linearMotion = Vector3D(
|
||||
0.0f,
|
||||
(vertMean - accelPrevVertMean) / dtMean,
|
||||
-((fwdMean - accelPrevFwdMean) / dtMean));
|
||||
accelPrevFwdMean = fwdMean;
|
||||
accelPrevVertMean = vertMean;
|
||||
}
|
||||
|
||||
// (AUDIO_FIDELITY F7) latch the incoming-missile report accumulated by
|
||||
// Missile::MoveAndCollide since our last frame, then re-arm. The authored
|
||||
// beeper matches incomingLock 1/0 and the tempo scale reads the range --
|
||||
@@ -5313,7 +5356,9 @@ void
|
||||
distanceToMissileNext = FLT_MAX;
|
||||
|
||||
if (getenv("BT_AUDIO_LOG")) { static int s_wd=0; if ((s_wd++ % 300)==0)
|
||||
DEBUG_STREAM << "[audio] mech watcher poll: delayed=" << (int)AreWatchersDelayed() << " audioWatchers=" << DebugAudioWatcherCount()
|
||||
DEBUG_STREAM << "[audio] mech watcher poll t=" << (GetTickCount() % 1000000)
|
||||
<< " n=" << s_wd
|
||||
<< " delayed=" << (int)AreWatchersDelayed() << " audioWatchers=" << DebugAudioWatcherCount()
|
||||
<< " simFlags=0x" << std::hex << (unsigned)simulationFlags << std::dec
|
||||
<< "\n" << std::flush; }
|
||||
if (!AreWatchersDelayed())
|
||||
|
||||
Reference in New Issue
Block a user