Route spectrum dashboard through reservoir budget

This commit is contained in:
Meta Vens 2026-05-26 10:31:12 +01:00
commit 1eb195804a
4 changed files with 168 additions and 17 deletions

View file

@ -106,10 +106,13 @@ a named invariant that the native runtime cannot protect yet.
service and can emit live sync telemetry with
`MIMIR_SYNC_TELEMETRY_SECONDS`. UI and telemetry read cached reports/states;
they do not run synchronization analysis.
- `MimirRuntime` publishes live ASIO spectrum history to Fensalir as direct
`AquariumSplineFrame` tube trails. The spectrum dashboard is a debug/runtime
surface, not a reservoir-splat field; no `AquariumBufferFieldFrame` is
submitted for it.
- `MimirRuntime` publishes live ASIO spectrum history to Fensalir as one
`AquariumBufferFieldFrame` texture-spline reservoir surface. Direct
`AquariumSplineFrame` submission is disabled for this dashboard. The current
tuning defaults to 32,768 reservoir samples with 8,192 updates per frame and
exposes `MIMIR_SPECTRUM_RESERVOIR_SPLATS`,
`MIMIR_SPECTRUM_RESERVOIR_UPDATES`, and
`MIMIR_SPECTRUM_RESERVOIR_CANDIDATES` for budget cuts.
- `MimirRuntime` queues bioacoustic timeline PCM through Fensalir audio when the
active timing witness is allowed. `MimirAudioSynchronizationSettings.Mode`
selects `chirp-only`, `passive`, or `hybrid`; passive disables active
@ -242,9 +245,10 @@ a named invariant that the native runtime cannot protect yet.
with probe durations long enough to keep loopback and mic windows live.
6. Bind Fensalir UI to the synchronization hub so buffer depth, stream cadence,
source timestamps, and output settings are visible and adjustable.
7. Keep the spectrum dashboard on direct spline-tube rendering. Future buffer
fields may exist for other volumetric surfaces, but this debug surface must
not submit reservoir splats.
7. Promote the spectrum reservoir producer from hash-jittered texture-spline
samples to native blue-noise compute sampling once Fensalir exposes the
blue-noise tile to the reservoir compute root. Keep direct spline triangles
off for this dashboard unless explicitly debugging the spline shader.
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

View file

@ -309,15 +309,18 @@ Visual fusion belongs in Fensalir over current reservoir claims. Native capture
workers provide frames; Fensalir owns feature extraction, matching, material
fitting, render budgeting, and publication.
The live debug spectrum view is direct spline-tube rendering. Mimir submits an
`AquariumSplineFrame` only: each rolling audio spectrum window becomes a
Catmull-Rom tube trail with frequency on X, amplitude on Y, history on Z, and
channels stacked along Y. Fensalir owns the shader-side tube SDF coverage for
those splines.
The live debug spectrum view is a Fensalir buffer-field reservoir surface, not
direct spline triangles. Mimir submits one `AquariumBufferFieldFrame` texture
spline program for the rolling ASIO spectrum: frequency lives on X, amplitude
on Y, history on Z, and channels stack along Y. Direct `AquariumSplineFrame`
submission is disabled for this surface so there is one visual authority.
`AquariumBufferFieldFrame`/reservoir splats are not part of this spectrum
dashboard. That previous path made the debug surface look like point/probe
dust and split visual authority between reservoir dots and direct tubes.
The current reservoir cut defaults to 32,768 spectrum samples, 8,192 sample
updates per frame, one candidate per update, and `WorldCenterRadius=(0,0,0,1)`
so sample radii stay in spectrum-world units instead of inflating into giant
screen plates. Fensalir still uses hash/jittered compute sampling for this
producer; native blue-noise sampling is available in scene shaders but is not
yet bound into the reservoir compute root.
## Known Risks

View file

@ -31,6 +31,9 @@ public sealed class MimirRuntime : IAquariumRuntime
private const float SpectrumCameraFitPadding = 1.12f;
private const float SpectrumFrustumMinimumNear = 0.01f;
private const float SpectrumSplineTubePadding = 0.18f;
private const int DefaultSpectrumReservoirSplatCount = 32768;
private const int DefaultSpectrumReservoirUpdatesPerFrame = 8192;
private const int DefaultSpectrumReservoirCandidates = 1;
private readonly MimirSynchronizationHub synchronization;
private readonly MimirAudioSpectrumAnalyzer spectrumAnalyzer;
private readonly IReadOnlyList<MimirStreamSourceFactory> sourceFactories;
@ -134,6 +137,7 @@ public sealed class MimirRuntime : IAquariumRuntime
private AquariumFrame CreateFrame()
{
var channelCount = Math.Max(1, lastAudioSpectra.Count);
var bufferFieldFrame = BuildSpectrumBufferFieldFrame();
var windowCount = Math.Max(1, spectrumHistory.Count);
var (splineMin, splineMax) = SpectrumSplineAabb(channelCount, windowCount);
var cameraTarget = (splineMin + splineMax) * 0.5f;
@ -158,8 +162,8 @@ public sealed class MimirRuntime : IAquariumRuntime
{
TraceHeightFieldSurface = false,
UseStarfieldBackground = false,
BufferFieldFrame = AquariumBufferFieldFrame.Empty,
SplineFrame = BuildSpectrumSplineFrame(),
BufferFieldFrame = bufferFieldFrame,
SplineFrame = AquariumSplineFrame.Empty,
});
}
@ -682,6 +686,27 @@ public sealed class MimirRuntime : IAquariumRuntime
: 96;
}
private static int ParseSpectrumReservoirSplatCount()
{
return int.TryParse(Environment.GetEnvironmentVariable("MIMIR_SPECTRUM_RESERVOIR_SPLATS"), out var value)
? Math.Clamp(value, 1024, 524288)
: DefaultSpectrumReservoirSplatCount;
}
private static int ParseSpectrumReservoirUpdatesPerFrame()
{
return int.TryParse(Environment.GetEnvironmentVariable("MIMIR_SPECTRUM_RESERVOIR_UPDATES"), out var value)
? Math.Clamp(value, 1, 524288)
: DefaultSpectrumReservoirUpdatesPerFrame;
}
private static int ParseSpectrumReservoirCandidates()
{
return int.TryParse(Environment.GetEnvironmentVariable("MIMIR_SPECTRUM_RESERVOIR_CANDIDATES"), out var value)
? Math.Clamp(value, 1, 8)
: DefaultSpectrumReservoirCandidates;
}
private static bool IsTruthy(string? value) =>
string.Equals(value, "1", StringComparison.OrdinalIgnoreCase) ||
string.Equals(value, "true", StringComparison.OrdinalIgnoreCase) ||
@ -880,6 +905,124 @@ public sealed class MimirRuntime : IAquariumRuntime
return new AquariumSplineFrame { Splines = splines };
}
private AquariumBufferFieldFrame BuildSpectrumBufferFieldFrame()
{
if (!sceneReady || spectrumHistory.Count == 0)
{
return AquariumBufferFieldFrame.Empty;
}
var windows = spectrumHistory.ToArray();
var latest = windows[^1];
var sourceIds = latest
.Select(spectrum => spectrum.SourceId)
.OrderBy(sourceId => sourceId, StringComparer.Ordinal)
.ToArray();
if (sourceIds.Length == 0)
{
return AquariumBufferFieldFrame.Empty;
}
var bandCount = latest.FirstOrDefault(spectrum => spectrum.BandDecibels.Count > 0)?.BandDecibels.Count ?? 0;
if (bandCount <= 1)
{
return AquariumBufferFieldFrame.Empty;
}
var rowCount = SpectrumHistoryWindowCount * sourceIds.Length;
var samples = new float[bandCount * rowCount];
for (var windowIndex = 0; windowIndex < windows.Length; windowIndex++)
{
var ageFromNewest = windows.Length - 1 - windowIndex;
var spectraBySource = windows[windowIndex].ToDictionary(spectrum => spectrum.SourceId, StringComparer.Ordinal);
for (var channelIndex = 0; channelIndex < sourceIds.Length; channelIndex++)
{
if (!spectraBySource.TryGetValue(sourceIds[channelIndex], out var spectrum) || spectrum.BandDecibels.Count != bandCount)
{
continue;
}
var row = channelIndex * SpectrumHistoryWindowCount + ageFromNewest;
WriteSpectrumRow(samples, row * bandCount, spectrum);
}
}
var splatCount = ParseSpectrumReservoirSplatCount();
var updatesPerFrame = Math.Clamp(ParseSpectrumReservoirUpdatesPerFrame(), 1, splatCount);
var bandStep = SpectrumWidth / Math.Max(1, bandCount - 1);
var reservoir = new AquariumFractalReservoirField
{
SplatCount = splatCount,
Depth = 1,
Seed = 0xB11FF13Du,
CandidatesPerReservoirUpdate = ParseSpectrumReservoirCandidates(),
SplatUpdatesPerFrame = updatesPerFrame,
ReservoirUpdatesPerPass = updatesPerFrame,
WorldCenterRadius = new Vector4(0.0f, 0.0f, 0.0f, 1.0f),
};
var program = new AquariumTextureSplineFieldProgram(
"asioSpectrumWaterfall",
"spectrumHistory",
AquariumTextureAxis.X,
FirstColumn: 0,
ColumnCount: rowCount,
ColumnStride: 1,
RollingWindowModulo: rowCount,
Subdivisions: 1,
Origin: new Vector3(-SpectrumWidth * 0.5f, 0.0f, 0.0f),
AxisStep: new Vector3(bandStep, 0.0f, 0.0f),
ColumnStep: new Vector3(0.0f, 0.0f, SpectrumWindowDepthSeparation),
ColumnGroupSize: SpectrumHistoryWindowCount,
ColumnGroupStep: new Vector3(0.0f, SpectrumChannelSeparation, 0.0f),
AmplitudeScale: SpectrumAmplitudeHeight,
Appearance: new AquariumSplineTubeAppearance(
new Vector4(1.0f, 0.68f, 0.12f, 2.5f),
Radius: 0.012f,
Alpha: 0.82f,
ZeroThreshold: 0.68f,
Feather: 0.08f,
TangentWeight: 1.0f,
CurvatureWeight: 0.68f,
NormalWeight: 0.34f,
DerivativeWeight: 0.88f),
ProbePolicy: new AquariumSplineTubeProbePolicy(
MaxProbeCount: updatesPerFrame,
BaseDensity: 1.0f,
MinimumVisualContribution: 0.004f,
Seed: 0xB11FF13Du),
SurfaceGraph: []);
return AquariumBufferFieldFrame.Compose(builder => builder
.Texture(
"spectrumHistory",
bandCount,
rowCount,
1,
0,
AquariumRollingModuloMode.Rows,
samples)
.TextureSplineField(program)
.Reservoir(reservoir)
.Lowering(new AquariumFieldLoweringPolicy(
AquariumFieldLoweringMode.ReservoirSplats,
MaxDirectSplines: 1,
MaxDirectControlPoints: 2,
MaxReservoirSplats: splatCount,
LodBias: 1.0f)));
}
private static void WriteSpectrumRow(float[] samples, int offset, MimirAudioSpectrumSnapshot spectrum)
{
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);
for (var index = 0; index < bands.Count; index++)
{
samples[offset + index] = (float)Math.Clamp((bands[index] - floor) / span, 0.0, 1.0);
}
}
private static IReadOnlyList<AquariumSplineVertex> BuildSpectrumWindowSpline(
MimirAudioSpectrumSnapshot spectrum,
float channelBaseY,

View file

@ -126,3 +126,4 @@
{"ts": "2026-05-25T22:44:59+01:00", "type": "implementation", "status": "ok", "note": "Eve dashboard path now uses Fensalir shared D3D12 program texture -> Mimir.EveRelay H.264 Annex-B WebSocket -> EveCanvas native AVSampleBufferDisplayLayer. Local Windows firewall blocked direct inbound TCP 8792, so launch script opens an SSH reverse tunnel and EveCanvas tries localhost before LAN. Live health reported h264-annexb 1264x681 with one connected client."}
{"ts": "2026-05-25T23:02:30+01:00", "type": "implementation", "status": "ok", "note": "Mimir local spectrum dashboard now forces Fensalir texture-spline field lowering to ReservoirSplats instead of auto direct tubes. Auto mode chose direct tubes for 160 columns, so the screen was not the final sampled reservoir. Spectrum rows now map age-from-newest explicitly: newest/front at z=0, older windows recede +Z. Live run shows 131,072 visible reservoir splats and four 192 kHz ASIO lanes."}
{"status":"ok","note":"Spectrum dashboard authority cut: Mimir no longer submits AquariumBufferFieldFrame/reservoir splats for the live audio spectrum view. The surface is direct AquariumSplineFrame tube trails only; config/mimir-spectrum-field.aquafield was deleted so the old ReservoirSplats path cannot reappear through configuration.","type":"correction","ts":"2026-05-26T10:08:18+01:00"}
{"status":"ok","note":"Corrected the previous overcut: the spectrum dashboard is back on a single AquariumBufferFieldFrame reservoir authority with direct spline triangles disabled. Defaults are 32768 reservoir samples, 8192 updates/frame, one candidate/update, and WorldCenterRadius=(0,0,0,1) to prevent sample radii from inflating into giant discs. Fensalir transparent-field splats no longer enforce the 0.035*fieldRadius minimum billboard radius. Runtime proof logs 32768 visible splats at about 3-6 ms CPU frame time and about 0.2 ms command recording. Compute sampling is still hash-jittered rather than true blue-noise texture driven.","type":"correction","ts":"2026-05-26T10:31:00+01:00"}