Make active sync use chirp-bin decoder

This commit is contained in:
Meta Vens 2026-05-23 19:22:25 +01:00
commit 67c7627446
11 changed files with 311 additions and 164 deletions

View file

@ -52,11 +52,7 @@ timing evidence Mimir is allowed to emit:
buffer.
- `hybrid`: prefer passive program-audio evidence when confidence is high, then
emit a watermark when confidence falls. The passive side uses bounded
GCC-PHAT-style phase correlation. The active fallback now uses
`MimirChirpBinTimeline`: a fixed-slope chirp-bin watermark whose symbols are
decoded by one dechirp and a fixed Goertzel bin bank instead of dense sliding
matched filters. Hybrid emission is pulsed, not continuous: when passive
confidence is weak, Mimir emits one half-second coded burst every two seconds.
GCC-PHAT-style phase correlation.
The mode belongs to the runtime, not the decoder. The decoder should consume
known timing evidence; it should not decide whether Mimir is allowed to make
@ -71,14 +67,19 @@ evidence and carry zero confidence. A single passive window is also capped below
certainty; full confidence belongs to repeated coherent state over time, not
one attractive correlation peak.
The active watermark path is deliberately receiver-cheap. `MimirChirpBinTimeline`
uses a common chirp duration, chirp slope, and Hann window for every symbol.
Symbol identity is the dechirped frequency bin. The synthetic invariant is
The active calibration path is deliberately receiver-cheap in both `chirp-only`
and `hybrid`. `MimirChirpBinTimeline` uses a common chirp duration, chirp slope,
and window for every symbol. Acquisition is a cheap bounded energy/onset pass;
classification is dechirp plus a fixed Goertzel bin bank; timeline placement is
the de Bruijn triplet trellis. A constrained local waveform correlation around
the decoded anchor delay provides the final fractional offset. The synthetic invariant is
`dotnet run --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --chirp-bin-self-test`;
it renders the chirp-bin timeline, decodes by dechirp plus Goertzel bins, and
requires code-valid triplet anchors plus a stable source clock. Default hybrid
watermark gain is intentionally low (`watermarkGain`, or
`MIMIR_WATERMARK_GAIN`) and separate from the louder chirp-only lab gain.
requires code-valid triplet anchors plus a stable source clock. `chirp-only`
emits this witness continuously; `hybrid` emits one low-gain half-second coded
burst every two seconds only while passive confidence is weak. Default hybrid
watermark gain is intentionally low (`watermarkGain`, or `MIMIR_WATERMARK_GAIN`)
and separate from the louder chirp-only lab gain.
Research notes:
@ -236,10 +237,9 @@ timeline anchors. Current synthetic proof detects all 15 emitted chirps, keeps
device runs still depend on loopback capture staying live; the local Scarlett
loopback has intermittently stopped advancing during short headless sniffs.
The older `MimirChirpletTimeline` matcher is now the chirp-only lab path, not
the hybrid fallback. `BuildChirpletEnergyTrace` still behaves like a dense
sliding matched-filter bank and should not retake the hot path. The active
hybrid watermark belongs to the chirp-bin machine.
The older `MimirChirpletTimeline` matcher is a diagnostic/reference artifact,
not the active runtime path. `BuildChirpletEnergyTrace` still behaves like a
dense sliding matched-filter bank and should not retake authority.
Next, replace the diagnostic bridge with native audio capture workers that
append typed blocks into `Mimir.Runtime`, then expose buffer depth, clock state,

View file

@ -85,33 +85,31 @@ a named invariant that the native runtime cannot protect yet.
- `MimirRuntime` queues chirplet timeline PCM through Fensalir audio when the
active timing witness is allowed. `MimirAudioSynchronizationSettings.Mode`
selects `chirp-only`, `passive`, or `hybrid`; passive disables active
emission, and hybrid emits the active pilot only while passive confidence is
below threshold.
emission, chirp-only emits the active witness continuously, and hybrid emits
the active pilot only while passive confidence is below threshold.
- `MimirPassiveAudioSynchronizationEstimator` is the first program-audio timing
path. It estimates loopback-to-mic delay with PHAT-weighted cross-spectrum
correlation so music can act as the default timing witness before any audible
watermark is needed.
- `MimirChirpBinTimeline` is the active hybrid watermark path. It renders a
fixed-slope chirp-bin codebook and decodes symbols with one dechirp plus
fixed Goertzel bins, then feeds the same de Bruijn triplet timeline-anchor
machine. The detector scores dechirped bin energy directly, caches chirp
kernels per sample rate, and uses a widened 32-symbol codebook so sub-frame
timing error does not masquerade as neighboring symbol identity. The matched
chirp-bin peak is refined below one sample and reports/states expose delay in
microseconds as well as fractional samples. Hybrid emits this as low-gain
half-second bursts every two seconds only while passive confidence is weak.
- `MimirChirpBinTimeline` is the active calibration path for both `chirp-only`
and `hybrid`. It renders a fixed-slope chirp-bin codebook and decodes symbols
with cheap event-energy proposals, dechirp plus fixed Goertzel bins, and the
same de Bruijn triplet timeline-anchor machine. The detector keeps
time/frequency ambiguity as candidate symbol/offset pairs so code constraints
can choose the coherent path. The analyzer refines the final fractional delay
with constrained local waveform correlation around the decoded active delay.
Reports/states expose delay in microseconds as well as fractional samples.
Hybrid emits this as low-gain half-second bursts every two seconds only while
passive confidence is weak.
Use `--chirp-bin-self-test` to prove the codebook/decoder and
`--hybrid-sync-self-test` to prove that the analyzer can recover a fractional
delay from a one-second rolling-buffer chirp-bin window. The current synthetic
microsecond proof recovers a 317.375-sample delay with 0.369 us error.
- `Mimir.BufferSmoke --render-chirplet-f32` and `--analyze-asio-f32` provide the
current chirp-only Scarlett artifact proof. A 192 kHz run decoded Focusrite
`Loopback 1 -> Loopback 2` at `0.000 us` with 7 matched anchors and 0.896
confidence. Physical input 2 decoded at about 616.226 samples / 3209.508 us
with 3 matched anchors and 0.516 confidence; physical input 1 did not decode
in that capture. This proves the timing evidence can survive the real ASIO
path, but the matched-kernel chirplet decoder took roughly 100 seconds for one
2-second 192 kHz comparison and is not the runtime hot path.
- `Mimir.BufferSmoke --render-chirp-bin-f32` and `--analyze-asio-f32` provide
the current active Scarlett artifact proof. A 192 kHz chirp-bin run decoded
Focusrite `Loopback 1 -> Loopback 2` at `0.000 us` with 12 matched anchors and
0.999 confidence. Physical inputs did not produce matched anchors in that run,
so acoustic robustness remains separate from the clean loopback timing proof.
- `MimirVideoFrameDescriptor` for dimensions, pixel format, stride, device
timestamp, and native/GPU handle metadata.
- `IMimirVideoCaptureDriver` and `MimirVideoCaptureDriverSource` as the live
@ -147,8 +145,8 @@ a named invariant that the native runtime cannot protect yet.
workers for local mic, loopback, and network audio feeds. Use the verified
Focusrite ASIO path for Scarlett capture; WASAPI remains a diagnostic
witness, not the Scarlett hot path.
4. Replace the diagnostic chirp-only matched-kernel decoder with the efficient
streaming transform before using chirp-only at 192 kHz in the hot path.
4. Prove the active chirp-bin path through real microphones, not only Scarlett
loopback; tune acoustic bands/gain/code spacing from measured mic response.
5. Add the synchronization actuator: drive a variable-rate resampler and
fractional delay line per non-reference stream from the smoothed
`MimirAudioSynchronizationState`. First, prove the constrained chirplet