From 0cac6d32708fd8c454da7bdd37105b5b22dd6ebb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 12 May 2026 12:36:14 +0100 Subject: [PATCH] Unify debug UI tabs --- .../Audio/AquariumSynth.cs | 28 ++- .../Ui/AquariumUi.cs | 11 ++ src/Aquarium.Engine/AquariumHost.cs | 2 +- .../Audio/AquariumSynthHost.cs | 32 +++- src/Aquarium.Engine/Render/D3D12Renderer.cs | 173 ++++++++++++++++-- .../Render/IAquariumRenderer.cs | 3 + src/Aquarium.Engine/Render/Ui/DebugUi.cs | 2 +- src/Aquarium.Epiphany/AquariumRuntime.cs | 44 +++-- state/evidence.jsonl | 1 + state/map.yaml | 4 +- state/memory.json | 3 +- 11 files changed, 253 insertions(+), 50 deletions(-) diff --git a/src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs b/src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs index 6b34bb6..3ee5d0f 100644 --- a/src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs +++ b/src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs @@ -12,6 +12,29 @@ public sealed class AquariumSynthDocument public IReadOnlyList Patches => patches; + public static AquariumSynthDocument Combine(params AquariumSynthDocument[] documents) + { + var combined = new AquariumSynthDocument + { + Enabled = documents.Any(document => document.Enabled), + MasterGain = documents.Length == 0 ? 1.0f : documents.Max(document => document.MasterGain) + }; + foreach (var document in documents) + { + if (!document.Enabled) + { + continue; + } + + foreach (var patch in document.Patches) + { + combined.patches.Add(patch); + } + } + + return combined; + } + public AquariumSynthDocument Patch( string id, string script, @@ -51,8 +74,11 @@ public enum AquariumSynthPatchCompileState Failed } -public readonly record struct AquariumSynthTrigger(float IntervalSeconds, float PhaseSeconds = 0.0f) +public readonly record struct AquariumSynthTrigger(float IntervalSeconds, float PhaseSeconds = 0.0f, int FireRevision = 0) { public static AquariumSynthTrigger Repeat(float intervalSeconds, float phaseSeconds = 0.0f) => new(MathF.Max(0.001f, intervalSeconds), phaseSeconds); + + public static AquariumSynthTrigger Manual(int fireRevision) => + new(float.PositiveInfinity, 0.0f, fireRevision); } diff --git a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs index 562c4fc..0a2612d 100644 --- a/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs +++ b/src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs @@ -3,11 +3,14 @@ namespace Aquarium.Engine.Ui; public sealed class AquariumUiDocument { private readonly List panels = []; + private readonly List commands = []; public static AquariumUiDocument Empty { get; } = new(); public IReadOnlyList Panels => panels; + public IReadOnlyList Commands => commands; + public AquariumUiDocument Panel(string title, Action compose) { return Panel(title, 18.0f, 82.0f, 360.0f, compose); @@ -20,6 +23,12 @@ public sealed class AquariumUiDocument panels.Add(new AquariumUiPanel(title, left, top, width, controls)); return this; } + + public AquariumUiDocument Command(string name, Func, string> execute, string description = "") + { + commands.Add(new AquariumConsoleCommand(name, execute, description)); + return this; + } } public sealed record AquariumUiPanel( @@ -82,6 +91,8 @@ public sealed class AquariumUiPanelBuilder(List controls) public readonly record struct AquariumUiOption(int Value, string Label); +public sealed record AquariumConsoleCommand(string Name, Func, string> Execute, string Description = ""); + public abstract record AquariumUiControl(string Label, string? Tooltip, Func? IsVisible) { public bool Visible => IsVisible?.Invoke() ?? true; diff --git a/src/Aquarium.Engine/AquariumHost.cs b/src/Aquarium.Engine/AquariumHost.cs index a9a8b24..3659ab5 100644 --- a/src/Aquarium.Engine/AquariumHost.cs +++ b/src/Aquarium.Engine/AquariumHost.cs @@ -53,7 +53,7 @@ public static class AquariumHost ApplyRendererDebugInput(renderer, input); SyncRendererSettingsToRuntime(renderer, runtimeLoader.Runtime); runtimeLoader.Update(deltaSeconds, input); - synthHost.Update(runtimeLoader.Runtime.Synth, deltaSeconds); + synthHost.Update(AquariumSynthDocument.Combine(runtimeLoader.Runtime.Synth, renderer.DebugSynth), deltaSeconds); if (!ReferenceEquals(settingsRuntime, runtimeLoader.Runtime)) { settingsRuntime = runtimeLoader.Runtime; diff --git a/src/Aquarium.Engine/Audio/AquariumSynthHost.cs b/src/Aquarium.Engine/Audio/AquariumSynthHost.cs index 3181cb8..9412a7f 100644 --- a/src/Aquarium.Engine/Audio/AquariumSynthHost.cs +++ b/src/Aquarium.Engine/Audio/AquariumSynthHost.cs @@ -33,8 +33,22 @@ internal sealed class AquariumSynthHost : IDisposable runtime.StatusSink = patch.StatusSink; UpdatePatch(runtime, patch); PublishStatus(runtime, patch); + var pendingFireReady = false; + lock (runtime.Sync) + { + pendingFireReady = runtime.PendingFire && runtime.Compiled is not null && runtime.ReadyKey == runtime.DesiredKey; + if (pendingFireReady) + { + runtime.PendingFire = false; + } + } - if (ShouldTrigger(patch.Trigger, timeSeconds - deltaSeconds, timeSeconds)) + if (pendingFireReady) + { + Play(runtime, patch, synth.MasterGain); + } + + if (ShouldTrigger(runtime, patch.Trigger, timeSeconds - deltaSeconds, timeSeconds)) { Play(runtime, patch, synth.MasterGain); } @@ -137,6 +151,7 @@ internal sealed class AquariumSynthHost : IDisposable { if (runtime.Compiled is null || runtime.ReadyKey != runtime.DesiredKey) { + runtime.PendingFire = true; return; } @@ -195,8 +210,19 @@ internal sealed class AquariumSynthHost : IDisposable } } - private static bool ShouldTrigger(AquariumSynthTrigger trigger, float previousTime, float currentTime) + private static bool ShouldTrigger(PatchRuntime runtime, AquariumSynthTrigger trigger, float previousTime, float currentTime) { + if (trigger.FireRevision > 0 && trigger.FireRevision != runtime.LastFireRevision) + { + runtime.LastFireRevision = trigger.FireRevision; + return true; + } + + if (!float.IsFinite(trigger.IntervalSeconds)) + { + return false; + } + var interval = MathF.Max(trigger.IntervalSeconds, 0.001f); var previousBeat = MathF.Floor((previousTime - trigger.PhaseSeconds) / interval); var currentBeat = MathF.Floor((currentTime - trigger.PhaseSeconds) / interval); @@ -269,6 +295,8 @@ internal sealed class AquariumSynthHost : IDisposable public float ScriptChangedAt { get; set; } public CompiledFaustPatch? Compiled { get; set; } public Task? CompileTask { get; set; } + public int LastFireRevision { get; set; } + public bool PendingFire { get; set; } public Action? StatusSink { get; set; } public AquariumSynthPatchCompileState State => Status.State; public AquariumSynthPatchStatus Status { get; private set; } = new(id, AquariumSynthPatchCompileState.Idle, "idle", 0, 0.0); diff --git a/src/Aquarium.Engine/Render/D3D12Renderer.cs b/src/Aquarium.Engine/Render/D3D12Renderer.cs index 2adbd13..28deecc 100644 --- a/src/Aquarium.Engine/Render/D3D12Renderer.cs +++ b/src/Aquarium.Engine/Render/D3D12Renderer.cs @@ -1,3 +1,4 @@ +using Aquarium.Engine.Audio; using Aquarium.Engine.Input; using Aquarium.Engine.Render.Features; using Aquarium.Engine.Render.Graph; @@ -63,6 +64,10 @@ public sealed class D3D12Renderer : IAquariumRenderer new(9, "SdfObject Identity"), new(10, "SdfObject Steps"), ]; + private static readonly DebugUi.DebugUiOption[] SynthPresetOptions = AquariumSynth.Dsl.BuiltInScripts.PrimitiveGolfScripts() + .Select((preset, index) => new DebugUi.DebugUiOption(index, $"{preset.Family}/{preset.Name}")) + .ToArray(); + private static readonly (string Family, string Name, string Script)[] SynthPresets = AquariumSynth.Dsl.BuiltInScripts.PrimitiveGolfScripts().ToArray(); private readonly IDXGIFactory4 factory; private readonly ID3D12Device device; @@ -89,9 +94,19 @@ public sealed class D3D12Renderer : IAquariumRenderer private ID3D12PipelineState? resolvePipelineState; private readonly ID3D12Fence fence; private readonly AutoResetEvent fenceEvent = new(false); - private readonly DebugUi debugUi; - private IReadOnlyList clientUiPanels = []; + private DebugUi debugUi; private AquariumUiDocument? currentClientUi; + private int activeDebugTab; + private string[] debugTabTitles = ["Aquarium", "Terminal", "Synth"]; + private string terminalInput = "help"; + private readonly List terminalLines = ["Aquarium terminal ready. Type help."]; + private IReadOnlyList clientCommands = []; + private string synthPlaygroundScript = AquariumSynth.Dsl.BuiltInScripts.ClassicSfxrPrimitiveGolfScripts[0].Script; + private int synthPlaygroundPreset; + private int synthPlaygroundCompileRevision; + private int synthPlaygroundPlayRevision; + private float synthPlaygroundGain = 0.45f; + private AquariumSynthPatchStatus synthPlaygroundStatus = new("aquarium-playground", AquariumSynthPatchCompileState.Idle, "idle", 0, 0.0); private ID3D11Resource[] overlayWrappedBackBuffers = []; private DirectWriteOverlay[] overlays = []; private D3D12RenderTarget heightFieldRenderTarget; @@ -195,7 +210,7 @@ public sealed class D3D12Renderer : IAquariumRenderer CreateRenderTargetViews(); CreateBackBufferOverlays(); - debugUi = CreateDebugUi(); + debugUi = CreateDebugUi(AquariumUiDocument.Empty); heightFieldRenderTarget = CreateHeightFieldRenderTarget(); sceneRenderTarget = CreateSceneRenderTarget(); sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target"); @@ -247,19 +262,31 @@ public sealed class D3D12Renderer : IAquariumRenderer public bool HasPresentedReadyFrame => hasPresentedReadyFrame; + public AquariumSynthDocument DebugSynth => new AquariumSynthDocument + { + MasterGain = 1.0f, + Enabled = true + }.Patch( + "aquarium-playground", + synthPlaygroundScript, + AquariumSynthTrigger.Manual(synthPlaygroundPlayRevision), + synthPlaygroundGain, + synthPlaygroundCompileRevision, + "aquarium_playground", + status => synthPlaygroundStatus = status); + public void UpdateUi(InputState input, AquariumUiDocument clientUi) { - debugUi.Update(input); if (!ReferenceEquals(currentClientUi, clientUi)) { currentClientUi = clientUi; - clientUiPanels = clientUi.Panels.Select(DebugUi.FromContract).ToArray(); + clientCommands = clientUi.Commands; + debugTabTitles = ["Aquarium", "Terminal", "Synth", .. clientUi.Panels.Select(panel => panel.Title)]; + activeDebugTab = Math.Clamp(activeDebugTab, 0, debugTabTitles.Length - 1); + debugUi = CreateDebugUi(clientUi); } - foreach (var panel in clientUiPanels) - { - panel.Update(input); - } + debugUi.Update(input); } public void CycleRenderDebugMode() @@ -277,17 +304,125 @@ public sealed class D3D12Renderer : IAquariumRenderer settings = graphicsSettings.Normalized(); } - private DebugUi CreateDebugUi() + private DebugUi CreateDebugUi(AquariumUiDocument clientUi) { - return new DebugUi("Aquarium Debug") - .Panel(panel => panel + var ui = new DebugUi("Aquarium Debug") + .Panel(panel => + { + panel + .Section("Tabs") + .Button("Aquarium", () => SelectDebugTab(0), "Shows engine renderer controls.") + .Button("Terminal", () => SelectDebugTab(1), "Shows interactive debug command terminal.") + .Button("Synth", () => SelectDebugTab(2), "Shows the synth patch playground."); + for (var index = 0; index < clientUi.Panels.Count; index++) + { + var tabIndex = index + 3; + var title = clientUi.Panels[index].Title; + panel.Button(title, () => SelectDebugTab(tabIndex), $"Shows {title} debug controls."); + } + + panel .Section("View") - .Options("Render Debug", () => RenderDebugMode, value => RenderDebugMode = Math.Clamp(value, GraphicsSettings.MinRenderDebugMode, GraphicsSettings.MaxRenderDebugMode), RenderDebugOptions, "Selects the active renderer debug view.") - .Button("Reset View", () => RenderDebugMode = 0, "Returns to the final presented frame.") - .Section("HDR") - .Slider("Exposure", () => settings.SceneExposure, value => settings = (settings with { SceneExposure = Math.Clamp(value, GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure) }).Normalized(), GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure, "0.###", "Manual scene exposure before display transform.") - .Slider("Bloom Intensity", () => settings.BloomIntensity, value => settings = (settings with { BloomIntensity = Math.Clamp(value, GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity) }).Normalized(), GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity, "0.###", "Strength of pre-tonemap bloom energy.") - .Slider("Bloom Veil", () => settings.BloomVeilIntensity, value => settings = (settings with { BloomVeilIntensity = Math.Clamp(value, GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity) }).Normalized(), GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity, "0.###", "Low-frequency veil from bright HDR energy.")); + .Options("Render Debug", () => RenderDebugMode, value => RenderDebugMode = Math.Clamp(value, GraphicsSettings.MinRenderDebugMode, GraphicsSettings.MaxRenderDebugMode), RenderDebugOptions, "Selects the active renderer debug view.", () => activeDebugTab == 0) + .Button("Reset View", () => RenderDebugMode = 0, "Returns to the final presented frame.", () => activeDebugTab == 0) + .Section("HDR", () => activeDebugTab == 0) + .Slider("Exposure", () => settings.SceneExposure, value => settings = (settings with { SceneExposure = Math.Clamp(value, GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure) }).Normalized(), GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure, "0.###", "Manual scene exposure before display transform.", () => activeDebugTab == 0) + .Slider("Bloom Intensity", () => settings.BloomIntensity, value => settings = (settings with { BloomIntensity = Math.Clamp(value, GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity) }).Normalized(), GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity, "0.###", "Strength of pre-tonemap bloom energy.", () => activeDebugTab == 0) + .Slider("Bloom Veil", () => settings.BloomVeilIntensity, value => settings = (settings with { BloomVeilIntensity = Math.Clamp(value, GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity) }).Normalized(), GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity, "0.###", "Low-frequency veil from bright HDR energy.", () => activeDebugTab == 0) + .Section("Terminal", () => activeDebugTab == 1) + .Readout("Output", TerminalDisplay, "Recent command output.", () => activeDebugTab == 1) + .Text("Command", () => terminalInput, value => terminalInput = value, "Debug command input.", () => activeDebugTab == 1) + .Button("Run Command", ExecuteTerminalInput, "Runs the current debug command.", () => activeDebugTab == 1) + .Section("Synth Playground", () => activeDebugTab == 2) + .Options("Preset", () => synthPlaygroundPreset, SelectSynthPreset, SynthPresetOptions, "Loads a built-in synth patch.", () => activeDebugTab == 2) + .Readout("Compile", () => $"{synthPlaygroundStatus.State}: {synthPlaygroundStatus.Message}", "Faust compile status.", () => activeDebugTab == 2) + .Text("Patch", () => synthPlaygroundScript, value => synthPlaygroundScript = value, "Patch DSL source. Enter inserts ';'.", () => activeDebugTab == 2) + .Slider("Gain", () => synthPlaygroundGain, value => synthPlaygroundGain = Math.Clamp(value, 0.0f, 1.0f), 0.0f, 1.0f, "0.###", "Playground patch gain.", () => activeDebugTab == 2) + .Button("Compile", () => synthPlaygroundCompileRevision++, "Forces async Faust compile.", () => activeDebugTab == 2) + .Button("Play", () => { synthPlaygroundCompileRevision++; synthPlaygroundPlayRevision++; }, "Compiles and schedules the playground patch.", () => activeDebugTab == 2); + }); + for (var panelIndex = 0; panelIndex < clientUi.Panels.Count; panelIndex++) + { + var tabIndex = panelIndex + 3; + foreach (var control in clientUi.Panels[panelIndex].Controls) + { + ui.AddContractControl(control with { IsVisible = ComposeVisibility(control.IsVisible, () => activeDebugTab == tabIndex) }); + } + } + + return ui; + } + + private void SelectDebugTab(int index) + { + activeDebugTab = Math.Clamp(index, 0, Math.Max(0, debugTabTitles.Length - 1)); + } + + private static Func ComposeVisibility(Func? source, Func tabVisible) + { + return () => tabVisible() && (source?.Invoke() ?? true); + } + + private string TerminalDisplay() + { + return string.Join(" | ", terminalLines.TakeLast(4)); + } + + private void ExecuteTerminalInput() + { + var input = terminalInput.Trim(); + if (input.Length == 0) + { + return; + } + + terminalLines.Add($"> {input}"); + terminalInput = ""; + var parts = input.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + var command = parts[0]; + var args = parts.Skip(1).ToArray(); + if (string.Equals(command, "help", StringComparison.OrdinalIgnoreCase)) + { + var names = new[] { "help", "clear", "render" } + .Concat(clientCommands.Select(item => item.Name)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Order(StringComparer.OrdinalIgnoreCase); + terminalLines.Add(string.Join(", ", names)); + return; + } + + if (string.Equals(command, "clear", StringComparison.OrdinalIgnoreCase)) + { + terminalLines.Clear(); + return; + } + + if (string.Equals(command, "render", StringComparison.OrdinalIgnoreCase)) + { + if (args.Length > 0 && int.TryParse(args[0], out var mode)) + { + RenderDebugMode = Math.Clamp(mode, GraphicsSettings.MinRenderDebugMode, GraphicsSettings.MaxRenderDebugMode); + } + + terminalLines.Add($"render debug {RenderDebugMode}"); + return; + } + + var registered = clientCommands.FirstOrDefault(item => string.Equals(item.Name, command, StringComparison.OrdinalIgnoreCase)); + if (registered is not null) + { + terminalLines.Add(registered.Execute(args)); + return; + } + + terminalLines.Add($"unknown command: {command}"); + } + + private void SelectSynthPreset(int index) + { + synthPlaygroundPreset = Math.Clamp(index, 0, Math.Max(0, SynthPresets.Length - 1)); + synthPlaygroundScript = SynthPresets[synthPlaygroundPreset].Script; + synthPlaygroundCompileRevision++; } public void Render(AquariumFrame frame, int width, int height) @@ -574,7 +709,7 @@ public sealed class D3D12Renderer : IAquariumRenderer { var wrappedBackBuffer = overlayWrappedBackBuffers[frameIndex]; overlayOn12Device.AcquireWrappedResources([wrappedBackBuffer]); - overlays[frameIndex].Render(frame, RenderDebugMode, debugUi, clientUiPanels); + overlays[frameIndex].Render(frame, RenderDebugMode, debugUi, []); overlayOn12Device.ReleaseWrappedResources([wrappedBackBuffer]); overlayContext.Flush(); frameResources.BackBuffer.MarkState(ResourceStates.Present); diff --git a/src/Aquarium.Engine/Render/IAquariumRenderer.cs b/src/Aquarium.Engine/Render/IAquariumRenderer.cs index 39debd6..8e81711 100644 --- a/src/Aquarium.Engine/Render/IAquariumRenderer.cs +++ b/src/Aquarium.Engine/Render/IAquariumRenderer.cs @@ -1,4 +1,5 @@ using Aquarium.Engine.Input; +using Aquarium.Engine.Audio; using Aquarium.Engine.Ui; namespace Aquarium.Engine.Render; @@ -11,6 +12,8 @@ public interface IAquariumRenderer : IDisposable bool HasPresentedReadyFrame { get; } + AquariumSynthDocument DebugSynth { get; } + void UpdateUi(InputState input, AquariumUiDocument clientUi); void CycleRenderDebugMode(); diff --git a/src/Aquarium.Engine/Render/Ui/DebugUi.cs b/src/Aquarium.Engine/Render/Ui/DebugUi.cs index 8ea8dc2..3b4faa7 100644 --- a/src/Aquarium.Engine/Render/Ui/DebugUi.cs +++ b/src/Aquarium.Engine/Render/Ui/DebugUi.cs @@ -74,7 +74,7 @@ internal sealed class DebugUi return this; } - private void AddContractControl(AquariumUiControl control) + public void AddContractControl(AquariumUiControl control) { switch (control) { diff --git a/src/Aquarium.Epiphany/AquariumRuntime.cs b/src/Aquarium.Epiphany/AquariumRuntime.cs index 522f7ca..772cede 100644 --- a/src/Aquarium.Epiphany/AquariumRuntime.cs +++ b/src/Aquarium.Epiphany/AquariumRuntime.cs @@ -23,11 +23,6 @@ public sealed class AquariumRuntime : IAquariumRuntime private float secondsSinceStateSave; private bool graphicsSettingsDirty; private bool timePaused; - private string patchScript = "v w=sin f=440 g=.18 a=.002 s=.05 d=.35 pu=.28;v w=tri f=880 g=.04 s=.03 d=.28"; - private int patchRate = 4; - private int faustCompileRevision; - private AquariumSynthPatchStatus synthPatchStatus = new("epiphany-editor", AquariumSynthPatchCompileState.Idle, "idle", 0, 0.0); - public AquariumRuntime(AquariumRuntimeOptions options) { Options = options; @@ -53,12 +48,26 @@ public sealed class AquariumRuntime : IAquariumRuntime .Section("Runtime") .Toggle("Pause Time", () => timePaused, value => timePaused = value, "Stops Epiphany simulation time while leaving the renderer alive.") .Slider("Time", () => timeSeconds, value => timeSeconds = MathF.Max(0.0f, value), 0.0f, 720.0f, "0.0", "Scrubs Epiphany simulation time.") - .Button("Flush State", FlushState, "Writes current Epiphany runtime state to CultCache.") - .Section("Synth") - .Readout("Faust", () => $"{synthPatchStatus.State}: {synthPatchStatus.Message}", "Patch compilation status from Aquarium's bundled Faust toolchain.") - .Text("Patch", () => patchScript, value => patchScript = value, "Aquarium patch DSL. Enter inserts ';'.") - .Slider("Rate", () => patchRate, value => patchRate = Math.Clamp(value, 1, 12), 1, 12, "Triggers per 16 seconds.") - .Button("Compile Faust", () => faustCompileRevision++, "Forces an async Faust compile through Aquarium's bundled toolchain.")); + .Button("Flush State", FlushState, "Writes current Epiphany runtime state to CultCache.")) + .Command("pause", args => + { + timePaused = args.Count == 0 ? !timePaused : bool.TryParse(args[0], out var value) && value; + return $"pause {timePaused}"; + }, "Toggles or sets Epiphany simulation pause.") + .Command("time", args => + { + if (args.Count > 0 && float.TryParse(args[0], out var value)) + { + timeSeconds = MathF.Max(0.0f, value); + } + + return $"time {timeSeconds:0.###}"; + }, "Reads or sets Epiphany simulation time.") + .Command("flush", _ => + { + FlushState(); + return "state flushed"; + }, "Flushes Epiphany state to CultCache."); } public AquariumRuntimeOptions Options { get; } @@ -67,18 +76,7 @@ public sealed class AquariumRuntime : IAquariumRuntime public AquariumUiDocument Ui { get; } - public AquariumSynthDocument Synth => new AquariumSynthDocument - { - MasterGain = 0.42f, - Enabled = true - }.Patch( - "epiphany-editor", - patchScript, - AquariumSynthTrigger.Repeat(16.0f / Math.Max(patchRate, 1)), - 1.0f, - faustCompileRevision, - "epiphany_editor", - status => synthPatchStatus = status); + public AquariumSynthDocument Synth { get; } = AquariumSynthDocument.Empty; public AquariumFrame Frame => new(ViewFrame, cameraRig.Position, timeSeconds); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 306ad5d..ca6fa75 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -57,3 +57,4 @@ {"timestamp":"2026-05-12T06:15:00+01:00","topic":"synth-composition-contract","lesson":"Aquarium synth integration should mirror the UI boundary: clients declare patch scripts and trigger policy through AquariumSynthDocument, while Aquarium.Engine hosts preview playback and Faust export/compile requests. The current editor sound path is intentionally a pre-rendered preview; optimized realtime Faust DSP loading remains a separate engine-hosting pass, not something to smuggle into the DSL or client.","files":["src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs","src/Aquarium.Engine/Audio/AquariumSynthHost.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","state/memory.json"],"source":"synth API integration pass"} {"timestamp":"2026-05-12T06:45:00+01:00","topic":"bundled-libfaust-dsp-host","lesson":"Aquarium users should not need a local Faust install. Published builds now bundle a slim Tools/Faust runtime, and AquariumSynthHost uses libfaust's LLVM C ABI to compile patch DSL output into native DSP factories asynchronously. Generated C# is not the optimized path. The current SFX path renders one-shot buffers from compiled Faust instances; the next cut is a proper streaming mixer/device backend over the same compiled-DSP spine.","files":["src/Aquarium.Engine/Audio/AquariumSynthHost.cs","scripts/sync-faust-toolchain.ps1","scripts/publish-win-x64.ps1","src/Aquarium.Engine.Contracts/Audio/AquariumSynth.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","state/memory.json","state/map.yaml"],"source":"user direction on bundled Faust and maximum-performance compiled DSP"} {"timestamp":"2026-05-12T11:55:00+01:00","topic":"wasapi-audio-backend","lesson":"WinMM PlaySound was cut from Aquarium synth playback. Compiled Faust SFX buffers now feed a WASAPI shared-mode render thread with an engine-owned float voice queue and device-format conversion/resampling. This is the first real audio backend; future audio work should grow this mixer into streaming DSP voices, routing, meters, and parameter control rather than adding platform playback shortcuts.","files":["src/Aquarium.Engine/Audio/WasapiAudioDevice.cs","src/Aquarium.Engine/Audio/AquariumSynthHost.cs","state/memory.json","state/map.yaml"],"source":"audio backend purification pass"} +{"timestamp":"2026-05-12T12:35:00+01:00","topic":"unified-debug-panel","lesson":"F2 should open one Aquarium debug panel, not separate engine and client windows. Client AquariumUiDocument panels are folded into the same tabbed debug surface, clients can register terminal commands through AquariumUiDocument.Command, and the engine owns built-in Terminal plus Synth playground tabs. Future debug UI should extend this shared composition surface instead of spawning parallel panels.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Ui/DebugUi.cs","src/Aquarium.Engine.Contracts/Ui/AquariumUi.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","state/memory.json","state/map.yaml"],"source":"debug UI consolidation pass"} diff --git a/state/map.yaml b/state/map.yaml index c5fda04..8cdeb1c 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -79,8 +79,8 @@ renderer_state: - Agent SDF visual language is documented against Epiphany's published CultNet surfaces: identity from agent memory, motion from heartbeat, posture from role/coordinator/result surfaces, pressure from reorient/pressure surfaces, and expression through bounded orbit wandering plus CPU-visible gravity-well pulses. - SDF light buffer feeds Self emission and direct object lighting; future other Selves should join this light lane, not a generic field-instance table. - Studio2 PMREM and irradiance DDS cubemaps are loaded as D3D12 TextureCubes; PMREM serves roughness-mip specular, irradiance serves Lambertian diffuse IBL for non-metal bodies. - - DirectWrite/Direct2D debug UI panel with code-first controls bound to renderer state. - - AquariumSynthDocument exposes client-declared patch scripts, trigger cadence, gain, Faust compile revision, and compile status callbacks; Aquarium.Engine compiles patches asynchronously through bundled libfaust/LLVM and sends compiled DSP SFX buffers into a WASAPI shared-mode mixer. + - DirectWrite/Direct2D unified debug panel with tabs for Aquarium renderer controls, client-declared debug panels, terminal commands, and the synth playground. + - AquariumSynthDocument exposes client-declared patch scripts, trigger cadence, gain, Faust compile revision, manual fire revisions, and compile status callbacks; Aquarium.Engine compiles patches asynchronously through bundled libfaust/LLVM and sends compiled DSP SFX buffers into a WASAPI shared-mode mixer. - Global GraphicsSettings document feeding render debug, exposure, bloom intensity, and bloom veil. - Temporal resolve uses scene color, metadata, and control history only; dormant event history lanes are cut until a real producer and consumer contract exists. - Bundled blue-noise texture assets are retained for future dithering/noise work even though the removed medium path no longer samples them. diff --git a/state/memory.json b/state/memory.json index cb50f20..83beae4 100644 --- a/state/memory.json +++ b/state/memory.json @@ -68,7 +68,8 @@ "text_and_ui": [ "Overlay text uses DirectWrite/Direct2D after scene rendering. It is crisp final-pixel UI for debug surfaces, terminals, inspectors, and splash/status text.", "Aquarium UI controls follow the CultLib code-first binding style without Unity prefab assumptions: panels, sections, sliders, toggles, buttons, and option rows bound by explicit read/write delegates.", - "Aquarium.Engine.Contracts exposes AquariumUiDocument as the client-facing overlay composition surface. Clients declare panels and controls; Aquarium.Engine owns DirectWrite/Direct2D rendering, input dispatch, hover/active feedback, and panel presentation. Engine debug UI remains engine-owned and separate from client UI.", + "Aquarium.Engine.Contracts exposes AquariumUiDocument as the client-facing debug composition surface. Client panels are tabs inside the single Aquarium debug panel, not separate floating windows, and clients can register terminal commands through AquariumUiDocument.Command.", + "The unified F2 debug panel owns engine controls, client tabs, a command terminal, and the synth playground. Do not reintroduce separate Aquarium/Epiphany debug panels fighting for the same hotkey.", "Vortice.Mathematics.Rect uses x, y, width, height. UI code should use explicit RectFromEdges helpers when reasoning in edges.", "Debug UI feedback needs honest element-specific states: base, hover, and active. Sliders respond on track/fill and handle separately, keep geometry stable, and brighten by lerping accent colors toward white.", "Scene/diegetic labels should use renderer-owned MSDF/SDF billboards when they live in world space. Overlay text should not be shoved into HDR for convenience."