diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 159407c..0f6c78e 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -51,6 +51,14 @@ Get-Content .\state\evidence.jsonl -Tail 8 properties. Camera/SDF/model editor affordances have no live UI authority, and editor camera/SDF/spline output no longer contributes to the runtime frame. Smoke with `--scene-editor-smoke`. +- The Audio Mixer dock is a horizontal CultUI channel-strip bank, not a + selected-stem inspector form. Six fixed slots read the live + `presentationControls.AudioFeeds` order so Scarlett ASIO mono inputs, + stereo loopback, and Raven loopback can appear as parallel strips with M/S, + gain, and compact sync/chirp-response readouts derived from + `MimirSynchronizationHub.AudioSynchronizationStates`. Do not move sample + alignment, chirp response mapping, or ambient/noise neutralization authority + into the UI; the surface only controls and observes runtime audio state. - Live camera image buffers should use Fensalir-owned texture leases when they are rendering inputs: Mimir asks the engine broker for a keyed D3D12 Texture2D/fence lease, writes decoded frames into that texture, commits the diff --git a/src/Mimir.Runtime/MimirRuntime.cs b/src/Mimir.Runtime/MimirRuntime.cs index d40c752..ac30eae 100644 --- a/src/Mimir.Runtime/MimirRuntime.cs +++ b/src/Mimir.Runtime/MimirRuntime.cs @@ -33,6 +33,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec private const float SpectrumFrustumMinimumNear = 0.01f; private const float SpectrumSplineTubePadding = 0.18f; private const int DefaultSpectrumSourceLaneCapacity = 8; + private const int AudioMixerChannelSlotCount = 6; private const string SpectrumFieldResourceKey = "mimir:resource:spectrum:field-upload"; private const string SpectrumRampResourceKey = AquariumBuiltInFieldResources.BlackbodyRampResourceKey; private static readonly string SpectrumRampTexturePath = AquariumBuiltInFieldResources.ResolveBlackbodyRampPath(); @@ -873,18 +874,29 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec shell.Vertical("mimir.editor-center", center => { - center.Preview("scene.view-preview", "", () => sceneEditor.PreviewItems, weight: 1.0f); + center.Preview("scene.view-preview", "", () => sceneEditor.PreviewItems, weight: 2.2f); center.Pane("mimir.audio-mixer", "Audio Mixer", mixer => { - mixer.Options("audio.stem", "Stem", () => presentationControls.SelectedAudioIndex, SelectAudioStem, AudioFeedOptions()); - mixer.Row("audio.toggles", toggles => + mixer.Horizontal("audio.channel-bank", bank => { - toggles.Toggle("audio.mute", "Mute", () => presentationControls.SelectedAudio?.Muted ?? false, SetSelectedAudioMuted); - toggles.Toggle("audio.solo", "Solo", () => presentationControls.SelectedAudio?.Solo ?? false, SetSelectedAudioSolo); - }); - mixer.Slider("audio.gain", "Gain", () => presentationControls.SelectedAudio?.Gain ?? 1.0f, SetSelectedAudioGain, 0.0f, 2.0f, "0.00"); - mixer.Text("audio.program", DescribeProgramAudio, "caption", weight: 0.8f); - }, weight: 0.72f); + for (var slot = 0; slot < AudioMixerChannelSlotCount; slot++) + { + var channelIndex = slot; + bank.Card($"audio.channel.{slot}", strip => + { + strip.Text($"audio.channel.{slot}.name", () => AudioChannelName(channelIndex), "strong", weight: 0.55f); + strip.Row($"audio.channel.{slot}.toggles", toggles => + { + toggles.Toggle($"audio.channel.{slot}.mute", "M", () => AudioMuted(channelIndex), value => SetAudioMuted(channelIndex, value)); + toggles.Toggle($"audio.channel.{slot}.solo", "S", () => AudioSolo(channelIndex), value => SetAudioSolo(channelIndex, value)); + }, weight: 0.55f); + strip.Slider($"audio.channel.{slot}.gain", "Gain", () => AudioGain(channelIndex), value => SetAudioGain(channelIndex, value), 0.0f, 2.0f, "0.00", weight: 0.65f); + strip.Text($"audio.channel.{slot}.status", () => DescribeAudioChannelStatus(channelIndex), "caption", weight: 0.95f); + }); + } + }, weight: 1.0f, gap: 6.0f); + mixer.Text("audio.program", DescribeProgramAudio, "caption", weight: 0.35f); + }, weight: 0.95f); }, weight: 1.75f); shell.Pane("mimir.inspector", "Inspector", inspector => @@ -1074,11 +1086,6 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec } } - private void SelectAudioStem(int index) - { - presentationControls.SelectedAudioIndex = Math.Clamp(index, 0, Math.Max(0, presentationControls.AudioFeeds.Count - 1)); - } - private void SetSelectedVideoVisible(bool visible) { sceneEditor.SetSelectedVisible(visible); @@ -1115,30 +1122,96 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec sceneEditor.MoveSelectedLayer(delta); } - private void SetSelectedAudioMuted(bool muted) + private MimirAudioPresentationControl? AudioChannel(int index) { - if (presentationControls.SelectedAudio is { } selected) + var feeds = presentationControls.AudioFeeds; + return index >= 0 && index < feeds.Count + ? feeds[index] + : null; + } + + private string AudioChannelName(int index) => + AudioChannel(index)?.DisplayName ?? "empty"; + + private string AudioChannelRole(MimirAudioPresentationControl channel) + { + var id = channel.SourceId; + if (id.Contains("raven", StringComparison.OrdinalIgnoreCase)) { - selected.Muted = muted; + return "Raven loopback"; + } + + if (id.Contains("loopback", StringComparison.OrdinalIgnoreCase)) + { + return "stereo loopback"; + } + + if (id.Contains("asio", StringComparison.OrdinalIgnoreCase) || + id.Contains("focusrite", StringComparison.OrdinalIgnoreCase) || + id.Contains("scarlett", StringComparison.OrdinalIgnoreCase)) + { + return "Scarlett ASIO"; + } + + return id; + } + + private bool AudioMuted(int index) => AudioChannel(index)?.Muted ?? false; + + private bool AudioSolo(int index) => AudioChannel(index)?.Solo ?? false; + + private float AudioGain(int index) => AudioChannel(index)?.Gain ?? 1.0f; + + private void SetAudioMuted(int index, bool muted) + { + if (AudioChannel(index) is { } channel) + { + channel.Muted = muted; } } - private void SetSelectedAudioSolo(bool solo) + private void SetAudioSolo(int index, bool solo) { - if (presentationControls.SelectedAudio is { } selected) + if (AudioChannel(index) is { } channel) { - selected.Solo = solo; + channel.Solo = solo; } } - private void SetSelectedAudioGain(float gain) + private void SetAudioGain(int index, float gain) { - if (presentationControls.SelectedAudio is { } selected) + if (AudioChannel(index) is { } channel) { - selected.Gain = Math.Clamp(gain, 0.0f, 2.0f); + channel.Gain = Math.Clamp(gain, 0.0f, 2.0f); } } + private string DescribeAudioChannelStatus(int index) + { + var channel = AudioChannel(index); + if (channel == null) + { + return ""; + } + + var role = AudioChannelRole(channel); + var state = AudioSynchronizationState(channel.SourceId); + if (state == null) + { + return $"{role} | sync waiting"; + } + + var lockLabel = state.Confidence >= 0.75 ? "locked" : "learning"; + var response = state.BandResponses.Count == 0 + ? "chirp unmapped" + : $"{state.BandResponses.Count} chirp bands"; + return $"{role} | {lockLabel} {state.DelayMicroseconds:0}us c={state.Confidence:0.00} | {response}"; + } + + private MimirAudioSynchronizationState? AudioSynchronizationState(string sourceId) => + synchronization.AudioSynchronizationStates + .FirstOrDefault(state => string.Equals(state.SourceId, sourceId, StringComparison.Ordinal)); + private IReadOnlyList VideoFeedOptions() { var feeds = presentationControls.VideoFeeds; @@ -1147,14 +1220,6 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec : feeds.Select((feed, index) => new AquariumUiOption(index, $"{feed.Layer + 1}. {feed.DisplayName}")).ToArray(); } - private IReadOnlyList AudioFeedOptions() - { - var feeds = presentationControls.AudioFeeds; - return feeds.Count == 0 - ? [new AquariumUiOption(0, "No audio")] - : feeds.Select((feed, index) => new AquariumUiOption(index, feed.DisplayName)).ToArray(); - } - private IReadOnlyList LutPresetOptions() => presentationControls.LutPresets .Select((preset, index) => new AquariumUiOption(index, preset.DisplayName)) diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 8be6d86..28d48c9 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -290,5 +290,6 @@ {"ts":"2026-05-31T22:45:00+01:00","type":"implementation","status":"ok","note":"Mimir editor authority was cut back to a 2D OBS-shaped program mixer. SceneEditorState no longer creates default SDF/model content, preview items are video-feed-only, runtime editor camera/SDF/spline output is silent, and the Eve/CultUI surface is Video Sources with source-adjacent layer actions left, chrome-free program canvas center, and Audio Mix right. Numeric transform inspector controls were removed from the live surface. `--scene-editor-smoke` now verifies only camera+video feed nodes, video-only preview items, and normalized program placement.","files":["src/Mimir.Runtime/MimirRuntime.cs","src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs","src/Mimir.BufferSmoke/Program.cs"],"source":"dotnet build src/Mimir.Runtime/Mimir.Runtime.csproj; dotnet build src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj; dotnet run --no-build --project src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj -- --scene-editor-smoke; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-flat-2d-program-mixer-headless.png"} {"ts": "2026-05-31T22:46:40+01:00", "type": "implementation", "status": "ok", "note": "Added the first Starfire-owned camera frustum solve. MimirCameraFrustumCalibrationSolver consumes stable LED/marker correspondences, scene-space marker points, and seed frustums, then emits position, rotation, horizontal/vertical tangent half-FOV, correspondence count, clipspace reprojection residual, and confidence. BufferSmoke --frustum-calibration-smoke solves five synthetic frustums for ps3-eye-0, ps3-eye-1, kiyo-pro-rgb, leap-stereo-ir, and eve-camera with mean clip error 0.000000; room calibration lock still passes. Eve is now modeled like Nightwing as eve-local-sensor-witness/eve-local-sensors: it owns local camera/mic flash and chirp solves and ships typed hints, not raw placement authority."} {"ts":"2026-05-31T23:05:00+01:00","type":"implementation","status":"ok","note":"Corrected the Mimir editor layout ownership after the flat-canvas pass: the center remains a chrome-free program compositor canvas, Audio Mixer is docked underneath that center canvas, and the right rail is again a Unity-style Inspector for the selected video layer's properties. Video Sources on the left now selects and navigates sources rather than carrying the property surface.","files":["src/Mimir.Runtime/MimirRuntime.cs","notes/fresh-workspace-handoff.md"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj; dotnet run --no-build --project src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj -- --scene-editor-smoke; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-unity-inspector-audio-bottom-headless.png"} +{"ts":"2026-05-31T23:09:31+01:00","type":"implementation","status":"ok","note":"Audio Mixer is now authored as a horizontal CultUI channel-strip bank beneath the compositor preview instead of a selected-stem inspector form. Each strip reads a live presentation audio feed slot, owns M/S/gain controls for that feed, and displays compact sync/chirp response status from MimirSynchronizationHub while the right rail remains the selected video-layer Inspector. The compositor preview is weighted ahead of the mixer dock. This is UI/control-surface wiring; DSP neutralization and sample-perfect alignment remain runtime/audio authority, not inspector-owned truth.","files":["src/Mimir.Runtime/MimirRuntime.cs"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj --no-restore; dotnet run --no-build --project src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj -- --presentation-control-smoke; dotnet run --no-build --project src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj -- --scene-editor-smoke; dotnet run --no-build --project src/Mimir.App/Mimir.App.csproj -- --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-horizontal-audio-dock-current-headless.png"} {"ts": "2026-05-31T22:52:47+01:00", "type": "implementation", "status": "ok", "note": "Extended MimirCameraFrustumCalibrationSolver beyond LED strips: it now also consumes MimirFeatureTrackFieldCandidate plus scene-space TrackId anchors, so PS Move sphere histories, sparse Eye tracks, and Eve-local marker tracks enter the same Starfire-owned frustum authority. BufferSmoke --frustum-calibration-smoke now proves five LED-spline frustums and five feature-track frustums for ps3-eye-0, ps3-eye-1, kiyo-pro-rgb, leap-stereo-ir, and eve-camera with mean clip error 0.000000."} {"ts": "2026-05-31T22:55:38+01:00", "type": "implementation", "status": "ok", "note": "Added mimir.local_frustum_hint_state.v1 as the CultMesh document for local witness frustum solves. It carries producer node, calibration id, candidate key, marker set id, per-camera pose/frustum snapshots, residuals, point counts, and confidence, so Eve/Nightwing can publish compact solved hints while Starfire remains canonical global placement authority."}