Correct complex contour confidence scoring
This commit is contained in:
parent
9567df5732
commit
82b9b2ea0d
5 changed files with 62 additions and 23 deletions
|
|
@ -20,9 +20,9 @@ Reference channel is `asio-ch2` / Loopback 1.
|
|||
|
||||
| Candidate | Meaning | Prediction | Estimate | Prediction Error | Confidence | Direct Hits | Cluster MAE | Phase MAE |
|
||||
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
||||
| `asio-ch3` | Loopback 2 | `0.000000` samples | `-0.002628` samples | `-0.014 us` | `0.126` | `216` | `0.008405` samples | `0.001 rad` |
|
||||
| `asio-ch1` | shotgun/co-streamer mic path | `544.244999` samples | `543.480112` samples | `-3.984 us` | `0.002` | `14` | `3.335599` samples | `0.858 rad` |
|
||||
| `asio-ch0` | cardioid/local mic path | `781.490952` samples | `781.787929` samples | `+1.547 us` | `0.011` | `23` | `2.949737` samples | `0.382 rad` |
|
||||
| `asio-ch3` | Loopback 2 | `0.000000` samples | `-0.002628` samples | `-0.014 us` | `0.971` | `216` | `0.008405` samples | `0.001 rad` |
|
||||
| `asio-ch1` | shotgun/co-streamer mic path | `544.244999` samples | `543.480112` samples | `-3.984 us` | `0.335` | `14` | `3.335599` samples | `0.858 rad` |
|
||||
| `asio-ch0` | cardioid/local mic path | `781.490952` samples | `781.787929` samples | `+1.547 us` | `0.488` | `23` | `2.949737` samples | `0.382 rad` |
|
||||
|
||||
## Interpretation
|
||||
|
||||
|
|
@ -32,9 +32,15 @@ live DAC/speaker/room/mic/ADC path: both physical mics land within four
|
|||
microseconds of their prior path seeds in this run, and the cardioid is within
|
||||
about one and a half microseconds.
|
||||
|
||||
This is not a final microsecond sync claim because the physical mic confidence
|
||||
is still low and the estimates are judged against previous path seeds rather
|
||||
than an independently measured ground-truth distance. It is, however, the first
|
||||
fresh meatspace proof that the complex contour/channel-model path can hear the
|
||||
current witness and return usable direct-path timing instead of only replaying
|
||||
old artifacts.
|
||||
This is not a final microsecond sync claim because the estimates are judged
|
||||
against previous path seeds rather than an independently measured ground-truth
|
||||
distance. It is, however, the first fresh meatspace proof that the complex
|
||||
contour/channel-model path can hear the current witness and return usable
|
||||
direct-path timing instead of only replaying old artifacts.
|
||||
|
||||
The first receipt pass reported much lower confidence because the tracker
|
||||
normalized the direct cluster against every alternate matched-filter lobe. The
|
||||
corrected scorer treats alternate lobes as ambiguity evidence while making
|
||||
direct-hit count, residual tightness, phase coherence, and prediction agreement
|
||||
the primary confidence owners. That raised loopback confidence from `0.126` to
|
||||
`0.971` without changing the measured delay.
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@ all four 192 kHz inputs, and analyzed the capture with the current complex
|
|||
contour channel model. Loopback 1 to Loopback 2 measured `-0.014 us`, proving
|
||||
the interface clock path is effectively sample-locked. Physical mic paths
|
||||
survived the room: the shotgun path landed `-3.984 us` from its prior seed and
|
||||
the cardioid landed `+1.547 us`. Confidence is still too low for a final
|
||||
microsecond sync claim, but this is fresh meatspace evidence through the actual
|
||||
DAC/speaker/room/mic/ADC path.
|
||||
the cardioid landed `+1.547 us`. After correcting the direct-path confidence
|
||||
scorer, loopback confidence is `0.971`, cardioid confidence is `0.488`, and the
|
||||
weaker/disconnected-looking path is `0.335`. This is fresh meatspace evidence
|
||||
through the actual DAC/speaker/room/mic/ADC path, though final microsecond sync
|
||||
still needs independently measured path truth instead of comparison to prior
|
||||
seeds.
|
||||
|
|
|
|||
|
|
@ -418,13 +418,6 @@ public sealed class MimirDirectPathTracker(
|
|||
? 0.0
|
||||
: bandObservations.Sum(observation => Math.Abs(observation.PhaseResidualRadians) * Math.Max(observation.Weight, 1.0e-9)) /
|
||||
Math.Max(1.0e-9, bandObservations.Sum(observation => Math.Max(observation.Weight, 1.0e-9)));
|
||||
var confidence = Math.Clamp(
|
||||
direct.Weight / Math.Max(1.0e-9, clusters.Sum(cluster => cluster.Weight)) *
|
||||
Math.Clamp(direct.Count / 16.0, 0.0, 1.0) *
|
||||
(1.0 / (1.0 + mae / Math.Max(1.0, sampleRate * 0.00005))) *
|
||||
(1.0 / (1.0 + meanAbsolutePhaseError / 0.75)),
|
||||
0.0,
|
||||
1.0);
|
||||
var reflectionTaps = clusters
|
||||
.Where(cluster => cluster.Delay > direct.Delay + options.DirectClusterRadiusSamples)
|
||||
.Select(cluster => new MimirAcousticReflectionTap(
|
||||
|
|
@ -435,6 +428,12 @@ public sealed class MimirDirectPathTracker(
|
|||
.OrderBy(tap => tap.RelativeDelaySamples)
|
||||
.Take(6)
|
||||
.ToArray();
|
||||
var confidence = ScoreDirectPathConfidence(
|
||||
direct,
|
||||
clusters,
|
||||
mae,
|
||||
meanAbsolutePhaseError,
|
||||
predictedDelaySamples);
|
||||
return new MimirDirectPathEstimate(
|
||||
updatedDelay,
|
||||
updatedDelay * 1_000_000.0 / sampleRate,
|
||||
|
|
@ -446,6 +445,34 @@ public sealed class MimirDirectPathTracker(
|
|||
reflectionTaps);
|
||||
}
|
||||
|
||||
private double ScoreDirectPathConfidence(
|
||||
MimirDelayCluster direct,
|
||||
IReadOnlyList<MimirDelayCluster> clusters,
|
||||
double meanAbsoluteErrorSamples,
|
||||
double meanAbsolutePhaseErrorRadians,
|
||||
double? predictedDelaySamples)
|
||||
{
|
||||
var hitConfidence = Math.Clamp(direct.Count / 24.0, 0.0, 1.0);
|
||||
var residualConfidence = 1.0 / (1.0 + meanAbsoluteErrorSamples / Math.Max(0.25, sampleRate * 0.000006));
|
||||
var phaseConfidence = 1.0 / (1.0 + meanAbsolutePhaseErrorRadians / 0.35);
|
||||
var predictionConfidence = predictedDelaySamples == null
|
||||
? 0.75
|
||||
: 1.0 / (1.0 + Math.Abs(direct.Delay - predictedDelaySamples.Value) / Math.Max(0.5, options.DirectClusterRadiusSamples));
|
||||
var coreConfidence =
|
||||
0.30 * hitConfidence +
|
||||
0.30 * residualConfidence +
|
||||
0.25 * phaseConfidence +
|
||||
0.15 * predictionConfidence;
|
||||
var nearCompetitorWeight = clusters
|
||||
.Where(cluster => !ReferenceEquals(cluster, direct))
|
||||
.Where(cluster => Math.Abs(cluster.Delay - direct.Delay) <= options.DirectClusterRadiusSamples * 3.0)
|
||||
.Sum(cluster => cluster.Weight);
|
||||
var ambiguity = nearCompetitorWeight <= 0.0
|
||||
? 1.0
|
||||
: direct.Weight / Math.Max(1.0e-9, direct.Weight + nearCompetitorWeight);
|
||||
return Math.Clamp(coreConfidence * (0.70 + 0.30 * ambiguity), 0.0, 1.0);
|
||||
}
|
||||
|
||||
private MimirDelayCluster[] ClusterDelays(IReadOnlyList<MimirDirectPathObservation> observations)
|
||||
{
|
||||
var sorted = observations.OrderBy(observation => observation.Delay).ToArray();
|
||||
|
|
|
|||
|
|
@ -107,3 +107,4 @@
|
|||
{"ts": "2026-05-25T03:40:00+01:00", "type": "implementation", "status": "partial", "note": "Built explicit complex contour channel learning and evaluation. `--learn-complex-contour-channel-model` learns path-scoped per-band delay/phase correction and reflection taps from `calibration/bioacoustic/complex-contour-replay-panel.json`, writing `calibration/bioacoustic/complex-contour-channel-model.json`. `MimirDirectPathTracker` now applies supplied channel-model phase/group-delay correction and downweights bands outside the usable learned surface. `--evaluate-complex-contour-channel-model` writes `calibration/bioacoustic/complex-contour-channel-model-evaluation.json`: current model improves 3/4 absolute path-seed errors, mean absolute path error by 2.137 us, and mean cluster MAE by 0.713 samples; fresh cardioid reaches 0.202 us from seed, but stored cardioid worsens from 15.817 us to 17.476 us. Treat the model as explicit calibration evidence, not default runtime authority, until more captures prove stability."}
|
||||
{"ts": "2026-05-25T04:25:00+01:00", "type": "implementation", "status": "partial", "note": "Moved the complex contour receiver from artifact-only replay into runtime shape. `MimirComplexContourRuntimeAnalyzer` reads Float32 samples from `MimirRollingStreamBuffer`, maps runtime time into the configured bioacoustic witness profile, runs the complex contour matched-filter/direct-path tracker, applies path-scoped `MimirComplexContourChannelModelDocument` corrections, and emits `evidence=complex-contour` synchronization reports. `MimirRuntime` now emits `MimirBioacousticContestantRenderer` audio when `enableComplexContourRuntime` is true, so the live sound and contour decoder share one song profile. Synthetic proof: `--complex-contour-runtime-self-test` at 192 kHz recovers a 693.5-sample delay with 0.219 us error from runtime-shaped rolling buffers. Real Scarlett loopback/mic proof remains the next gate."}
|
||||
{"ts": "2026-05-25T06:37:00+01:00", "type": "verification", "status": "partial", "note": "Ran a fresh live Scarlett complex-contour pass through the physical output/input path. Rendered `artifacts/asio/canary-packet-live-20260525-063229-f32.raw`, played it through Focusrite ASIO at 192 kHz, and captured `artifacts/asio/scarlett-canary-packet-live-20260525-063229-f32.raw` from all four inputs. Loopback 1 -> Loopback 2 measured -0.014 us with 216 direct hits and 0.008 sample MAE. With `calibration/bioacoustic/complex-contour-channel-model.json` loaded, shotgun measured -3.984 us from prior seed and cardioid measured +1.547 us from prior seed. This proves fresh meatspace viability, but physical mic confidence remains low; next work is stronger direct-path confidence and independent distance/path truth. Receipt: `calibration/bioacoustic/complex-contour-live-20260525-063229.md`."}
|
||||
{"ts": "2026-05-25T06:50:00+01:00", "type": "implementation", "status": "ok", "note": "Corrected `MimirDirectPathTracker` confidence scoring. The old score normalized direct-cluster confidence against all alternate matched-filter lobes, which made a nearly perfect loopback lock report only 0.126 confidence. Confidence now primarily belongs to the selected direct cluster: direct-hit count, residual tightness, phase coherence, and prediction agreement; nearby competing lobes apply only an ambiguity penalty. Reanalysis of `scarlett-canary-packet-live-20260525-063229-f32.raw` leaves delays unchanged but raises Loopback 1 -> Loopback 2 confidence to 0.971, cardioid confidence to 0.488, and the weaker/disconnected-looking channel to 0.335."}
|
||||
|
|
|
|||
|
|
@ -250,10 +250,12 @@ accepted_design:
|
|||
`calibration/bioacoustic/complex-contour-live-20260525-063229.md`:
|
||||
Focusrite ASIO playback/capture measured Loopback 1 -> Loopback 2 at
|
||||
-0.014 us, shotgun at -3.984 us from prior seed, and cardioid at +1.547 us
|
||||
from prior seed with the current channel model. This is fresh meatspace
|
||||
evidence through DAC/speaker/room/mic/ADC, but physical confidence remains
|
||||
low, so the next cut is stronger direct-path confidence and independent
|
||||
path truth.
|
||||
from prior seed with the current channel model. The direct-path confidence
|
||||
scorer now belongs to selected-cluster quality rather than all alternate
|
||||
matched-filter lobes: loopback confidence is 0.971, cardioid confidence is
|
||||
0.488, and the weaker/disconnected-looking path is 0.335. This is fresh
|
||||
meatspace evidence through DAC/speaker/room/mic/ADC, but the next cut is
|
||||
independent path truth and better frequency/direct-path discrimination.
|
||||
`calibration/bioacoustic/complex-contour-replay-panel.json` persists the
|
||||
current four-case replay receipt.
|
||||
Acoustic robustness remains open.
|
||||
|
|
|
|||
Loading…
Reference in a new issue