diff --git a/docs/audio-field.md b/docs/audio-field.md index 78fd473..c4f9fb2 100644 --- a/docs/audio-field.md +++ b/docs/audio-field.md @@ -155,8 +155,13 @@ computed dual-mic composite WAV with `--asio-dual-mic-composite-wav`, then muxes that WAV with the Kiyo video. The 2026-06-01 receipt at `artifacts/runtime/kiyo-dual-mic-composite/kiyo-dual-mic-composite-latest.mp4` contains 10.000 s of 640x480 30 fps Kiyo video and 9.994 s of mono AAC from the -computed composite. Treat it as a bridge proof of audibility/sync, not the final -native live DSP path. +computed composite. After listening feedback, the bridge tightened its audition +defaults: measured-band gain is capped at `1.18x`, incoherent calibrated bands +are suppressed more aggressively, and an optional residual envelope expander +demotes the low-level post-sum noise bed. Reprocessing the same raw ASIO/Kiyo +receipt lowered composite RMS from `0.046805` to `0.034400` while preserving the +same `-141.019` sample mic-delay estimate. Treat it as a bridge proof of +audibility/sync and a denoise scorer, not the final native live DSP path. The synthetic invariant is `dotnet run --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --bioacoustic-self-test`; it renders the bioacoustic timeline, decodes direct word anchors, and requires a diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index 979e21a..ba84d06 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -817,7 +817,10 @@ a named invariant that the native runtime cannot protect yet. shared tones. `scripts/record-kiyo-dual-mic-composite.ps1` is the first listenable bridge: it records Kiyo video plus Scarlett ASIO raw channels, renders the channels 0/1 composite WAV with `--asio-dual-mic-composite-wav`, - and muxes the computed mono composite into the Kiyo MP4. Treat that as the + and muxes the computed mono composite into the Kiyo MP4. The bridge defaults + now cap measured-band boost at 1.18x, apply stronger incoherent-band + suppression, and enable a residual envelope expander so low-level post-sum + noise does not ride along as loudly in audition receipts. Treat that as the contract and offline scorer for the native/Faust implementation, not as a parallel live mixer authority. The next matching probe loop also exists as diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 12c66b1..e6dd827 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -325,7 +325,13 @@ The 2026-06-01 receipt `artifacts/runtime/kiyo-dual-mic-composite/kiyo-dual-mic-composite-latest.mp4` has 10.000 s of 640x480 30 fps Kiyo video and 9.994 s of mono AAC composite audio; the composite report estimated channel-1 delay at about -141.019 samples -(-2937.889 us). +(-2937.889 us). After user listening feedback, the bridge tightened audition +defaults: measured-band boost is capped at 1.18x, incoherent calibrated bands +are suppressed harder, and a residual envelope expander demotes the low-level +post-sum bed. Reprocessing the same raw ASIO/Kiyo receipt lowered composite RMS +from 0.046805 to 0.034400 while preserving the same delay estimate. This is a +better listenable proof, not a claim that sparse-band C# has become the final +studio denoiser. `MimirTargetedBioacousticProbePlanner` is the matching "ask the room a better question" owner. It consumes per-source spectral residuals and optional source pathology notes, then emits gain-bounded shaped probe bands for the diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index 2930f79..45c3b81 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -3527,11 +3527,15 @@ static int RunAsioDualMicCompositeWave( MinimumConfidence: 0.05, TargetBandEnergy: MedianPositiveEnergy(shotgunResponses.Concat(cardioidResponses).Select(static response => response.Energy)), MinimumBandEnergy: 1.0e-8, - MinimumBandGain: 0.65, - MaximumBandGain: 1.60, + MinimumBandGain: 0.55, + MaximumBandGain: 1.18, NoiseFloorRms: 1.0e-5, - MinimumCoherence: 0.42, - IncoherentBandSuppression: 0.62)).Build( + MinimumCoherence: 0.48, + IncoherentBandSuppression: 0.78, + EnableResidualNoiseExpander: true, + ResidualNoiseFloorMultiplier: 2.8, + ResidualNoiseMinimumGain: 0.16, + ResidualNoiseExpansionPower: 2.4)).Build( [ NewCompositeSourceFromResponses("asio-ch0-shotgun", shotgun, sampleRate, delaySamples: 0.0, confidence: 0.90, shotgunResponses, NoiseEstimate(shotgun)), NewCompositeSourceFromResponses("asio-ch1-cardioid", cardioid, sampleRate, delaySamples: delay, confidence: 0.90, cardioidResponses, NoiseEstimate(cardioid)), diff --git a/src/Mimir.Runtime/Synchronization/MimirCalibratedAudioComposite.cs b/src/Mimir.Runtime/Synchronization/MimirCalibratedAudioComposite.cs index b230572..39b3967 100644 --- a/src/Mimir.Runtime/Synchronization/MimirCalibratedAudioComposite.cs +++ b/src/Mimir.Runtime/Synchronization/MimirCalibratedAudioComposite.cs @@ -8,7 +8,11 @@ public sealed record MimirCalibratedAudioCompositeOptions( double MaximumBandGain = 4.00, double NoiseFloorRms = 1.0e-5, double MinimumCoherence = 0.35, - double IncoherentBandSuppression = 0.72); + double IncoherentBandSuppression = 0.72, + bool EnableResidualNoiseExpander = false, + double ResidualNoiseFloorMultiplier = 3.0, + double ResidualNoiseMinimumGain = 0.22, + double ResidualNoiseExpansionPower = 2.0); public sealed record MimirCalibratedAudioCompositeSource( string SourceId, @@ -148,6 +152,11 @@ public sealed class MimirCalibratedAudioCompositeBuilder(MimirCalibratedAudioCom } } + if (options.EnableResidualNoiseExpander) + { + ApplyResidualNoiseExpander(output); + } + var reportCount = Math.Max(1, reports.Count); return new MimirCalibratedAudioCompositeResult( sampleRate, @@ -417,6 +426,37 @@ public sealed class MimirCalibratedAudioCompositeBuilder(MimirCalibratedAudioCom return 1.0 / (1.0 + Math.Sqrt(variance)); } + private void ApplyResidualNoiseExpander(float[] samples) + { + if (samples.Length == 0) + { + return; + } + + var absSorted = samples + .Select(static sample => Math.Abs(sample)) + .Order() + .ToArray(); + var floorIndex = Math.Clamp((int)Math.Round((absSorted.Length - 1) * 0.20), 0, absSorted.Length - 1); + var noiseFloor = Math.Max(options.NoiseFloorRms, absSorted[floorIndex] * 1.4826); + var threshold = Math.Max(options.NoiseFloorRms * 2.0, noiseFloor * Math.Max(1.0, options.ResidualNoiseFloorMultiplier)); + var minGain = Math.Clamp(options.ResidualNoiseMinimumGain, 0.0, 1.0); + var power = Math.Clamp(options.ResidualNoiseExpansionPower, 0.25, 8.0); + var attack = 0.45; + var release = 0.996; + var envelope = 0.0; + for (var index = 0; index < samples.Length; index++) + { + var magnitude = Math.Abs(samples[index]); + envelope = magnitude > envelope + ? envelope * attack + magnitude * (1.0 - attack) + : envelope * release + magnitude * (1.0 - release); + var ratio = Math.Clamp(envelope / threshold, 0.0, 1.0); + var gain = minGain + (1.0 - minGain) * Math.Pow(ratio, power); + samples[index] = (float)Math.Clamp(samples[index] * gain, -1.0, 1.0); + } + } + private sealed record PreparedCompositeSource( string SourceId, float[] Samples, diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 4319d00..1a9edd8 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -318,3 +318,4 @@ {"ts": "2026-06-01T04:01:53+01:00", "type": "verification", "status": "ok", "note": "Bioacoustic scheduler now shares the targeted probe planner's measurable frequency boundary. The scheduler filters residual confidence to schedulable bands before choosing cadence/status and passes the same 120 Hz-12 kHz window to the planner, so unmeasurable 18.5 kHz residuals no longer keep live status pinned to a band the Realtek/speaker/Scarlett path cannot answer. Verified with --bioacoustic-probe-scheduler-smoke and --targeted-bioacoustic-probe-smoke."} {"ts": "2026-06-01T04:13:53+01:00", "type": "verification", "status": "ok", "note": "Added calibrated-band coherence suppression to MimirCalibratedAudioCompositeBuilder. The composite path now aligns sources, applies measured-band correction, scores phase/energy coherence per calibrated band, suppresses incoherent measured-band components, and reports source/band coherence. Verified with --dual-mic-coherence-cancellation-smoke: shared tones held ~0.999 coherence, a mic-local 3.52 kHz interferer scored ~0.001 coherence with ~0.948 suppression, poison energy fell 0.039195 to 0.001306, and SNR rose 1.366 dB to 16.304 dB."} {"ts": "2026-06-01T04:24:57+01:00", "type": "verification", "status": "ok", "note": "Recorded a listenable Kiyo plus computed dual-mic composite bridge receipt at artifacts/runtime/kiyo-dual-mic-composite/kiyo-dual-mic-composite-latest.mp4. The script record-kiyo-dual-mic-composite.ps1 started Kiyo FFmpeg capture and Scarlett ASIO raw capture together, generated dual-mic-composite.wav via --asio-dual-mic-composite-wav, then muxed it. ffprobe verified 10.000 s of 640x480 30 fps H.264 video plus 9.994 s of 48 kHz mono AAC. The composite report estimated cardioid delay -141.019 samples (-2937.889 us) relative to shotgun and emitted 11 coherence band reports."} +{"ts": "2026-06-01T04:32:13+01:00", "type": "verification", "status": "ok", "note": "Tightened Kiyo dual-mic composite bridge after listening feedback: limited measured-band gain to 1.18x, raised incoherent-band suppression, and enabled residual envelope expansion. Reprocessed the 20260601-042314 raw ASIO/Kiyo receipt. Cleaner MP4 now at artifacts/runtime/kiyo-dual-mic-composite/kiyo-dual-mic-composite-latest.mp4; ffprobe verified 10.000 s 640x480@30 video plus 9.994 s 48 kHz mono AAC. Composite RMS fell from 0.046805 to 0.034400 while preserving the same -141.019 sample mic-delay estimate."} diff --git a/state/map.yaml b/state/map.yaml index 7e75b82..cf4d00d 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -657,7 +657,12 @@ accepted_design: `artifacts/runtime/kiyo-dual-mic-composite/kiyo-dual-mic-composite-latest.mp4` has 10.000 s of 640x480 30 fps Kiyo video and 9.994 s of mono AAC composite audio; the composite report estimated channel-1 delay at about -141.019 - samples (-2937.889 us). + samples (-2937.889 us). After listening feedback, the bridge audition + defaults now cap measured-band boost at 1.18x, suppress incoherent + calibrated bands harder, and enable a residual envelope expander to demote + the low-level post-sum noise bed. Reprocessing the same raw ASIO/Kiyo + receipt lowered composite RMS from 0.046805 to 0.034400 while preserving the + same delay estimate. Faust/native DSP still owns the production hot lane; this C# path is a contract, scorer, and offline diagnostic, not a competing live mixer. `MimirTargetedBioacousticProbePlanner` is now the residual-driven probe