Translate Zyn PAD presets into Aqua candidates
This commit is contained in:
parent
b38e463957
commit
d3866deb4e
7 changed files with 213 additions and 33 deletions
|
|
@ -52,9 +52,13 @@ GPL PAD batch through the real Zyn oracle when the renderer is built:
|
|||
|
||||
Each render lands in a per-synth timestamped folder under
|
||||
`artifacts/parity/zyn-upstream-pad-fixtures/`, with Zyn reference WAVs, source
|
||||
table WAVs, `report.txt`, and `candidate.aqua`. The Aquarium candidate is the
|
||||
current PAD baseline unless the report says a fixture has a specific rebuild.
|
||||
These are listening and parity fixtures, not library candidates.
|
||||
table WAVs, `report.txt`, and `candidate.aqua`. The candidate is now generated
|
||||
per preset by `ZynInstrumentReader.RebuildFirstPadAsAquariumScript`: first
|
||||
enabled PAD kit item, OSCIL harmonic magnitudes, oracle-reported table
|
||||
basefreq, and basic volume/envelope scaffolding. The report names missing
|
||||
semantics such as Zyn harmonic profile shaping, bandwidth/profile behavior, and
|
||||
filter envelope/LFO lowering. These are listening and parity fixtures, not
|
||||
library candidates.
|
||||
|
||||
## Pressure Conclusions
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System.IO.Compression;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AquariumSynth.Dsl;
|
||||
|
|
@ -70,6 +72,13 @@ public sealed record ZynInstrumentSurveyItem(
|
|||
int ComplexityScore,
|
||||
IReadOnlyList<ReferenceFeature> Features);
|
||||
|
||||
public sealed record ZynPadRebuild(
|
||||
string InstrumentName,
|
||||
int KitItemId,
|
||||
string Script,
|
||||
IReadOnlyList<ReferenceFeature> MatchedFeatures,
|
||||
IReadOnlyList<ReferenceFeature> MissingFeatures);
|
||||
|
||||
public enum ZynEngine
|
||||
{
|
||||
AddSynth,
|
||||
|
|
@ -84,7 +93,7 @@ public static class ZynInstrumentReader
|
|||
|
||||
public static ZynInstrument Parse(ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
var document = XDocument.Parse(XmlText(bytes).TrimStart(), LoadOptions.None);
|
||||
var document = ParseDocument(bytes);
|
||||
var instrument = document.Descendants("INSTRUMENT").FirstOrDefault()
|
||||
?? throw new ArgumentException("Zyn instrument XML is missing INSTRUMENT");
|
||||
var info = instrument.Element("INFO");
|
||||
|
|
@ -103,6 +112,90 @@ public static class ZynInstrumentReader
|
|||
public static ReferenceSource SourceForBytes(string uri, string license, ReadOnlySpan<byte> bytes, string notes = "") =>
|
||||
new("zyn-xiz", uri, license, Convert.ToHexString(SHA256.HashData(bytes)).ToLowerInvariant(), notes);
|
||||
|
||||
public static ZynPadRebuild RebuildFirstPadAsAquariumScript(
|
||||
string path,
|
||||
float tableRootFrequencyHz,
|
||||
float playbackFrequencyHz = 261.6256f) =>
|
||||
RebuildFirstPadAsAquariumScript(File.ReadAllBytes(path), tableRootFrequencyHz, playbackFrequencyHz);
|
||||
|
||||
public static ZynPadRebuild RebuildFirstPadAsAquariumScript(
|
||||
ReadOnlySpan<byte> bytes,
|
||||
float tableRootFrequencyHz,
|
||||
float playbackFrequencyHz = 261.6256f)
|
||||
{
|
||||
if (tableRootFrequencyHz <= 0) throw new ArgumentOutOfRangeException(nameof(tableRootFrequencyHz));
|
||||
if (playbackFrequencyHz <= 0) throw new ArgumentOutOfRangeException(nameof(playbackFrequencyHz));
|
||||
|
||||
var document = ParseDocument(bytes);
|
||||
var instrument = document.Descendants("INSTRUMENT").FirstOrDefault()
|
||||
?? throw new ArgumentException("Zyn instrument XML is missing INSTRUMENT");
|
||||
var name = StringValue(instrument.Element("INFO"), "name", "unnamed");
|
||||
var item = instrument
|
||||
.Descendants("INSTRUMENT_KIT_ITEM")
|
||||
.FirstOrDefault(IsEnabledPadItem)
|
||||
?? throw new ArgumentException("Zyn instrument XML has no enabled PAD kit item");
|
||||
var pad = item.Element("PAD_SYNTH_PARAMETERS")
|
||||
?? throw new ArgumentException("Enabled PAD kit item is missing PAD_SYNTH_PARAMETERS");
|
||||
var amplitude = pad.Element("AMPLITUDE_PARAMETERS");
|
||||
var envelope = amplitude?.Element("AMPLITUDE_ENVELOPE");
|
||||
var harmonics = pad.Element("OSCIL")?.Element("HARMONICS")?.Elements("HARMONIC")
|
||||
.Select(ParsePadHarmonic)
|
||||
.Where(partial => partial.Gain > 0)
|
||||
.OrderBy(partial => partial.Ratio)
|
||||
.Take(32)
|
||||
.ToList() ?? [];
|
||||
if (harmonics.Count == 0)
|
||||
{
|
||||
harmonics.Add(new HarmonicPartial(1, 0.16f));
|
||||
}
|
||||
|
||||
var volume = IntParam(amplitude, "volume", 90);
|
||||
var layerGain = Math.Clamp(volume / 500f, 0.02f, 0.4f);
|
||||
var attack = EnvelopeTime(envelope, "A_dt", 0.28f);
|
||||
var decay = EnvelopeTime(envelope, "D_dt", 0.42f);
|
||||
var release = EnvelopeTime(envelope, "R_dt", 1.2f);
|
||||
var safeName = SafeIdentifier(string.IsNullOrWhiteSpace(name) ? $"pad_{IntAttribute(item, "id")}" : name);
|
||||
var partialText = string.Join(",", harmonics.Select(partial => $"{F(partial.Ratio)}:{F(partial.Gain)}"));
|
||||
|
||||
var matched = new List<ReferenceFeature>
|
||||
{
|
||||
new("engine_pad", "1", "Translated first enabled PAD kit item."),
|
||||
new("pad_oscillator_harmonics", harmonics.Count.ToString(CultureInfo.InvariantCulture), "Mapped OSCIL/HARMONICS magnitudes into Aquarium spectrum partials."),
|
||||
new("pad_table_root", F(tableRootFrequencyHz), "Root frequency comes from the Zyn oracle generated sample basefreq."),
|
||||
new("pad_volume", volume.ToString(CultureInfo.InvariantCulture), "Mapped PAD amplitude volume into Aquarium layer gain.")
|
||||
};
|
||||
var missing = new List<ReferenceFeature>();
|
||||
if (IntParam(pad, "bandwidth", 0) > 0)
|
||||
{
|
||||
missing.Add(new("pad_bandwidth_profile", IntParam(pad, "bandwidth", 0).ToString(CultureInfo.InvariantCulture), "Aquarium spread is kept at zero until Zyn bandwidth/profile semantics are calibrated."));
|
||||
}
|
||||
if (pad.Element("HARMONIC_PROFILE") is { } profile)
|
||||
{
|
||||
missing.Add(new("pad_harmonic_profile", IntParam(profile, "base_type", 0).ToString(CultureInfo.InvariantCulture), "Zyn harmonic profile shaping is not yet lowered; explicit OSCIL harmonics are used as the first spectral rung."));
|
||||
}
|
||||
if (pad.Element("FILTER_PARAMETERS") is not null)
|
||||
{
|
||||
missing.Add(new("pad_filter_parameters", "present", "Filter envelope/LFO lowering remains separate pressure."));
|
||||
}
|
||||
|
||||
var script = new StringBuilder();
|
||||
script.AppendLine("# Generated from a ZynAddSubFX PAD fixture for parity pressure.");
|
||||
script.AppendLine("# Scope: first enabled PAD kit item, OSCIL harmonic magnitudes, basic volume/envelope.");
|
||||
script.AppendLine("patch");
|
||||
script.AppendLine(" gain=1");
|
||||
script.AppendLine(" soft_clip=false");
|
||||
script.AppendLine();
|
||||
script.AppendLine("defaults");
|
||||
script.AppendLine(" wave=sine");
|
||||
script.AppendLine(" lpf=1");
|
||||
script.AppendLine(" hpf=0");
|
||||
script.AppendLine();
|
||||
script.AppendLine($"layer name={safeName} engine=pad gain={F(layerGain)} env=rl rates={F(attack)},{F(decay)},1,{F(release)} levels=1,1,1,0 curves=lin,lin,lin,lin gate=1.5");
|
||||
script.AppendLine($"spectrum layer={safeName} root={F(tableRootFrequencyHz)} freq={F(playbackFrequencyHz)} spread=0 partials={partialText}");
|
||||
|
||||
return new ZynPadRebuild(name, IntAttribute(item, "id"), script.ToString(), matched, missing);
|
||||
}
|
||||
|
||||
private static ZynKitItem ParseKitItem(XElement item)
|
||||
{
|
||||
var engines = new List<ZynEngine>();
|
||||
|
|
@ -139,12 +232,18 @@ public static class ZynInstrumentReader
|
|||
return System.Text.Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
private static XDocument ParseDocument(ReadOnlySpan<byte> bytes) =>
|
||||
XDocument.Parse(XmlText(bytes).TrimStart(), LoadOptions.None);
|
||||
|
||||
private static int CountElements(XElement root, Func<string, bool> predicate) =>
|
||||
root.Descendants().Count(element => predicate(element.Name.LocalName));
|
||||
|
||||
private static bool EngineEnabled(XElement item, string flagName, string sectionName) =>
|
||||
BoolParamValue(item, flagName) ?? item.Element(sectionName) is not null;
|
||||
|
||||
private static bool IsEnabledPadItem(XElement item) =>
|
||||
BoolParam(item, "enabled") && EngineEnabled(item, "pad_enabled", "PAD_SYNTH_PARAMETERS");
|
||||
|
||||
private static string StringValue(XElement? root, string name, string fallback) =>
|
||||
root?.Elements("string")
|
||||
.FirstOrDefault(element => AttributeValue(element, "name") == name)
|
||||
|
|
@ -170,6 +269,41 @@ public static class ZynInstrumentReader
|
|||
|
||||
private static string? AttributeValue(XElement element, string name) =>
|
||||
element.Attribute(name)?.Value;
|
||||
|
||||
private static HarmonicPartial ParsePadHarmonic(XElement harmonic)
|
||||
{
|
||||
var id = IntAttribute(harmonic, "id");
|
||||
var ratio = Math.Max(1, id);
|
||||
var magnitude = IntParam(harmonic, "mag", 0);
|
||||
return new HarmonicPartial(ratio, 0.16f * Math.Clamp(magnitude / 127f, 0, 1));
|
||||
}
|
||||
|
||||
private static int IntParam(XElement? root, string name, int fallback)
|
||||
{
|
||||
var value = root?.Elements("par")
|
||||
.FirstOrDefault(element => AttributeValue(element, "name") == name)
|
||||
?.Attribute("value")
|
||||
?.Value;
|
||||
return int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsed) ? parsed : fallback;
|
||||
}
|
||||
|
||||
private static float EnvelopeTime(XElement? envelope, string name, float fallback)
|
||||
{
|
||||
var value = IntParam(envelope, name, -1);
|
||||
return value < 0 ? fallback : Math.Clamp(value / 127f, 0.02f, 1.4f);
|
||||
}
|
||||
|
||||
private static string SafeIdentifier(string value)
|
||||
{
|
||||
var chars = value
|
||||
.Select(ch => char.IsLetterOrDigit(ch) ? char.ToLowerInvariant(ch) : '_')
|
||||
.ToArray();
|
||||
var safe = string.Join("_", new string(chars).Split('_', StringSplitOptions.RemoveEmptyEntries));
|
||||
return string.IsNullOrWhiteSpace(safe) ? "pad" : safe;
|
||||
}
|
||||
|
||||
private static string F(float value) =>
|
||||
value.ToString("0.######", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static class ZynInstrumentSurvey
|
||||
|
|
|
|||
|
|
@ -72,4 +72,5 @@
|
|||
{"date":"2026-05-15","area":"zyn-pad-parity","lesson":"Aqua's remaining detuned impression was caused by stacking same-note PAD spectral voices. Collapse body/high content into one coherent spectral table before adding layers for richness. A simple gain trim then brought loudness into line: RMS ratio 1.001704, centroid ratio 1.004072, score 0.6211.","evidence":"BuiltInScripts.ZynStylePadTexture now uses one active PAD spectrum with partials 1, 1.5, and 2 plus patch gain 1.1; artifacts/parity/zyn-pad-reference/report.txt records the focused render."}
|
||||
{"date":"2026-05-15","area":"zyn-pad-fixtures","lesson":"More PAD fixtures immediately exposed which pressure is real: `pad-pure` and old `pad-texture` render identically through Zyn, so the filter/category XML in `pad-texture` was not live oracle behavior. `pad-harmonic` changes table and note output through explicit OSCIL harmonics and should be the next PAD parity rung.","evidence":"tests/AquariumSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/pad-pure.xiz and pad-harmonic.xiz plus artifacts/parity/zyn-pad-fixtures/report.txt."}
|
||||
{"date":"2026-05-15","area":"zyn-upstream-gpl-bank","lesson":"GPL Zyn presets are acceptable as test-only feedstock. The upstream instrument submodule at `external/zynaddsubfx/instruments` commit c5c912131b31df5fdf372d2f06a25aaf2375837f provides 1318 `.xiz` files; survey and PAD render tests write ignored reports/WAVs while the NuGet boundary still excludes `.xiz`, `external/`, and artifacts.","evidence":"ZynInstrumentTests.SurveysUpstreamGplInstrumentBankWhenAvailable and ZynReferenceParityTests.ZynPadReferenceRendererSurveysUpstreamGplPadFixturesWhenBuilt; focused Zyn tests passed 14/14."}
|
||||
{"date":"2026-05-15","area":"zyn-artifact-layout","lesson":"Zyn PAD listening artifacts now follow the DX7 parity shape: per-synth timestamped run folders with Zyn reference WAVs, source-table WAVs, `report.txt`, and `candidate.aqua`. Upstream GPL PAD runs also render `candidate-aquarium.wav` from the current ZynStylePadTexture baseline, explicitly labeled as not a per-preset rebuild.","evidence":"ZynReferenceParityTests focused run passed 4/4 and wrote folders such as artifacts/parity/zyn-upstream-pad-fixtures/0121-ghost-ensemble-20260515T072330036."}
|
||||
{"date":"2026-05-15","area":"zyn-artifact-layout","lesson":"Zyn PAD listening artifacts now follow the DX7 parity shape: per-synth timestamped run folders with Zyn reference WAVs, source-table WAVs, `report.txt`, and `candidate.aqua`. Upstream GPL PAD runs write `candidate-aquarium.wav`; this was initially the current ZynStylePadTexture baseline and is now superseded by generated per-preset PAD rebuilds.","evidence":"ZynReferenceParityTests focused run passed 4/4 and wrote folders such as artifacts/parity/zyn-upstream-pad-fixtures/0121-ghost-ensemble-20260515T072330036."}
|
||||
{"date":"2026-05-15","area":"zyn-pad-translation","lesson":"Zyn PAD artifacts now use per-preset generated `.aqua` instead of the generic baseline. `ZynInstrumentReader.RebuildFirstPadAsAquariumScript` translates the first enabled PAD kit item into one named PAD layer plus a `spectrum` bank using OSCIL harmonic magnitudes, Zyn oracle sample `basefreq` as table root, PAD volume as layer gain, and simple rate/level envelope scaffolding. Reports explicitly list missing Zyn semantics: bandwidth/profile spreading, harmonic profile shaping, and filter envelope/LFO lowering.","evidence":"ZynInstrumentTests.RebuildsProjectAuthoredPadAsAquariumSpectrumScript plus focused Zyn tests passed 13/13; latest upstream PAD reports include generated candidate scripts and log-mel scores from ~0.276 to ~0.637."}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
},
|
||||
"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. 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, proves `PadNoteTest`, and builds `ZynPadReference`.",
|
||||
"lesson": "Start Zyn as structural classification, not translation. Upstream Zyn presets live in a nested GPL instrument-bank submodule and may be used as test-only parity/pressure feedstock once provenance is recorded. 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 PAD oracle now renders both generated PAD sample tables and note audio through Zyn `PADnoteParameters`/`PADnote`; optional parity artifacts live under `artifacts/parity/zyn-pad-reference` and `artifacts/parity/zyn-pad-fixtures`. The first project-authored PAD comparison proved the harness and showed Aquarium `spectrum` was not a close Zyn PAD emulation. User listening identified Zyn as pure wineglass and Aquarium as angry bees. Cutting unearned air/noise/drive/soft-clip from the rebuild, adding interpolated wavetable reads, and raising Aquarium spectral tables to Zyn's 131072-frame PAD size improved the report. A later pitch/drone pass split PAD table root from playback note frequency: `spectrum root=...` owns table/base frequency and `freq=...` owns the played note. Using Zyn's reported sample basefreq 77.7813 while playing 261.6256, removing gratuitous spread/vibrato, collapsing two same-note PAD voices into one coherent spectral table, and trimming gain improved the report to log-mel 0.35669, envelope 0.347572, RMS ratio 1.001704, centroid ratio 1.004072, score 0.6211. The first PAD fixture survey shows `pad-pure` and the old `pad-texture` render identically through Zyn, so the filter/category XML in `pad-texture` is not live pressure for this oracle path. `pad-harmonic` changes the source table and note output through explicit OSCIL harmonics, making it the next real PAD reference rung. The remaining gap is source-table/profile and envelope semantics, not more decorative patch layers. The report now also emits source-table WAVs for listening. The hardened reader parses the upstream GPL instrument bank at commit c5c912131b31df5fdf372d2f06a25aaf2375837f: 1318/1318 .xiz files; optional tests write a ranked report and render five upstream PAD listening fixtures under ignored artifacts. 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 named layers and generated table base frequency; playback `freq` remains note authority. 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.",
|
||||
"lesson": "Start Zyn as structural classification, then move into explicit scoped rebuilds. Upstream Zyn presets live in a nested GPL instrument-bank submodule and may be used as test-only parity/pressure feedstock once provenance is recorded. 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 PAD oracle now renders both generated PAD sample tables and note audio through Zyn `PADnoteParameters`/`PADnote`; optional parity artifacts live under `artifacts/parity/zyn-pad-reference` and `artifacts/parity/zyn-pad-fixtures`. The first project-authored PAD comparison proved the harness and showed Aquarium `spectrum` was not a close Zyn PAD emulation. User listening identified Zyn as pure wineglass and Aquarium as angry bees. Cutting unearned air/noise/drive/soft-clip from the rebuild, adding interpolated wavetable reads, and raising Aquarium spectral tables to Zyn's 131072-frame PAD size improved the report. A later pitch/drone pass split PAD table root from playback note frequency: `spectrum root=...` owns table/base frequency and `freq=...` owns the played note. Using Zyn's reported sample basefreq 77.7813 while playing 261.6256, removing gratuitous spread/vibrato, collapsing two same-note PAD voices into one coherent spectral table, and trimming gain improved the report to log-mel 0.35669, envelope 0.347572, RMS ratio 1.001704, centroid ratio 1.004072, score 0.6211. The first PAD fixture survey shows `pad-pure` and the old `pad-texture` render identically through Zyn, so the filter/category XML in `pad-texture` is not live pressure for this oracle path. `pad-harmonic` changes the source table and note output through explicit OSCIL harmonics, making it the next real PAD reference rung. The remaining gap is source-table/profile and envelope semantics, not more decorative patch layers. The report now also emits source-table WAVs for listening. The hardened reader parses the upstream GPL instrument bank at commit c5c912131b31df5fdf372d2f06a25aaf2375837f: 1318/1318 .xiz files; optional tests write a ranked report and render five upstream PAD listening fixtures under ignored artifacts. `RebuildFirstPadAsAquariumScript` now generates first-pass per-preset PAD `.aqua` candidates from the first enabled PAD kit item, OSCIL harmonic magnitudes, oracle-reported table base frequency, basic volume, and simple rate/level envelope scaffolding while reporting missing bandwidth/profile/filter semantics. 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 named layers and generated table base frequency; playback `freq` remains note authority. 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": "Use the Zyn PAD oracle report to isolate whether the main mismatch is source table generation, note playback/gain, envelope shape, or fixture mapping before adding more Zyn DSL surface."
|
||||
},
|
||||
"note_and_envelope_model": {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ live_invariants:
|
|||
- Recompile only for graph shape changes; vary declared parameters through the hosted DSP control API.
|
||||
- Reference fixtures must preserve provenance, license status, source hash, and feature pressure.
|
||||
- Public-domain reference fixtures, GPL Zyn instrument-bank fixtures, dexed-py helpers, and pinned ZynAddSubFX source are test/development material only; the NuGet package must ship only AquariumSynth.Dsl.
|
||||
- ZynAddSubFX import starts as feature extraction, not translation. Upstream GPL `.xiz` instruments may be used as test-only pressure/parity feedstock with provenance reports, while project-authored `.xiz` fixtures remain the clean baseline. The Zyn engine source and instrument bank are pinned under `external/zynaddsubfx` for parity oracles only, not Aquarium runtime code.
|
||||
- ZynAddSubFX import starts as feature extraction and then explicit, scoped rebuilds. Upstream GPL `.xiz` instruments may be used as test-only pressure/parity feedstock with provenance reports, while project-authored `.xiz` fixtures remain the clean baseline. The Zyn engine source and instrument bank are pinned under `external/zynaddsubfx` for parity oracles only, not Aquarium runtime code.
|
||||
- Named `layer` declarations own Zyn-style kit/layer identity: engine tag, optional key range metadata, default gain, and effect-send labels. They lower to ordinary voices for now; do not smuggle PAD/free-envelope/effect behavior into them.
|
||||
- Additive `harmonics` declarations own authored ratio/gain partial banks under named layers. They lower to ordinary voices for now; do not pretend this covers Zyn ADDsynth phase, bandwidth, oscillator shaping, or free-envelope semantics.
|
||||
- Normal voices may use staged `env=rl` rate/level envelopes. Notes still own gate timing; envelopes own level shape. This is not arbitrary Zyn free-envelope point editing.
|
||||
|
|
@ -102,7 +102,7 @@ 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 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, proves `PadNoteTest`, and builds `ZynPadReference`. The optional PAD reports emit note and source-table WAV/listening artifacts. After cutting unearned noise/drive/soft-clip, adding interpolated table reads, raising Aquarium spectral tables to 131072 frames, splitting table root from playback frequency, removing gratuitous spread/vibrato, collapsing same-note PAD voices into one coherent table, and trimming gain, the project-authored PAD report is close by ear and still not formally passing: log-mel 0.35669, envelope 0.347572, RMS ratio 1.001704, centroid ratio 1.004072, score 0.6211. The PAD fixture survey shows `pad-pure` and `pad-texture` render identically through Zyn, while `pad-harmonic` changes the source and becomes the next real rung. The upstream GPL instrument bank is initialized at `external/zynaddsubfx/instruments` commit c5c912131b31df5fdf372d2f06a25aaf2375837f; survey tests parse 1318/1318 .xiz files, write a pressure report, and render a five-patch upstream PAD listening batch under ignored artifacts."
|
||||
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. `ZynInstrumentReader.RebuildFirstPadAsAquariumScript` now emits first-pass per-preset PAD `.aqua` rebuilds for the first enabled PAD kit item: OSCIL harmonic magnitudes, oracle-reported table base frequency, basic volume, and simple rate/level envelope scaffolding, while reporting missing bandwidth/profile/filter semantics. 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, proves `PadNoteTest`, and builds `ZynPadReference`. The optional PAD reports emit note and source-table WAV/listening artifacts. After cutting unearned noise/drive/soft-clip, adding interpolated table reads, raising Aquarium spectral tables to 131072 frames, splitting table root from playback frequency, removing gratuitous spread/vibrato, collapsing same-note PAD voices into one coherent table, and trimming gain, the project-authored PAD report is close by ear and still not formally passing: log-mel 0.35669, envelope 0.347572, RMS ratio 1.001704, centroid ratio 1.004072, score 0.6211. The PAD fixture survey shows `pad-pure` and `pad-texture` render identically through Zyn, while `pad-harmonic` changes the source and becomes the next real rung. The upstream GPL instrument bank is initialized at `external/zynaddsubfx/instruments` commit c5c912131b31df5fdf372d2f06a25aaf2375837f; survey tests parse 1318/1318 .xiz files, write a pressure report, and render a five-patch upstream PAD listening batch under ignored artifacts."
|
||||
first_slice:
|
||||
- "Use the Zyn PAD oracle report to isolate source-table, playback/gain, envelope, and fixture-mapping mismatch before further Zyn DSL golf."
|
||||
- "Use named layers as the owner before promoting richer formant morphing syntax."
|
||||
|
|
@ -177,9 +177,9 @@ completed_slices:
|
|||
oracle render batch for five upstream PAD instruments under
|
||||
`artifacts/parity/zyn-upstream-pad-fixtures/`. Zyn PAD artifacts now use
|
||||
per-synth timestamped folders with reference WAVs, table WAVs,
|
||||
`candidate.aqua`, and `report.txt`; upstream GPL runs also render the
|
||||
current `ZynStylePadTexture` Aquarium baseline as `candidate-aquarium.wav`
|
||||
while labeling it as a baseline rather than a per-preset rebuild. The
|
||||
`candidate.aqua`, and `report.txt`; upstream GPL runs now render
|
||||
per-preset first-pass PAD rebuilds as `candidate-aquarium.wav`, with
|
||||
reports naming which Zyn PAD semantics are still missing. The
|
||||
batch includes `Pads/0002-sin2x pad.xiz`, `Pads/0065-Soft Pad.xiz`,
|
||||
`Dual/0008-Organ Choir Pad2.xiz`, `Laba170bank/0098-DoublePadBass.xiz`,
|
||||
and `Companion/0121-Ghost Ensemble.xiz`.
|
||||
|
|
|
|||
|
|
@ -147,6 +147,24 @@ public sealed class ZynInstrumentTests
|
|||
Assert.Contains(survey[0].Features, feature => feature.Name == "formant_filter_count" && feature.Value == "1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RebuildsProjectAuthoredPadAsAquariumSpectrumScript()
|
||||
{
|
||||
var path = FixturePath("ZynAddSubFX", "ProjectAuthored", "pad-harmonic.xiz");
|
||||
|
||||
var rebuild = ZynInstrumentReader.RebuildFirstPadAsAquariumScript(path, tableRootFrequencyHz: 77.7813f);
|
||||
var patch = PatchScript.Parse(rebuild.Script);
|
||||
|
||||
Assert.Equal("AQ Pad Harmonic", rebuild.InstrumentName);
|
||||
Assert.Equal(0, rebuild.KitItemId);
|
||||
Assert.Contains("spectrum", rebuild.Script);
|
||||
Assert.Contains("root=77.7813", rebuild.Script);
|
||||
var bank = Assert.Single(patch.SpectralBanks);
|
||||
Assert.Equal(77.7813f, bank.RootFrequencyHz, precision: 4);
|
||||
Assert.Contains(bank.Partials, partial => Math.Abs(partial.Ratio - 2) < 0.0001f && partial.Gain > 0);
|
||||
Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "pad_oscillator_harmonics");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SurveysUpstreamGplInstrumentBankWhenAvailable()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,8 +93,11 @@ public sealed class ZynReferenceParityTests
|
|||
$"zyn_table_rms: {Rms(zynTableSamples):0.######}"
|
||||
};
|
||||
|
||||
var aquaExport = FaustEmitter.EmitScript(BuiltInScripts.ZynStylePadTexture, new FaustExportOptions("zyn_pad_texture"));
|
||||
await File.WriteAllTextAsync(Path.Combine(artifactDir, "candidate.aqua"), BuiltInScripts.ZynStylePadTexture);
|
||||
var rebuild = ZynInstrumentReader.RebuildFirstPadAsAquariumScript(input, ParseBaseFrequency(tableReference.Stdout));
|
||||
report.AddRange(rebuild.MatchedFeatures.Select(feature => $"matched_{feature.Name}: {feature.Value}"));
|
||||
report.AddRange(rebuild.MissingFeatures.Select(feature => $"missing_{feature.Name}: {feature.Value} - {feature.Notes}"));
|
||||
var aquaExport = FaustEmitter.EmitScript(rebuild.Script, new FaustExportOptions("zyn_pad_texture"));
|
||||
await File.WriteAllTextAsync(Path.Combine(artifactDir, "candidate.aqua"), rebuild.Script);
|
||||
var aquaRender = await FaustCompiler.RenderAsync(aquaExport.Source, new FaustRenderOptions(DurationSeconds: 1.5f));
|
||||
if (aquaRender is { Samples.Length: > 0 })
|
||||
{
|
||||
|
|
@ -148,12 +151,13 @@ public sealed class ZynReferenceParityTests
|
|||
var noteWav = Path.Combine(runDir, "reference-zyn.wav");
|
||||
var tableRaw = Path.Combine(runDir, "reference-zyn-table0.f32");
|
||||
var tableWav = Path.Combine(runDir, "reference-zyn-table0.wav");
|
||||
await File.WriteAllTextAsync(Path.Combine(runDir, "candidate.aqua"), BuiltInScripts.ZynStylePadTexture);
|
||||
|
||||
var note = await RunAsync(bash, ["-lc", ZynPadCommand(root, input, noteRaw, 0, "note", "261.6256", "1.5")]);
|
||||
Assert.Equal(0, note.ExitCode);
|
||||
var table = await RunAsync(bash, ["-lc", ZynPadCommand(root, input, tableRaw, 0, "0")]);
|
||||
Assert.Equal(0, table.ExitCode);
|
||||
var rebuild = ZynInstrumentReader.RebuildFirstPadAsAquariumScript(input, ParseBaseFrequency(table.Stdout));
|
||||
await File.WriteAllTextAsync(Path.Combine(runDir, "candidate.aqua"), rebuild.Script);
|
||||
|
||||
var noteSamples = await ReadFloat32Async(noteRaw);
|
||||
var tableSamples = await ReadFloat32Async(tableRaw);
|
||||
|
|
@ -173,21 +177,23 @@ public sealed class ZynReferenceParityTests
|
|||
report.Add($"centroid: {features.SpectralCentroidHz:0.######}");
|
||||
report.Add($"table_peak: {Peak(tableSamples):0.######}");
|
||||
report.Add($"table_rms: {Rms(tableSamples):0.######}");
|
||||
await File.WriteAllLinesAsync(
|
||||
Path.Combine(runDir, "report.txt"),
|
||||
[
|
||||
$"fixture: {name}",
|
||||
$"input: {input}",
|
||||
$"candidate: current ZynStylePadTexture baseline; not a per-fixture rebuild unless this is pad-texture",
|
||||
$"note_stdout: {note.Stdout.Trim()}",
|
||||
$"table_stdout: {table.Stdout.Trim()}",
|
||||
$"peak: {Peak(noteSamples):0.######}",
|
||||
$"rms: {Rms(noteSamples):0.######}",
|
||||
$"duration: {features.DurationSeconds:0.######}",
|
||||
$"centroid: {features.SpectralCentroidHz:0.######}",
|
||||
$"table_peak: {Peak(tableSamples):0.######}",
|
||||
$"table_rms: {Rms(tableSamples):0.######}"
|
||||
]);
|
||||
var runReport = new List<string>
|
||||
{
|
||||
$"fixture: {name}",
|
||||
$"input: {input}",
|
||||
$"candidate: generated first-pass Zyn PAD rebuild",
|
||||
$"note_stdout: {note.Stdout.Trim()}",
|
||||
$"table_stdout: {table.Stdout.Trim()}",
|
||||
$"peak: {Peak(noteSamples):0.######}",
|
||||
$"rms: {Rms(noteSamples):0.######}",
|
||||
$"duration: {features.DurationSeconds:0.######}",
|
||||
$"centroid: {features.SpectralCentroidHz:0.######}",
|
||||
$"table_peak: {Peak(tableSamples):0.######}",
|
||||
$"table_rms: {Rms(tableSamples):0.######}"
|
||||
};
|
||||
runReport.AddRange(rebuild.MatchedFeatures.Select(feature => $"matched_{feature.Name}: {feature.Value}"));
|
||||
runReport.AddRange(rebuild.MissingFeatures.Select(feature => $"missing_{feature.Name}: {feature.Value} - {feature.Notes}"));
|
||||
await File.WriteAllLinesAsync(Path.Combine(runDir, "report.txt"), runReport);
|
||||
}
|
||||
|
||||
await File.WriteAllLinesAsync(Path.Combine(artifactDir, $"survey-{Timestamp()}.txt"), report);
|
||||
|
|
@ -246,12 +252,13 @@ public sealed class ZynReferenceParityTests
|
|||
var tableRaw = Path.Combine(runDir, "reference-zyn-table0.f32");
|
||||
var tableWav = Path.Combine(runDir, "reference-zyn-table0.wav");
|
||||
var aquaWav = Path.Combine(runDir, "candidate-aquarium.wav");
|
||||
await File.WriteAllTextAsync(Path.Combine(runDir, "candidate.aqua"), BuiltInScripts.ZynStylePadTexture);
|
||||
|
||||
var note = await RunAsync(bash, ["-lc", ZynPadCommand(root, input, noteRaw, kitIndex, "note", "261.6256", "1.5")]);
|
||||
Assert.Equal(0, note.ExitCode);
|
||||
var table = await RunAsync(bash, ["-lc", ZynPadCommand(root, input, tableRaw, kitIndex, "0")]);
|
||||
Assert.Equal(0, table.ExitCode);
|
||||
var rebuild = ZynInstrumentReader.RebuildFirstPadAsAquariumScript(input, ParseBaseFrequency(table.Stdout));
|
||||
await File.WriteAllTextAsync(Path.Combine(runDir, "candidate.aqua"), rebuild.Script);
|
||||
|
||||
var noteSamples = await ReadFloat32Async(noteRaw);
|
||||
var tableSamples = await ReadFloat32Async(tableRaw);
|
||||
|
|
@ -260,7 +267,7 @@ public sealed class ZynReferenceParityTests
|
|||
WriteWav(noteWav, noteSamples, 44100, 0.9f);
|
||||
WriteWav(tableWav, tableSamples, 44100, 0.9f);
|
||||
var aquaRender = await FaustCompiler.RenderAsync(
|
||||
FaustEmitter.EmitScript(BuiltInScripts.ZynStylePadTexture, new FaustExportOptions("zyn_upstream_pad_baseline")).Source,
|
||||
FaustEmitter.EmitScript(rebuild.Script, new FaustExportOptions("zyn_upstream_pad_candidate")).Source,
|
||||
new FaustRenderOptions(DurationSeconds: 1.5f));
|
||||
|
||||
var features = AudioAnalyzer.AnalyzeAudio(noteSamples).Features;
|
||||
|
|
@ -270,7 +277,7 @@ public sealed class ZynReferenceParityTests
|
|||
$"instrument: {instrument.Name}",
|
||||
$"input: {input}",
|
||||
$"kit_index: {kitIndex}",
|
||||
$"candidate: current ZynStylePadTexture baseline, not a per-preset rebuild",
|
||||
$"candidate: generated first-pass Zyn PAD rebuild",
|
||||
$"note_stdout: {note.Stdout.Trim()}",
|
||||
$"table_stdout: {table.Stdout.Trim()}",
|
||||
$"peak: {Peak(noteSamples):0.######}",
|
||||
|
|
@ -280,6 +287,8 @@ public sealed class ZynReferenceParityTests
|
|||
$"table_peak: {Peak(tableSamples):0.######}",
|
||||
$"table_rms: {Rms(tableSamples):0.######}"
|
||||
};
|
||||
runReport.AddRange(rebuild.MatchedFeatures.Select(feature => $"matched_{feature.Name}: {feature.Value}"));
|
||||
runReport.AddRange(rebuild.MissingFeatures.Select(feature => $"missing_{feature.Name}: {feature.Value} - {feature.Notes}"));
|
||||
report.Add("");
|
||||
report.Add($"fixture: {relative}");
|
||||
report.Add($"instrument: {instrument.Name}");
|
||||
|
|
@ -293,11 +302,13 @@ public sealed class ZynReferenceParityTests
|
|||
report.Add($"table_peak: {Peak(tableSamples):0.######}");
|
||||
report.Add($"table_rms: {Rms(tableSamples):0.######}");
|
||||
report.Add($"artifact_dir: {runDir}");
|
||||
report.AddRange(rebuild.MatchedFeatures.Select(feature => $"matched_{feature.Name}: {feature.Value}"));
|
||||
report.AddRange(rebuild.MissingFeatures.Select(feature => $"missing_{feature.Name}: {feature.Value} - {feature.Notes}"));
|
||||
if (aquaRender is { Samples.Length: > 0 })
|
||||
{
|
||||
WriteWav(aquaWav, aquaRender.Samples, aquaRender.SampleRate, 0.9f);
|
||||
var comparison = AudioAnalyzer.CompareAudio(noteSamples, aquaRender.Samples);
|
||||
report.Add($"candidate: current ZynStylePadTexture baseline, not a per-preset rebuild");
|
||||
report.Add($"candidate: generated first-pass Zyn PAD rebuild");
|
||||
report.Add($"log_mel_distance: {comparison.LogMelDistance:0.######}");
|
||||
report.Add($"envelope_distance: {comparison.EnvelopeDistance:0.######}");
|
||||
report.Add($"rms_ratio: {comparison.RmsRatio:0.######}");
|
||||
|
|
@ -381,6 +392,18 @@ public sealed class ZynReferenceParityTests
|
|||
private static string Timestamp() =>
|
||||
DateTimeOffset.UtcNow.ToString("yyyyMMddTHHmmssfff", System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
private static float ParseBaseFrequency(string stdout)
|
||||
{
|
||||
const string marker = "basefreq=";
|
||||
var start = stdout.IndexOf(marker, StringComparison.OrdinalIgnoreCase);
|
||||
if (start < 0) throw new InvalidOperationException($"Zyn PAD table stdout did not include basefreq: {stdout}");
|
||||
start += marker.Length;
|
||||
var end = start;
|
||||
while (end < stdout.Length && !char.IsWhiteSpace(stdout[end])) end++;
|
||||
var value = stdout[start..end];
|
||||
return float.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private static async Task<float[]> ReadFloat32Async(string path)
|
||||
{
|
||||
var bytes = await File.ReadAllBytesAsync(path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue