Consume AquaSynth patch compiler

This commit is contained in:
Meta Vens 2026-05-18 10:11:06 +01:00
commit 2093527c35
8 changed files with 24 additions and 20 deletions

Binary file not shown.

Binary file not shown.

View file

@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Vortice.Direct2D1" Version="3.8.3" />
<PackageReference Include="AquaSynth.Faust" Version="0.1.0-alpha.2" />
<PackageReference Include="AquaSynth.Faust" Version="0.1.0-alpha.3" />
<ProjectReference Include="..\Aquarium.Engine.Contracts\Aquarium.Engine.Contracts.csproj" />
<PackageReference Include="Vortice.Direct3D11" Version="3.8.3" />
<PackageReference Include="Vortice.Direct3D12" Version="3.8.3" />

View file

@ -8,7 +8,7 @@ internal sealed class AquariumSynthHost : IDisposable
private readonly Dictionary<string, PatchRuntime> patches = new(StringComparer.Ordinal);
private readonly WasapiAudioDevice audioDevice = new();
private readonly AquaSynthRenderSession renderSession = new(new AquaSynthNativeOptions(DspSourceDirectory: Path.Combine(AppContext.BaseDirectory, "Synth")));
private readonly AquaSynthPatchCompiler patchCompiler = new(new AquaSynthNativeOptions(DspSourceDirectory: Path.Combine(AppContext.BaseDirectory, "Synth")));
private float timeSeconds;
public void Update(AquariumSynthDocument synth, AquariumAudioDocument audio, float deltaSeconds)
@ -105,7 +105,7 @@ internal sealed class AquariumSynthHost : IDisposable
{
try
{
if (!renderSession.TryCompileScript(identity, out var compiled, out var error))
if (!patchCompiler.TryCompileScript(identity, out var compiled, out var error))
{
lock (runtime.Sync)
{
@ -115,7 +115,7 @@ internal sealed class AquariumSynthHost : IDisposable
runtime.FailedKey = compileKey;
runtime.SoundCache.Clear();
runtime.CompileTask = null;
runtime.SetStatus(AquariumSynthPatchCompileState.Failed, error ?? "AquaSynth render session unavailable", revision, timeSeconds);
runtime.SetStatus(AquariumSynthPatchCompileState.Failed, error ?? "AquaSynth patch compiler unavailable", revision, timeSeconds);
}
Console.WriteLine($"Aquarium synth patch `{patchId}` AquaSynth compile failed: {error}");
@ -242,7 +242,7 @@ internal sealed class AquariumSynthHost : IDisposable
}
audioDevice.Dispose();
renderSession.Dispose();
patchCompiler.Dispose();
}
private sealed class PatchRuntime(string id)

View file

@ -69,9 +69,9 @@
{"timestamp":"2026-05-12T23:08:00+01:00","topic":"synth-test-ownership","lesson":"Aquarium must not own synth reference truth. Engine tests may smoke-test the runtime synth host boundary, but synth correctness belongs in AquariumSynthCSharp so Aquarium can keep iterating while the synth library is under construction.","files":["tests/Aquarium.Engine.Tests/SynthPlaybackTests.cs","tests/Aquarium.Engine.Tests/Aquarium.Engine.Tests.csproj","state/evidence.jsonl"],"source":"user questioned synth testing ownership"}
{"timestamp":"2026-05-13T00:26:00+01:00","topic":"synth-package-boundary","lesson":"Aquarium must not build against the live AquariumSynthCSharp project while a synth agent is mutating it. Consume AquariumSynth.Dsl as a pinned repo-local NuGet package and update that package only by deliberate version bump.","files":["NuGet.config","packages/AquariumSynth.Dsl.0.1.0-aquarium.1.nupkg","src/Aquarium.Engine/Aquarium.Engine.csproj","scripts/update-synth-package.ps1","state/map.yaml","state/memory.json","state/scratch.md","state/evidence.jsonl"],"source":"user asked whether synth-agent work can break Aquarium builds"}
{"timestamp":"2026-05-17T15:15:00+01:00","topic":"aquasynth-native-audio-ownership","lesson":"Aquarium should host completed synth products, not own AquaSynth parsing, Faust emission, native libfaust factory creation, render duration estimation, compile keys, DSP source artifacts, or sample-buffer rendering. Those responsibilities now live in AquaSynth.Faust through AquaSynthNativeCompiler; AquariumSynthHost keeps scheduling, debounce/status, cache playback, and WASAPI output.","files":["src/Aquarium.Engine/Audio/AquariumSynthHost.cs","src/Aquarium.Engine/Aquarium.Engine.csproj","scripts/update-synth-package.ps1","scripts/publish-win-x64.ps1","state/map.yaml","state/memory.json"],"source":"user asked to finish taking over Aquarium's current audio rendering ownership so the engine does not concern itself with synth internals"}
{"timestamp":"2026-05-17T15:45:00+01:00","topic":"aquasynth-package-split","lesson":"Aquarium consumes AquaSynth.Faust, not a catch-all AquaSynth.Dsl package. AquaSynth.Faust carries the runtime/toolchain surface and pulls AquaSynth.Core transitively for the built-in patch editor's parser/model/built-in script needs.","files":["src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-aquasynth.1.nupkg","packages/AquaSynth.Faust.0.1.0-aquasynth.1.nupkg","scripts/update-synth-package.ps1","scripts/publish-win-x64.ps1","state/map.yaml","state/memory.json","state/scratch.md"],"source":"user pointed out .Dsl no longer described the package and confirmed Aquarium still needs DSL through the Faust dependency"}
{"timestamp":"2026-05-17T16:05:00+01:00","topic":"aquasynth-render-session-boundary","lesson":"AquariumSynthHost no longer exposes a static native render smoke helper or calls AquaSynthNativeCompiler.TryLoad. AquaSynth.Faust owns lazy compiler loading through AquaSynthRenderSession; Aquarium holds that session and only schedules compile/playback requests.","files":["src/Aquarium.Engine/Audio/AquariumSynthHost.cs","tests/Aquarium.Engine.Tests/SynthPlaybackTests.cs","src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-aquasynth.2.nupkg","packages/AquaSynth.Faust.0.1.0-aquasynth.2.nupkg"],"source":"user called out AquariumSynthHost keeping compiler load and TryRenderScriptWithNativeFaust as a convenience exemption"}
{"timestamp":"2026-05-17T16:15:00+01:00","topic":"aquasynth-semver","lesson":"Aquarium now pins AquaSynth packages at `0.1.0-alpha.2`. Keep AquaSynth package versions as normal SemVer prereleases; do not use repo-name suffixes such as `0.1.0-aquasynth.2`.","files":["src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-alpha.2.nupkg","packages/AquaSynth.Faust.0.1.0-alpha.2.nupkg","state/map.yaml"],"source":"user noted that 0.1.0-aquasynth.2 was an exciting new take on semantic versioning"}
{"timestamp":"2026-05-17T15:45:00+01:00","topic":"aquasynth-package-split","lesson":"Aquarium consumes AquaSynth.Faust, not a catch-all AquaSynth.Dsl package. AquaSynth.Faust carries the runtime/toolchain surface and pulls AquaSynth.Core transitively for the built-in patch editor's parser/model/built-in script needs.","files":["src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-alpha.3.nupkg","packages/AquaSynth.Faust.0.1.0-alpha.3.nupkg","scripts/update-synth-package.ps1","scripts/publish-win-x64.ps1","state/map.yaml","state/memory.json","state/scratch.md"],"source":"user pointed out .Dsl no longer described the package and confirmed Aquarium still needs DSL through the Faust dependency"}
{"timestamp":"2026-05-18T10:35:00+01:00","topic":"aquasynth-render-session-boundary","lesson":"AquariumSynthHost does not deserve to hold a live AquaSynthRenderSession. AquaSynth.Faust owns live patch compilation through AquaSynthPatchCompiler; Aquarium owns only debounce, trigger scheduling, rendered-buffer caching, and WASAPI playback.","files":["src/Aquarium.Engine/Audio/AquariumSynthHost.cs","tests/Aquarium.Engine.Tests/SynthPlaybackTests.cs","src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-alpha.3.nupkg","packages/AquaSynth.Faust.0.1.0-alpha.3.nupkg"],"source":"user challenged the host's remaining Faust authority after AquaSynth already owned patch meaning and native render proof"}
{"timestamp":"2026-05-17T16:15:00+01:00","topic":"aquasynth-semver","lesson":"Aquarium pins AquaSynth packages on the `0.1.0-alpha.N` prerelease line. Keep AquaSynth package versions as normal SemVer prereleases; do not use repo-name suffixes such as `0.1.0-aquasynth.2`.","files":["src/Aquarium.Engine/Aquarium.Engine.csproj","packages/AquaSynth.Core.0.1.0-alpha.3.nupkg","packages/AquaSynth.Faust.0.1.0-alpha.3.nupkg","state/map.yaml"],"source":"user noted that 0.1.0-aquasynth.2 was an exciting new take on semantic versioning"}
{"timestamp":"2026-05-13T00:40:00+01:00","topic":"generic-sdf-field-ids","lesson":"Aquarium shared SDF code must not special-case Epiphany object identities. SDF field ids are generic base-plus-object-index metadata; Self, Cursor, and role meaning stay in Epiphany's object table and shaders, while temporal reprojection uses uploaded AquariumSdfObject current/previous centers for every SDF object.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Epiphany/EpiphanySceneBuilder.cs","docs/epiphany-agent-sdf-visual-language.md","state/memory.json"]}
{"timestamp":"2026-05-13T01:05:00+01:00","topic":"sdf-metallic-roughness-pbr","lesson":"SDF surfaces now use the industry-standard metallic-roughness material language: baseColor, metallic, roughness, and emission. The shared shader derives dielectric F0, metal-tinted specular F0, non-metal diffuse color, direct Cook-Torrance GGX specular, Fresnel-gated Lambert diffuse, diffuse irradiance IBL, and roughness-mip PMREM specular from those fields.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Epiphany/Shaders","docs/epiphany-agent-sdf-visual-language.md","state/memory.json"],"source":"Khronos glTF 2.0 metallic-roughness material model; Google Filament material model notes"}
{"timestamp":"2026-05-13T01:45:00+01:00","topic":"imagination-topology-spec","lesson":"Imagination's visual spec needs topology, not just evocative nouns. The target is a luminous opal seed wrapped by broad translucent curling ribbon-sheets with traced raised rims, visible interior apertures, vertical fountain bias, sparse candidate filaments/sparks, and cool backlog shadow. Trefoil/tube curves may define rim paths, but tubes alone do not satisfy the petal form.","files":["docs/epiphany-agent-sdf-visual-language.md","state/memory.json"],"source":"user supplied imagegen reference and noted current output did not match the imagined impossible flower"}

View file

@ -56,8 +56,8 @@ current_model:
dependencies:
cult_math: E:\Projects\CultMath
cult_lib: E:\Projects\CultLib
aqua_synth_faust: NuGet package AquaSynth.Faust 0.1.0-alpha.2 from repo-local packages feed
aqua_synth_core: transitive NuGet package AquaSynth.Core 0.1.0-alpha.2 from repo-local packages feed
aqua_synth_faust: NuGet package AquaSynth.Faust 0.1.0-alpha.3 from repo-local packages feed
aqua_synth_core: transitive NuGet package AquaSynth.Core 0.1.0-alpha.3 from repo-local packages feed
docs:
doctrine: docs/aquarium-engine-doctrine.md
engine_client_boundary: docs/engine-client-boundary.md
@ -103,7 +103,7 @@ renderer_state:
- DirectWrite/Direct2D debug panels own body scrolling and clipping; overflowing client controls must stay inside the panel with a visible scrollbar.
- Client-declared UI panels are folded into the unified Debug tab strip by default; panels that opt into proximity fading render as independent floating overlays. Floating panels can right-anchor with negative left offsets and fade to 10% opacity when the mouse is not near.
- Aquarium UI exposes generic selectable tree rows with disclosure arrows. Clients use them for hierarchy navigation without teaching DebugUi about client-specific spatial domains.
- Aquarium exposes an optional synth/audio hosting boundary through AquariumSynthDocument; Aquarium consumes AquaSynth.Faust as a pinned repo-local NuGet package so synth-agent construction cannot break Aquarium builds until the package is intentionally updated. AquaSynth.Core arrives transitively for patch editor/parser surfaces.
- Aquarium exposes an optional synth/audio hosting boundary through AquariumSynthDocument; Aquarium consumes AquaSynth.Faust as a pinned repo-local NuGet package so synth-agent construction cannot break Aquarium builds until the package is intentionally updated. AquaSynth.Core arrives transitively for patch editor/parser surfaces. AquaSynth owns live patch compilation and native Faust factory lifetime; Aquarium owns debounce, playback scheduling, cached rendered buffers, and WASAPI output.
- Aquarium now exposes a generic queued PCM audio lane through AquariumAudioDocument. Epiphany Face voice uses it to play streamed Codex realtime output without reaching into the engine's WASAPI internals.
- Epiphany owns the first native Face realtime voice session controller. It stores loopback app-server URI, thread id, voice, and speech prompt in CultCache live state; starts `thread/realtime/start` with audio output over the experimental Codex app-server WebSocket JSON-RPC edge; sends text utterances; reflects ephemeral transcript/error/audio counters in the debug UI; and treats speech as transient Face surface, not durable memory or project authority.
- Face voice routing is no longer a singleton. Epiphany persists typed FaceVoiceEndpoint rows with id, display name, thread id, voice, prompt, enabled flag, XY proximity anchor, and an audible-radius scale. FaceVoiceRouter uses proximity only to choose the addressed endpoint for user input; enabled endpoints can all run concurrently so active rumination loops may speak regardless of listener distance. Distance shapes PCM output gain and stereo pan through AquariumAudioDocument/WasapiAudioDevice.

View file

@ -95,8 +95,8 @@
"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."
],
"audio": [
"Aquarium exposes an optional audio/synth hosting boundary through contracts; clients declare intent, Aquarium schedules playback and owns device/toolchain integration.",
"Aquarium consumes AquaSynth.Faust as a pinned repo-local NuGet package, with AquaSynth.Core arriving transitively for the built-in patch editor/parser surface. AquaSynth owns synth internals, native Faust compilation, generated DSP manifests, and tests; update the package only by deliberate version bump so visual/renderer work can continue while synth construction changes underneath."
"Aquarium exposes an optional audio/synth hosting boundary through contracts; clients declare intent, Aquarium schedules playback and owns device output.",
"Aquarium consumes AquaSynth.Faust as a pinned repo-local NuGet package, with AquaSynth.Core arriving transitively for the built-in patch editor/parser surface. AquaSynth owns synth internals, live patch compilation, native Faust factory lifetime, generated DSP manifests, and tests; AquariumSynthHost owns debounce, trigger scheduling, rendered-buffer caching, and WASAPI playback. Update the package only by deliberate version bump so visual/renderer work can continue while synth construction changes underneath."
],
"state_and_reload": [
"CultCache is the client memory organ. Runtime state, camera, renderer knobs, body state, UI state, and future Epiphany connection state should be typed Cult documents.",

View file

@ -6,7 +6,7 @@ namespace Aquarium.Engine.Tests;
public sealed class SynthPlaybackTests
{
[Fact]
public void AquaSynthRenderSessionCanRenderAudiblePatchForEnginePlayback()
public void AquaSynthPatchCompilerCanRenderAudiblePatchForEnginePlayback()
{
const string script = """
voice
@ -18,8 +18,8 @@ public sealed class SynthPlaybackTests
decay=0.12
""";
using var session = new AquaSynthRenderSession();
if (!session.TryRenderScript("engine_synth_smoke", script, 1.0f, out var samples, out var error))
using var compiler = new AquaSynthPatchCompiler();
if (!compiler.TryCompileScript(new AquaSynthCompileIdentity("engine_synth_smoke", "engine_synth_smoke", script), out var patch, out var error))
{
if (error?.Contains("Faust toolchain not found", StringComparison.OrdinalIgnoreCase) == true ||
error?.Contains("Faust DLL not found", StringComparison.OrdinalIgnoreCase) == true)
@ -27,11 +27,15 @@ public sealed class SynthPlaybackTests
return;
}
Assert.Fail($"AquaSynth render session failed to render a tiny patch: {error}");
Assert.Fail($"AquaSynth patch compiler failed to render a tiny patch: {error}");
}
Assert.True(samples.Length > 2048, $"Rendered too few samples: {samples.Length}.");
Assert.Contains(samples, sample => MathF.Abs(sample) > 0.001f);
Assert.InRange(samples.Max(sample => MathF.Abs(sample)), 0.001f, 1.0f);
using (patch)
{
var samples = patch!.Render(1.0f);
Assert.True(samples.Length > 2048, $"Rendered too few samples: {samples.Length}.");
Assert.Contains(samples, sample => MathF.Abs(sample) > 0.001f);
Assert.InRange(samples.Max(sample => MathF.Abs(sample)), 0.001f, 1.0f);
}
}
}