Route dual mic cleanup after Faust alignment

This commit is contained in:
Meta Vens 2026-06-01 04:47:06 +01:00
commit ae8247303e
9 changed files with 223 additions and 25 deletions

View file

@ -157,11 +157,17 @@ that WAV with the Kiyo video. The 2026-06-01 receipt at
contains 10.000 s of 640x480 30 fps Kiyo video and 9.994 s of mono AAC from the
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.
are suppressed more aggressively, and the choppy post-sum residual expander is
not enabled by default. The next hot owner is
`faust/mimir_dual_mic_dialogue_cleaner.dsp`: a two-input/two-output Faust graph
for aligned shotgun/cardioid witnesses that emits a dialogue composite stem and
a rejected residual witness using smooth multiband voice shaping, witness
subtraction, and slow downward expansion. `MimirRuntime` now queues that Faust
program as `dual-mic-dialogue-cleaner` with `host_voice` and residual `ambient`
output stems, but only feeds it from the alignment actuator's published
`aligned_source_*` stem frame. Alignment is therefore a structural precursor to
cleanup, not an optional sidecar. Treat the C# bridge as an audition/scoring
receipt, 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

View file

@ -819,8 +819,12 @@ a named invariant that the native runtime cannot protect yet.
renders the channels 0/1 composite WAV with `--asio-dual-mic-composite-wav`,
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
suppression, and do not enable the choppy C# residual expander by default.
The Faust hot-lane target now exists as
`faust/mimir_dual_mic_dialogue_cleaner.dsp`; Mimir queues it as
`dual-mic-dialogue-cleaner`, consuming the alignment actuator's published
`aligned_source_*` stem frame rather than raw mic buffers, and emitting
`host_voice` plus a rejected residual witness. Treat the C# bridge 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

View file

@ -0,0 +1,65 @@
declare name "Mimir Dual Mic Dialogue Cleaner";
declare version "0.1";
declare author "Mimir";
declare license "MIT";
declare description "Faust-owned smooth dual-mic dialogue cleanup target: aligned shotgun/cardioid inputs become a conservative dialogue stem and a rejected residual witness.";
import("stdfaust.lib");
// Inputs are already delay-aligned upstream by mimir_alignment_actuator.
// This graph owns smooth audio-rate cleanup, not calibration, timing, or UI.
//
// input 0: aligned shotgun / co-streamer witness
// input 1: aligned cardioid / host witness
// output 0: dialogue composite stem
// output 1: rejected residual / noise witness
drive = hslider("dialogue/drive", 1.00, 0.00, 2.00, 0.001);
shotgunWeight = hslider("dialogue/shotgun_weight", 0.45, 0.00, 1.00, 0.001);
cardioidWeight = hslider("dialogue/cardioid_weight", 0.55, 0.00, 1.00, 0.001);
witnessReject = hslider("dialogue/witness_reject", 0.20, 0.00, 1.00, 0.001);
lowShelf = hslider("dialogue/low_shelf", 0.80, 0.00, 2.00, 0.001);
presenceShelf = hslider("dialogue/presence_shelf", 1.08, 0.00, 2.00, 0.001);
airShelf = hslider("dialogue/air_shelf", 0.90, 0.00, 2.00, 0.001);
// Smooth broadband downward expansion. This is intentionally slow enough to
// avoid the choppy gate artifact from the C# audition bridge.
floorLevel = hslider("denoise/noise_floor", 0.018, 0.0001, 0.25, 0.0001);
expansionDepth = hslider("denoise/expansion_depth", 0.32, 0.00, 0.95, 0.001);
expansionCurve = hslider("denoise/expansion_curve", 1.35, 0.25, 4.00, 0.001);
envelopeHz = hslider("denoise/envelope_hz", 18.0, 1.0, 80.0, 0.1);
band(f, q, g, x) = x : fi.resonbp(1.0, f, q) : *(g);
voiceShape(x) =
band(120.0, 1.2, lowShelf, x) +
band(220.0, 1.6, 0.95, x) +
band(420.0, 2.0, 0.98, x) +
band(800.0, 2.4, 1.00, x) +
band(1500.0, 2.8, presenceShelf, x) +
band(2800.0, 3.2, presenceShelf, x) +
band(5200.0, 3.2, airShelf, x) +
band(8500.0, 2.6, airShelf, x);
smoothAbs(x) = abs(x) : si.smooth(ba.tau2pole(1.0 / max(1.0, envelopeHz)));
softExpand(x) = x * gain
with {
env = smoothAbs(x);
ratio = min(1.0, env / max(0.0001, floorLevel));
openness = pow(ratio, expansionCurve);
gain = 1.0 - expansionDepth * (1.0 - openness);
};
softClip(x) = x / (1.0 + abs(x));
clean(shotgun, cardioid) = dialogue, residual
with {
weighted = shotgun * shotgunWeight + cardioid * cardioidWeight;
witness = (shotgun - cardioid) * 0.5;
shaped = voiceShape(weighted - witnessReject * witness);
dialogue = softExpand(shaped * drive) : softClip;
residual = witness + (weighted - dialogue) * 0.25;
};
process = clean;

View file

@ -327,11 +327,16 @@ 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). 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.
are suppressed harder, and the choppy residual expander is not enabled by
default. The actual denoise authority is moving to Faust:
`faust/mimir_dual_mic_dialogue_cleaner.dsp` compiles as a two-input/two-output
aligned shotgun/cardioid dialogue cleaner with smooth multiband voice shaping,
witness subtraction, and slow downward expansion. `MimirRuntime` queues it as
`dual-mic-dialogue-cleaner` with `host_voice` and residual `ambient` output
stems. It is fed from the alignment actuator's published `aligned_source_*`
stem frame, not from raw mic buffers, so Faust alignment is a real structural
precursor to cleanup. This is the first hot-lane cleaner socket, not proof that
the final studio denoiser is solved.
`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

View file

@ -3531,11 +3531,7 @@ static int RunAsioDualMicCompositeWave(
MaximumBandGain: 1.18,
NoiseFloorRms: 1.0e-5,
MinimumCoherence: 0.48,
IncoherentBandSuppression: 0.78,
EnableResidualNoiseExpander: true,
ResidualNoiseFloorMultiplier: 2.8,
ResidualNoiseMinimumGain: 0.16,
ResidualNoiseExpansionPower: 2.4)).Build(
IncoherentBandSuppression: 0.78)).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)),

View file

@ -87,6 +87,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
private long spectrumHistorySequence;
private long audioActuatorFrameSequence;
private bool audioActuatorProgramQueued;
private bool dialogueCleanerProgramQueued;
private readonly Queue<MimirSpectrumHistoryFrame> spectrumHistory = new();
private AquariumRuntimeServices runtimeServices = AquariumRuntimeServices.Empty;
private MimirActuatorFrame lastAudioActuatorFrame = MimirActuatorFrame.Empty;
@ -1333,6 +1334,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
}
QueueAudioActuatorProgram();
QueueDialogueCleanerProgram();
audio.EnqueueControlFrame(new AquariumAudioControlFrame(
MimirAlignmentActuatorProfile.SixSourceFaust.Id,
frame.ReferenceSourceId,
@ -1379,6 +1381,30 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
audioActuatorProgramQueued = true;
}
private void QueueDialogueCleanerProgram()
{
if (dialogueCleanerProgramQueued)
{
return;
}
var profile = MimirDialogueCleanerProfile.DualMicFaust;
var path = ResolveRuntimeAssetPath(profile.FaustDspPath);
if (path == null)
{
Console.WriteLine($"Mimir dialogue cleaner DSP not queued; `{profile.FaustDspPath}` was not found.");
return;
}
audio.EnqueueStreamingDspProgram(new AquariumStreamingDspProgram(
profile.Id,
"mimir_dual_mic_dialogue_cleaner",
File.ReadAllText(path),
unchecked((int)File.GetLastWriteTimeUtc(path).Ticks),
OutputStems: profile.OutputStems));
dialogueCleanerProgramQueued = true;
}
private void QueueStreamingActuatorAudioBlock(MimirActuatorFrame frame, long sequence)
{
var commands = frame.Commands.OrderBy(command => command.SourceId, StringComparer.Ordinal).ToArray();
@ -1450,6 +1476,77 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
sequence));
}
private void QueueStreamingDialogueCleanerAudioBlock(AquariumAudioStemFrame alignedFrame)
{
if (!string.Equals(alignedFrame.ProfileId, MimirAlignmentActuatorProfile.SixSourceFaust.Id, StringComparison.Ordinal))
{
return;
}
var candidates = alignedFrame.Channels
.OrderBy(channel => DialogueCleanerSourceRank(channel.SourceId))
.ThenBy(channel => channel.SourceId, StringComparer.Ordinal)
.Take(MimirDialogueCleanerProfile.DualMicFaust.SourceCount)
.ToArray();
if (candidates.Length < MimirDialogueCleanerProfile.DualMicFaust.SourceCount)
{
return;
}
var channels = new List<AquariumStreamingAudioChannel>(MimirDialogueCleanerProfile.DualMicFaust.SourceCount);
var frameCount = alignedFrame.FrameCount;
var sampleRate = alignedFrame.SampleRate;
for (var index = 0; index < candidates.Length; index++)
{
var samples = ApplyGain(candidates[index].Samples, presentationControls.AudioGain(candidates[index].SourceId));
if (samples.Length == 0)
{
return;
}
frameCount = Math.Min(frameCount, samples.Length);
channels.Add(new AquariumStreamingAudioChannel(index, candidates[index].SourceId, samples));
}
if (frameCount <= 0 || sampleRate <= 0)
{
return;
}
if (channels.Any(channel => channel.Samples.Length != frameCount))
{
channels = channels
.Select(channel => channel.Samples.Length == frameCount
? channel
: channel with { Samples = channel.Samples.AsSpan(0, frameCount).ToArray() })
.ToList();
}
audio.EnqueueStreamingAudioBlock(new AquariumStreamingAudioBlock(
MimirDialogueCleanerProfile.DualMicFaust.Id,
channels,
frameCount,
sampleRate,
alignedFrame.Sequence));
}
private static int DialogueCleanerSourceRank(string sourceId)
{
if (sourceId.Contains("asio-ch0", StringComparison.OrdinalIgnoreCase) ||
sourceId.Contains("shotgun", StringComparison.OrdinalIgnoreCase))
{
return 0;
}
if (sourceId.Contains("asio-ch1", StringComparison.OrdinalIgnoreCase) ||
sourceId.Contains("cardioid", StringComparison.OrdinalIgnoreCase))
{
return 1;
}
return 100;
}
private IReadOnlyDictionary<string, float> ApplyPresentationGain(MimirActuatorCommand command)
{
var gain = presentationControls.AudioGain(command.SourceId);
@ -1467,8 +1564,12 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
var consumed = false;
foreach (var stemFrame in runtimeServices.AudioStems.DrainPublishedFrames())
{
obsStemPublication.Consume(stemFrame);
consumed = true;
if (string.Equals(stemFrame.ProfileId, MimirAlignmentActuatorProfile.SixSourceFaust.Id, StringComparison.Ordinal))
{
QueueStreamingDialogueCleanerAudioBlock(stemFrame);
obsStemPublication.Consume(stemFrame);
consumed = true;
}
}
if (consumed)

View file

@ -17,6 +17,23 @@ public sealed record MimirAlignmentActuatorProfile(
GainControlFormat: "source{0}/gain");
}
public sealed record MimirDialogueCleanerProfile(
string Id,
string FaustDspPath,
int SourceCount,
IReadOnlyList<Aquarium.Engine.Audio.AquariumStreamingDspOutputStem> OutputStems)
{
public static MimirDialogueCleanerProfile DualMicFaust { get; } = new(
"dual-mic-dialogue-cleaner",
"faust/mimir_dual_mic_dialogue_cleaner.dsp",
SourceCount: 2,
OutputStems:
[
new(0, "host_voice", "Dialogue composite", "scarlett-dual-mic"),
new(1, "ambient", "Rejected residual", "scarlett-dual-mic")
]);
}
public sealed record MimirActuatorCommand(
string SourceId,
double TargetDelaySamples,

View file

@ -319,3 +319,5 @@
{"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."}
{"ts": "2026-06-01T04:44:10+01:00", "type": "decision", "status": "ok", "note": "Moved dual-mic cleanup authority toward Faust after listening feedback showed the C# residual expander made the Kiyo composite choppier rather than cleaner. Disabled the expander in --asio-dual-mic-composite-wav defaults, added faust/mimir_dual_mic_dialogue_cleaner.dsp as a smooth two-input shotgun/cardioid dialogue cleaner, and queued it from MimirRuntime as dual-mic-dialogue-cleaner with host_voice plus residual ambient stems. Verified dotnet build and Faust 2.85.5 C++ generation for the DSP."}
{"ts": "2026-06-01T04:46:01+01:00", "type": "decision", "status": "ok", "note": "Corrected the Faust cleaner wiring after user caught the prerequisite: dual-mic cleanup must consume post-alignment audio. The runtime no longer queues dual-mic-dialogue-cleaner from raw rolling buffers in parallel with the actuator. It now waits for the alignment actuator's published aligned_source_* stem frame from Fensalir's audio stem bus, then queues that aligned pair into the cleaner profile on the next tick. Alignment is a structural precursor to cleanup."}

View file

@ -659,12 +659,14 @@ accepted_design:
audio; the composite report estimated channel-1 delay at about -141.019
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.
calibrated bands harder, and leave the choppy residual expander disabled by
default. Faust/native DSP now has the first actual cleaner socket:
`faust/mimir_dual_mic_dialogue_cleaner.dsp` compiles as a smooth two-input
shotgun/cardioid dialogue cleaner and Mimir queues it as
`dual-mic-dialogue-cleaner`, fed from the alignment actuator's published
`aligned_source_*` stem frame rather than raw mic buffers, emitting
`host_voice` plus a rejected residual witness. The C# path is a contract,
scorer, and offline diagnostic, not a competing live mixer.
`MimirTargetedBioacousticProbePlanner` is now the residual-driven probe
planner for improving that calibration instead of blindly EQing harder. It
consumes per-source spectral residuals plus optional source pathology notes