diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index 37d748b..081d050 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -108,8 +108,10 @@ a named invariant that the native runtime cannot protect yet. they do not run synchronization analysis. - `MimirRuntime` publishes live ASIO spectrum history to Fensalir as direct `AquariumSplineFrame` tube surfaces. The spline shader owns visible coverage: - it evaluates capsule/tube distance, applies native blue-noise jitter, and - writes scene color plus temporal reservoir guide MRTs. The old + it evaluates capsule/tube distance and writes scene color plus temporal + reservoir guide MRTs. Direct spline rendering is deterministic; native + blue-noise jitter belongs in a future stochastic surface-claim producer, not + in the direct debug surface. The old `AquariumBufferFieldFrame` / `ReservoirSplats` dashboard path is no longer allowed to decide this surface. Spectrum rows are timestamped history frames: row identity is stable, source identity is stable, band identity is stable, @@ -253,9 +255,10 @@ a named invariant that the native runtime cannot protect yet. 6. Bind Fensalir UI to the synchronization hub so buffer depth, stream cadence, source timestamps, and output settings are visible and adjustable. 7. Tighten the spectrum spline tube temporal path until it behaves like a - production debug surface: shader-owned tube SDF coverage, native blue-noise - sample jitter, and temporal accumulation from sparse frame budgets. Do not - route this dashboard back through fractal point splats. + production debug surface: shader-owned tube SDF coverage, correct + camera-travel metadata, deterministic direct rendering, and temporal + accumulation from stable frame budgets. Do not route this dashboard back + through fractal point splats. 8. Move GPU feature extraction, fusion, material fitting, render budgeting, and Spout2 publication into Fensalir. 9. Move mic alignment, room suppression, voice separation, spatialization, and diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 0591016..707f554 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -318,8 +318,11 @@ whose truth is a tube SDF. Fensalir's spline shader owns visible coverage. Geometry is only the conservative segment envelope; the pixel shader evaluates capsule/tube -distance, applies native blue-noise sample jitter, writes color/metadata/control, -and emits `reservoirGuide` for the scene temporal path. Mimir must not rotate +distance, writes color/metadata/control, and emits `reservoirGuide` for the +scene temporal path. The direct spline fallback does not use stochastic +blue-noise perturbation; blue-noise sampling belongs in a real reservoir +producer, not in a direct debug surface where the viewer needs coherent lines. +Mimir must not rotate which rows or bands exist per frame: that made the surface temporally incoherent and impossible to follow. The live model stores timestamped spectrum history frames with monotonically increasing sequence ids, computes Z from diff --git a/src/Mimir.Runtime/MimirRuntime.cs b/src/Mimir.Runtime/MimirRuntime.cs index 81458b8..2a93cb0 100644 --- a/src/Mimir.Runtime/MimirRuntime.cs +++ b/src/Mimir.Runtime/MimirRuntime.cs @@ -34,8 +34,8 @@ public sealed class MimirRuntime : IAquariumRuntime private const float SpectrumSplineEmission = 1.85f; private const float SpectrumSplineHotBloom = 8.0f; private const int DefaultSpectrumSplineWindowStride = 2; - private const int DefaultSpectrumSplineBandStride = 2; - private const int DefaultSpectrumSplineSubdivisions = 1; + private const int DefaultSpectrumSplineBandStride = 1; + private const int DefaultSpectrumSplineSubdivisions = 2; private readonly MimirSynchronizationHub synchronization; private readonly MimirAudioSpectrumAnalyzer spectrumAnalyzer; private readonly IReadOnlyList sourceFactories; @@ -935,9 +935,7 @@ public sealed class MimirRuntime : IAquariumRuntime int bandStride) { var bands = spectrum.BandDecibels; - var floor = Math.Min(spectrum.NoiseFloorDb, bands.Min()); - var ceiling = Math.Max(-24.0, bands.Max()); - var span = Math.Max(18.0, ceiling - floor); + var envelope = SmoothedSpectrumEnvelope(spectrum); var points = new List((bands.Count + bandStride - 1) / bandStride + 2); for (var index = 0; index < bands.Count; index++) { @@ -948,7 +946,7 @@ public sealed class MimirRuntime : IAquariumRuntime } var x = -SpectrumWidth * 0.5f + SpectrumWidth * index / Math.Max(1, bands.Count - 1); - var normalized = (float)Math.Clamp((bands[index] - floor) / span, 0.0, 1.0); + var normalized = envelope[index]; var y = channelBaseY + normalized * SpectrumAmplitudeHeight; points.Add(new AquariumSplineVertex( new Vector3(x, y, z), @@ -958,6 +956,50 @@ public sealed class MimirRuntime : IAquariumRuntime return points; } + private static float[] SmoothedSpectrumEnvelope(MimirAudioSpectrumSnapshot spectrum) + { + var bands = spectrum.BandDecibels; + var floor = Math.Min(spectrum.NoiseFloorDb, bands.Min()); + var ceiling = Math.Max(-24.0, Percentile(bands, 0.96)); + var span = Math.Max(18.0, ceiling - floor); + var normalized = new float[bands.Count]; + for (var index = 0; index < bands.Count; index++) + { + normalized[index] = (float)Math.Clamp((bands[index] - floor) / span, 0.0, 1.35); + } + + return GaussianSmooth5(normalized); + } + + private static float[] GaussianSmooth5(IReadOnlyList values) + { + var smoothed = new float[values.Count]; + for (var index = 0; index < values.Count; index++) + { + var value = + values[Math.Max(0, index - 2)] * 0.0625f + + values[Math.Max(0, index - 1)] * 0.25f + + values[index] * 0.375f + + values[Math.Min(values.Count - 1, index + 1)] * 0.25f + + values[Math.Min(values.Count - 1, index + 2)] * 0.0625f; + smoothed[index] = Math.Clamp(value, 0.0f, 1.25f); + } + + return smoothed; + } + + private static double Percentile(IReadOnlyList values, double percentile) + { + if (values.Count == 0) + { + return 0.0; + } + + var sorted = values.OrderBy(value => value).ToArray(); + var index = Math.Clamp((int)Math.Round((sorted.Length - 1) * percentile), 0, sorted.Length - 1); + return sorted[index]; + } + private static void AddSpectrumGridSplines( List splines, int channelCount, diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 2e3afe8..ffea777 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -130,3 +130,4 @@ {"ts": "2026-05-26T10:48:57+01:00", "type": "correction", "status": "ok", "note": "Spectrum dashboard authority is direct spline-tube SDF again: Mimir submits AquariumSplineFrame trails and leaves AquariumBufferFieldFrame empty, so fractal ReservoirSplats cannot own the view. The live run artifacts/runtime/mimir-spectrum-sdf-temporal-sparse.out.log showed four 192 kHz ASIO lanes, no D3D12 fractal reservoir lines, and about 4-7 ms D3D12 CPU frames with record near 3 ms using sparse rotating spline budgets."} {"ts": "2026-05-26T11:01:55+01:00", "type": "implementation", "status": "ok", "note": "Spectrum spline heat now drives HDR bloom instead of relying on flat color. Mimir maps normalized band energy through a hard-drive curve: quiet bins stay dim/transparent, hot bins raise alpha and HDR red/yellow/white energy before Fensalir bloom/ACES tonemapping. Live ASIO proof artifacts/runtime/mimir-spectrum-hot-bloom-screen.png shows loopback lanes glowing while quiet lanes stay subdued; frame timing remained about 4.5-6.9 ms with no ReservoirSplats/fractal dashboard path."} {"ts": "2026-05-26T11:13:09+01:00", "type": "correction", "status": "ok", "note": "Rebuilt spectrum spline history around temporal identity instead of render-frame sampling. The failed path rotated row and band selection by frameIndex, so visible line identity changed every frame and older windows teleported by integer queue age. Mimir now stores timestamped spectrum history frames with sequence ids, computes Z from continuous age, keeps source ordering across the full history, and only decimates by stable history-sequence/frequency-bin identity. Full no-decimation proof was coherent but exposed Fensalir CPU spline expansion at ~25 ms record; stable LOD defaults restore ~6-8 ms without frame-phase flicker. Proof: artifacts/runtime/mimir-spectrum-coherent-lod-screen.png and .out.log."} +{"ts": "2026-05-26T11:29:14+01:00", "type": "correction", "status": "ok", "note": "Corrected spectrum spline surface ownership: Fensalir direct splines no longer alpha-blend segment overlap, D3D12SplinePS writes true camera travel into colorTravel.a instead of alpha, coverage/confidence now lives in control/reservoirGuide, and direct blue-noise jitter was removed from the fallback surface. Headless proof artifacts/runtime/mimir-spline-travel-owner-smooth.png shows smooth deterministic synthetic spectrum tubes after the fix. This is still the direct SDF debug path, not the future stochastic reservoir producer."}