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>
341 lines
8.5 KiB
C++
341 lines
8.5 KiB
C++
#pragma once
|
|
#include <cstdlib>
|
|
|
|
#include "cmpnnt.h"
|
|
#include "slot.h"
|
|
#include "memstrm.h"
|
|
|
|
class PlugStream;
|
|
class Simulation;
|
|
class Entity;
|
|
|
|
//##########################################################################
|
|
//########################### AttributeWatcher #######################
|
|
//##########################################################################
|
|
|
|
class AttributeWatcher:
|
|
public Component
|
|
{
|
|
public:
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Destructor
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
~AttributeWatcher();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// DidAttributeChange
|
|
//
|
|
// Returns True if attribute has changed since the last time
|
|
// DidAttributeChange was called.
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
Logical
|
|
DidAttributeChange();
|
|
|
|
protected:
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Constructor
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
AttributeWatcher(
|
|
PlugStream *stream,
|
|
Entity *entity
|
|
);
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// SendNotificationOfChange
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
virtual void
|
|
SendNotificationOfChange();
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// BuildFromPage
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
static void
|
|
BuildFromPage(
|
|
PlugStream *stream,
|
|
NameList *name_list,
|
|
ClassID class_ID,
|
|
ObjectID object_ID
|
|
);
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Protected data
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
Simulation*
|
|
simulation;
|
|
void*
|
|
attributePointer;
|
|
Logical
|
|
attributeChanged;
|
|
Logical
|
|
sendNotificationOnChange;
|
|
};
|
|
|
|
//##########################################################################
|
|
//########################### AttributeWatcherOf #####################
|
|
//##########################################################################
|
|
|
|
template <class T> class AttributeWatcherOf:
|
|
public AttributeWatcher
|
|
{
|
|
public:
|
|
~AttributeWatcherOf();
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Accessors
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
T
|
|
GetCurrentValue()
|
|
{return currentValue;}
|
|
T*
|
|
GetCurrentPointer()
|
|
{return ¤tValue;}
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Execute
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
void
|
|
Execute();
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// PrimeWatcher
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
void
|
|
PrimeWatcher();
|
|
|
|
protected:
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Constructor
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
AttributeWatcherOf(
|
|
PlugStream *stream,
|
|
Entity *entity
|
|
);
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// BuildFromPage
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
static void
|
|
BuildFromPage(
|
|
PlugStream *stream,
|
|
NameList *name_list,
|
|
ClassID class_ID,
|
|
ObjectID object_ID
|
|
);
|
|
|
|
private:
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// InitializeCurrentValue
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
void
|
|
InitializeCurrentValue();
|
|
|
|
protected:
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// GrabCurrentValue -- protected (task #50): AudioScaleOf's per-poll
|
|
// Execute override calls it directly (see AUDWTHR.h).
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
void
|
|
GrabCurrentValue();
|
|
|
|
private:
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// DumpValue
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
virtual void
|
|
DumpValue(const T *attribute_ptr);
|
|
|
|
//
|
|
//-----------------------------------------------------------------------
|
|
// Private data
|
|
//-----------------------------------------------------------------------
|
|
//
|
|
T
|
|
currentValue;
|
|
#if DEBUG_LEVEL>0
|
|
Logical
|
|
dumpValue;
|
|
#endif
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~ AttributeWatcherOf templates ~~~~~~~~~~~~~~~~~~~~
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T>
|
|
AttributeWatcherOf<T>::~AttributeWatcherOf()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T>
|
|
AttributeWatcherOf<T>::AttributeWatcherOf(
|
|
PlugStream *stream,
|
|
Entity *entity
|
|
):
|
|
AttributeWatcher(stream, entity)
|
|
{
|
|
Check_Pointer(this);
|
|
|
|
Logical dump_value;
|
|
|
|
MemoryStream_Read(stream, &dump_value);
|
|
|
|
#if DEBUG_LEVEL>0
|
|
dumpValue = dump_value;
|
|
if (dumpValue)
|
|
{
|
|
Tell(
|
|
"AttributeWatcherOf<T>::AttributeWatcherOf - " <<
|
|
*(T*)attributePointer <<
|
|
"\n"
|
|
);
|
|
}
|
|
#endif
|
|
|
|
InitializeCurrentValue();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::BuildFromPage(
|
|
PlugStream *stream,
|
|
NameList *name_list,
|
|
ClassID class_ID,
|
|
ObjectID object_ID
|
|
)
|
|
{
|
|
Check(stream);
|
|
Check(name_list);
|
|
|
|
AttributeWatcher::BuildFromPage(stream, name_list, class_ID, object_ID);
|
|
|
|
//
|
|
// Store dump_value
|
|
//
|
|
MEM_STRM_WRITE_ENTRY(*stream, name_list, Logical, dump_value);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::PrimeWatcher()
|
|
{
|
|
Check(this);
|
|
#if DEBUG_LEVEL>0
|
|
if (dumpValue)
|
|
{
|
|
DumpValue((T*)attributePointer);
|
|
}
|
|
#endif
|
|
GrabCurrentValue();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::Execute()
|
|
{
|
|
Check(this);
|
|
|
|
Check_Pointer(attributePointer);
|
|
if (getenv("BT_AUDIO_SPATIAL")) { // poll-rate probe: total watcher polls + change events
|
|
static long s_polls=0; if ((++s_polls % 2000)==0)
|
|
DEBUG_STREAM << "[watchpoll] total polls=" << s_polls << "\n" << std::flush;
|
|
extern void *g_btFootStepAddr; // DIAG: uncapped tracer on THE footstep watcher
|
|
if ((void*)attributePointer == g_btFootStepAddr) {
|
|
static long s_fsp=0;
|
|
if ((++s_fsp % 120)==0 || !(currentValue == *(T*)attributePointer))
|
|
DEBUG_STREAM << "[fswatch] poll#" << s_fsp << " cur=" << (int)*(int*)¤tValue
|
|
<< " mem=" << *(int*)attributePointer << "\n" << std::flush;
|
|
}
|
|
extern void *g_btAccelAddr; // DIAG: poll-vs-change split on the accel attr
|
|
if ((void*)attributePointer == g_btAccelAddr) {
|
|
static long s_ap=0, s_ac=0;
|
|
int changed = !(currentValue == *(T*)attributePointer);
|
|
if (changed) ++s_ac;
|
|
if ((++s_ap % 120)==0 || (changed && (s_ac % 30)==0))
|
|
DEBUG_STREAM << "[accwatch] t=" << (GetTickCount() % 1000000)
|
|
<< " poll#" << s_ap << " changes=" << s_ac
|
|
<< " memY=" << ((float*)attributePointer)[1]
|
|
<< " curY=" << ((float*)¤tValue)[1] << "\n" << std::flush;
|
|
}
|
|
}
|
|
if (!(currentValue == *(T*)attributePointer))
|
|
{
|
|
if (getenv("BT_AUDIO_SPATIAL")) { static int s_chg=0; if (s_chg++<60)
|
|
DEBUG_STREAM << "[watchpoll] CHANGE attrPtr=" << (void*)attributePointer << "\n" << std::flush; }
|
|
#if DEBUG_LEVEL>0
|
|
if (dumpValue)
|
|
{
|
|
DumpValue((T*)attributePointer);
|
|
}
|
|
#endif
|
|
GrabCurrentValue();
|
|
}
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::InitializeCurrentValue()
|
|
{
|
|
Check_Pointer(attributePointer);
|
|
currentValue = *(T*)attributePointer;
|
|
Verify(currentValue == *(T*)attributePointer);
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::GrabCurrentValue()
|
|
{
|
|
InitializeCurrentValue();
|
|
attributeChanged = True;
|
|
if (sendNotificationOnChange)
|
|
{
|
|
SendNotificationOfChange();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#if DEBUG_LEVEL>0
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::DumpValue(const T *attribute_ptr)
|
|
#else
|
|
template <class T> void
|
|
AttributeWatcherOf<T>::DumpValue(const T*)
|
|
#endif
|
|
{
|
|
Check_Pointer(attribute_ptr);
|
|
Tell((void *)attribute_ptr << " = " << *attribute_ptr << "\n");
|
|
}
|