Build Zyn reference oracle

This commit is contained in:
Meta Vens 2026-05-15 00:03:33 +01:00
commit 9372e5bd11
6 changed files with 147 additions and 12 deletions

View file

@ -65,3 +65,4 @@
{"kind":"voice_rate_level_envelopes","lesson":"The existing readable `env=rl rates=... levels=... curves=... gate=...` contour now applies to normal voices and therefore to named layer defaults, not only operator graphs. This gives PAD and vocal Zyn rebuilds staged non-ADSR onset/release shape while preserving the invariant that Note owns gate timing and envelope data owns level shape. Arbitrary Zyn free-envelope point curves remain missing pressure.","source":"Zyn staged voice envelope DSL slice on 2026-05-14"}
{"kind":"pad_spectral_cloud","lesson":"PAD-style layers now have `spectrum layer=... root=... spread=... partials=ratio:gain,...`, recorded as `SpectralBank` and generated as PADsynth-style FFT tables: frequency-domain harmonic spreading, deterministic random phase, one inverse FFT, normalization, then Faust waveform/rdtable playback before ordinary voice treatment. This gives PAD texture rebuilds a real spectral source authority without inflating the voice graph; roots/spreads/partials are authoring-time table shape, not runtime controls. It still does not claim full Zyn PAD harmonic-profile/randomness/pitch-zone behavior.","source":"Zyn PAD spectral-cloud DSL slice on 2026-05-14"}
{"kind":"zyn_reference_oracle","lesson":"ZynAddSubFX source is pinned as GPL test/development material under `external/zynaddsubfx` at 3ab608c432996ba4d582176572c0b0f82328c825. Treat it like dexed-py: a parity oracle for tests and artifacts, not Aquarium implementation, runtime dependency, or NuGet package content. Before further Zyn DSL golf, build a test-only PAD renderer/wrapper from this source and compare Aquarium rebuilds against actual Zyn behavior.","source":"Zyn source pinning for parity on 2026-05-14"}
{"date":"2026-05-14","area":"zyn-reference","lesson":"Pinned Zyn can build on Windows through MSYS2/MinGW when GUI/plugins are disabled, tests are enabled, Werror is off, and the stale non-async MiddleWare Part constructor call is patched. Apply Zyn compatibility patches to ignored artifact source copies, not the clean pinned submodule.","evidence":"tools/zyn-reference/build-zyn-reference.ps1 copies external/zynaddsubfx to artifacts/zyn-source-msys, applies tools/zyn-reference/patches/0001-msys-part-constructor.patch, builds PadNoteTest, and ctest -R PadNoteTest passes."}

View file

@ -17,6 +17,8 @@ surfaces:
reference_roadmap: docs/reference-synth-roadmap.md
dx7_public_domain_fixtures: tests/AquariumSynth.Dsl.Tests/Fixtures/Dx7/PublicDomain
zyn_reference_source: external/zynaddsubfx
zyn_reference_build_script: tools/zyn-reference/build-zyn-reference.ps1
zyn_reference_build_patch: tools/zyn-reference/patches/0001-msys-part-constructor.patch
zyn_project_fixtures: tests/AquariumSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored
package: AquariumSynth.Dsl 0.1.0-aquarium.1
modules:

View file

@ -84,9 +84,9 @@
"next": "Use the now-validated algorithm-8 route scale, transpose lowering, and fixed-frequency lowering as fixed inputs while isolating remaining community-voice timbre mismatch, then expand to broader public-domain banks."
},
"zyn_reference_path": {
"status": "Initial ZynInstrumentReader parses plain XML and gzip-compressed .xiz-shaped XML from project-authored fixtures into ZynInstrument records and ReferencePatch features. First Zyn-style Aquarium rebuilds exist for additive lead, PAD texture, and vocal/formant layer. `ZynInstrumentSurvey` can rank .xiz directories by feature pressure. Named `layer` declarations provide the first Zyn-driven DSL abstraction; additive `harmonics`, PAD `spectrum`, and staged `env=rl` voice envelopes now attach to those layers.",
"lesson": "Start Zyn as structural classification, not translation. Upstream Zyn presets live in a separate bank submodule and should not be vendored until license/provenance is explicit. The ZynAddSubFX engine source is now pinned as GPL test/development material under `external/zynaddsubfx` at 3ab608c432996ba4d582176572c0b0f82328c825; use it as a parity oracle only, never as Aquarium runtime or NuGet package content. The hardened reader parses the observed upstream instrument bank at commit e9f64a9: 1358/1358 .xiz files. The worst target is `olivers-100/0032-Drum Kit.xiz`, with 16 enabled kit items, mixed ADD/SUB/PAD engines, 106 envelopes, 25 free envelopes, 73 LFOs, 37 filters, and 3 formant filters. The first rebuilds show Aquarium can sketch small Zyn fixtures with existing voices/macros/formants/noise, and the upstream survey correctly pushed named kit/layer routing first. `layer` owns name, engine tag, optional key range metadata, default gain, and effect-send labels while lowering to ordinary voices. `harmonics` owns authored ratio/gain partial banks under those layers. `spectrum` owns PAD-style root/spread/partial clouds under those layers and generates PADsynth-style FFT wavetables with frequency-domain spreading, deterministic random phase, and one inverse FFT before ordinary voice treatment. Staged `env=rl` now applies to voices as well as operators, preserving Note as gate authority and envelope data as level-shape authority. Aquarium still does not claim Zyn ADDsynth phase/bandwidth details, full Zyn PAD harmonic-profile/randomness/pitch-zone behavior, arbitrary free-envelope point curves, or richer formant morphing.",
"next": "Build a test-only Zyn PAD reference renderer/wrapper from the pinned source before further Zyn DSL golf."
"status": "Initial ZynInstrumentReader parses plain XML and gzip-compressed .xiz-shaped XML from project-authored fixtures into ZynInstrument records and ReferencePatch features. First Zyn-style Aquarium rebuilds exist for additive lead, PAD texture, and vocal/formant layer. `ZynInstrumentSurvey` can rank .xiz directories by feature pressure. Named `layer` declarations provide the first Zyn-driven DSL abstraction; additive `harmonics`, PAD `spectrum`, and staged `env=rl` voice envelopes now attach to those layers. The pinned Zyn source now builds as a test-only MSYS2/MinGW oracle through `tools/zyn-reference/build-zyn-reference.ps1`, which patches an ignored artifact source copy and proves `PadNoteTest`.",
"lesson": "Start Zyn as structural classification, not translation. Upstream Zyn presets live in a separate bank submodule and should not be vendored until license/provenance is explicit. The ZynAddSubFX engine source is pinned as GPL test/development material under `external/zynaddsubfx` at 3ab608c432996ba4d582176572c0b0f82328c825; use it as a parity oracle only, never as Aquarium runtime or NuGet package content. Zyn build fixes belong in `tools/zyn-reference/patches/` and apply to ignored artifact copies, not the clean pinned submodule. The hardened reader parses the observed upstream instrument bank at commit e9f64a9: 1358/1358 .xiz files. The worst target is `olivers-100/0032-Drum Kit.xiz`, with 16 enabled kit items, mixed ADD/SUB/PAD engines, 106 envelopes, 25 free envelopes, 73 LFOs, 37 filters, and 3 formant filters. The first rebuilds show Aquarium can sketch small Zyn fixtures with existing voices/macros/formants/noise, and the upstream survey correctly pushed named kit/layer routing first. `layer` owns name, engine tag, optional key range metadata, default gain, and effect-send labels while lowering to ordinary voices. `harmonics` owns authored ratio/gain partial banks under those layers. `spectrum` owns PAD-style root/spread/partial clouds under those layers and generates PADsynth-style FFT wavetables with frequency-domain spreading, deterministic random phase, and one inverse FFT before ordinary voice treatment. Staged `env=rl` now applies to voices as well as operators, preserving Note as gate authority and envelope data as level-shape authority. Aquarium still does not claim Zyn ADDsynth phase/bandwidth details, full Zyn PAD harmonic-profile/randomness/pitch-zone behavior, arbitrary free-envelope point curves, or richer formant morphing.",
"next": "Implement a test-only Zyn PAD renderer/wrapper on top of the proven build, emit reference audio or tables, then compare Aquarium `spectrum` output before further Zyn DSL golf."
},
"note_and_envelope_model": {
"rule": "Notes own frequency, gate duration, and host/MIDI source. Envelopes own ADSR level shape.",
@ -100,8 +100,8 @@
"binding_rule": "Parameter binding uses field-site references such as `lpf=@/macro/brightness` and `/opgraphs/0/operators/2/level`; the field owns meaning and the parameter owns the runtime value. Avoid target-routing semantics unless a new graph authority is deliberately mapped."
},
"last_verified": {
"command": "AQUARIUM_DX7_PYTHON=<bundled python> dotnet test AquariumSynthCSharp.slnx --no-restore",
"result": "95 passed; Zyn source is pinned as test-only parity oracle and package boundary remains clean",
"commit": "pending Zyn reference oracle pin"
"command": "powershell -NoProfile -ExecutionPolicy Bypass -File tools\\zyn-reference\\build-zyn-reference.ps1; dotnet test AquariumSynthCSharp.slnx --no-restore",
"result": "Zyn source copied to ignored artifact tree, patched, built with MSYS2/MinGW, PadNoteTest passed; C# suite 95 passed and package boundary remains clean",
"commit": "pending Zyn oracle build script"
}
}

View file

@ -1,6 +1,6 @@
project: AquariumSynthCSharp
spine_version: 1
updated: 2026-05-14T21:10:00+01:00
updated: 2026-05-14T21:45:00+01:00
prime_directive: >
Build coherent synth machinery. References exist to reveal missing structure,
@ -24,6 +24,7 @@ current_mechanism:
dx7_reference_fixtures: tests/AquariumSynth.Dsl.Tests/Fixtures/Dx7/PublicDomain
dx7_reference_renderer_tests: tests/AquariumSynth.Dsl.Tests/Dx7ReferenceParityTests.cs
zyn_reference_source: external/zynaddsubfx
zyn_reference_build_script: tools/zyn-reference/build-zyn-reference.ps1
zyn_reference_reader: src/AquariumSynth.Dsl/ZynInstrument.cs
zyn_project_fixtures: tests/AquariumSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored
reference_rebuilds: src/AquariumSynth.Dsl/ReferenceRebuilds.cs
@ -99,9 +100,9 @@ reference_targets:
priority: 2
purpose: "Additive, subtractive, PAD, formant, kit, and layered-instrument pressure test."
source: "https://github.com/zynaddsubfx/zynaddsubfx"
status: "Initial ZynInstrumentReader reads plain or gzip-compressed .xiz XML from project-authored fixtures and classifies active ADD/SUB/PAD engines, enabled kit items, layering, envelopes, free envelopes, LFOs, filters, formants, and effects as ReferencePatch features. First Aquarium rebuilds exist for additive lead, PAD texture, and vocal/formant layer and now use named `layer` declarations. Additive rebuilds can use `harmonics` banks attached to layers, PAD rebuilds can use `spectrum` PADsynth-style FFT wavetable banks attached to layers, and PAD/vocal rebuilds use staged voice `env=rl` envelopes through layer defaults. ZynAddSubFX source is now pinned under `external/zynaddsubfx` at 3ab608c432996ba4d582176572c0b0f82328c825 for test-only parity work. A non-vendored upstream bank survey parsed 1358/1358 .xiz files and identified named kit/layer routing as the first owner abstraction."
status: "Initial ZynInstrumentReader reads plain or gzip-compressed .xiz XML from project-authored fixtures and classifies active ADD/SUB/PAD engines, enabled kit items, layering, envelopes, free envelopes, LFOs, filters, formants, and effects as ReferencePatch features. First Aquarium rebuilds exist for additive lead, PAD texture, and vocal/formant layer and now use named `layer` declarations. Additive rebuilds can use `harmonics` banks attached to layers, PAD rebuilds can use `spectrum` PADsynth-style FFT wavetable banks attached to layers, and PAD/vocal rebuilds use staged voice `env=rl` envelopes through layer defaults. ZynAddSubFX source is pinned under `external/zynaddsubfx` at 3ab608c432996ba4d582176572c0b0f82328c825 for test-only parity work, and `tools/zyn-reference/build-zyn-reference.ps1` now builds an ignored patched source copy with MSYS2/MinGW and proves `PadNoteTest`. A non-vendored upstream bank survey parsed 1358/1358 .xiz files and identified named kit/layer routing as the first owner abstraction."
first_slice:
- "Build a test-only Zyn PAD reference renderer/wrapper from the pinned source before further Zyn DSL golf."
- "Implement a test-only Zyn PAD renderer/wrapper on top of the proven source build before further Zyn DSL golf."
- "Use named layers as the owner before promoting richer formant morphing syntax."
- "Additive harmonic banks, PAD spectral clouds, and staged voice envelopes now exist; prove any next syntax across more than one target with parity, not parser-only fixtures."
- "Do not add all remaining pressures at once."
@ -137,9 +138,11 @@ next_agent_start_here:
Named `layer` declarations own source identity, additive `harmonics` banks
attach to those layers, PAD `spectrum` banks attach to those layers as
PADsynth-style FFT wavetable sources, and staged `env=rl` envelopes now
work on normal voices/layer defaults. Next
pressure is richer formant/vowel morphing. Prove it across more than one
target, and leave DX7 alone unless a regression test fails.
work on normal voices/layer defaults. The pinned Zyn source now builds
through `tools/zyn-reference/build-zyn-reference.ps1` using an ignored
patched artifact copy. Next pressure is a test-only PAD renderer/wrapper
that emits reference audio or tables for Aquarium `spectrum` parity, then
richer formant/vowel morphing can resume.
must_read:
- AGENTS.md
- docs/audio-doctrine.md
@ -152,6 +155,17 @@ next_agent_start_here:
- "dotnet test AquariumSynthCSharp.slnx --no-restore"
completed_slices:
- date: 2026-05-14
summary: >
Built the pinned ZynAddSubFX source as a test-only MSYS2/MinGW parity
oracle without dirtying the checked-in submodule. The build script copies
`external/zynaddsubfx` to ignored `artifacts/zyn-source-msys`, applies a
repo-owned compatibility patch for the stale `Part` constructor call,
configures GUI/plugins off with tests on and `Werror=OFF`, builds
`PadNoteTest`, and runs the CTest target. The next rung is a small
reference renderer/wrapper that emits PAD audio or tables for Aquarium
`spectrum` parity.
verification: "powershell -NoProfile -ExecutionPolicy Bypass -File tools\\zyn-reference\\build-zyn-reference.ps1: PadNoteTest passed"
- date: 2026-05-14
summary: >
Pinned ZynAddSubFX source as a GPL test/development reference under

View file

@ -0,0 +1,101 @@
param(
[string]$MsysRoot = "C:\msys64",
[string]$BuildDir = "artifacts/zyn-reference-build-msys",
[string]$SourceDir = "artifacts/zyn-source-msys"
)
$ErrorActionPreference = "Stop"
if (Get-Variable PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
}
function Convert-ToMsysPath([string]$Path) {
$resolved = [System.IO.Path]::GetFullPath($Path)
if ($resolved -notmatch "^[A-Za-z]:\\") {
throw "Cannot convert path to MSYS form: $resolved"
}
$drive = $resolved.Substring(0, 1).ToLowerInvariant()
$tail = $resolved.Substring(2).Replace("\", "/")
return "/$drive$tail"
}
function Invoke-GitProbe([string[]]$Arguments) {
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
& git @Arguments 1>$null 2>$null
return $LASTEXITCODE
}
finally {
$ErrorActionPreference = $oldPreference
}
}
$repoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\.."))
$zynRoot = Join-Path $repoRoot "external\zynaddsubfx"
$workSource = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $SourceDir))
$patchPath = Join-Path $PSScriptRoot "patches\0001-msys-part-constructor.patch"
$bash = Join-Path $MsysRoot "usr\bin\bash.exe"
if (-not (Test-Path $bash)) {
throw "MSYS2 bash not found at $bash"
}
if (-not (Test-Path (Join-Path $zynRoot "src\Params\PADnoteParameters.cpp"))) {
throw "ZynAddSubFX submodule is not initialized at $zynRoot"
}
& git -C $zynRoot submodule update --init rtosc
if ($LASTEXITCODE -ne 0) {
throw "Failed to initialize Zyn rtosc submodule."
}
$sourceParent = Split-Path $workSource -Parent
if (-not (Test-Path $sourceParent)) {
New-Item -ItemType Directory -Path $sourceParent | Out-Null
}
& robocopy $zynRoot $workSource /MIR /XD .git /XF .git /NFL /NDL /NJH /NJS /NP | Out-Null
if ($LASTEXITCODE -gt 7) {
throw "Failed to copy Zyn source to $workSource"
}
$applyCheck = Invoke-GitProbe @("-C", $workSource, "apply", "--check", $patchPath)
if ($applyCheck -eq 0) {
& git -C $workSource apply $patchPath
if ($LASTEXITCODE -ne 0) { throw "Failed to apply Zyn build patch." }
Write-Host "Applied Zyn build patch to artifact source."
}
else {
$reverseCheck = Invoke-GitProbe @("-C", $workSource, "apply", "--reverse", "--check", $patchPath)
if ($reverseCheck -eq 0) {
Write-Host "Zyn artifact source already has build patch."
}
else {
throw "Zyn build patch cannot be applied cleanly to $workSource and is not already applied."
}
}
$repoUnix = Convert-ToMsysPath $repoRoot
$sourceUnix = Convert-ToMsysPath $workSource
$buildUnix = Convert-ToMsysPath (Join-Path $repoRoot $BuildDir)
$script = @"
set -euo pipefail
export PATH=/mingw64/bin:/usr/bin:/bin:`$PATH
cd "$repoUnix"
cmake -S "$sourceUnix" -B "$buildUnix" -G Ninja \
-DGuiModule=off \
-DPluginEnable=OFF \
-DCompileTests=ON \
-DCompileExtensiveTests=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DWerror=OFF
cmake --build "$buildUnix" --target PadNoteTest -j 4
ctest --test-dir "$buildUnix" -R PadNoteTest --output-on-failure
"@
& $bash -lc $script
if ($LASTEXITCODE -ne 0) {
throw "Zyn reference build failed."
}

View file

@ -0,0 +1,17 @@
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
index 4210c5ae..b7767f4f 100644
--- a/src/Misc/MiddleWare.cpp
+++ b/src/Misc/MiddleWare.cpp
@@ -598,9 +598,11 @@ public:
Part *p = alloc.get();
#else
Part *p = new Part(*master->memory, synth, master->time,
+ master->sync,
config->cfg.GzipCompression,
config->cfg.Interpolation,
- &master->microtonal, master->fft);
+ &master->microtonal, master->fft, &master->watcher,
+ ("/part"+to_s(npart)+"/").c_str());
p->partno = npart % NUM_MIDI_CHANNELS;
p->Prcvchn = npart % NUM_MIDI_CHANNELS;