Add native bandpass and notch filters
This commit is contained in:
parent
eb27b49f7a
commit
da459f80f3
11 changed files with 243 additions and 17 deletions
|
|
@ -52,6 +52,11 @@ For this repo that means:
|
|||
- Prefer deterministic lowering. Same script plus same options must produce the
|
||||
same patch and Faust source.
|
||||
|
||||
Filters own post-source spectral selection. Low-pass, high-pass, band-pass, and
|
||||
notch are native AquaSynth filter authorities. Formants remain vowel/body color,
|
||||
and PAD spectrum/profile fields remain source-table construction; do not use
|
||||
those surfaces as substitutes for ordinary subtractive filters.
|
||||
|
||||
## Faust Boundary
|
||||
|
||||
Faust describes pure DSP: inputs to outputs. Architecture files and host code
|
||||
|
|
|
|||
|
|
@ -88,17 +88,19 @@ Current upstream bank coverage:
|
|||
- Files parsed: `1318/1318`
|
||||
- Enabled kit items: `1459`
|
||||
- Layered instruments: `63`
|
||||
- Handled with parity-backed or native AquaSynth coverage: PAD layers, named
|
||||
- Handled with parity-backed or native AquaSynth coverage: native band-pass and
|
||||
notch filters, PAD layers, named
|
||||
kit layers, PAD table modes/bandwidth, PAD source-table extraction for the
|
||||
implemented OscilGen subset, analog and state-variable PAD LP/HP
|
||||
cutoff/order/Q/envelopes, and staged non-free envelopes.
|
||||
implemented OscilGen subset, PAD LP/HP/BPF/notch cutoff/order/Q/envelopes,
|
||||
and staged non-free envelopes.
|
||||
- Counted but not translated: ADD, SUB, mixed-engine kits, free envelopes,
|
||||
active LFO routing, formant filters/motion, and effects.
|
||||
- Unknown PAD filter pressure: formant filters, state-variable band/notch, and
|
||||
other unimplemented PAD global filter categories/types such as
|
||||
`cat=1 type=0`, `cat=2 type=2`, `cat=0 type=4`, `cat=0 type=6`, and
|
||||
smaller buckets. State-variable LP/HP (`cat=2 type=0/1`) now lower through
|
||||
AquaSynth's existing cutoff/order/Q authority.
|
||||
- Unknown PAD filter pressure: formant filters, peak filters, shelf filters,
|
||||
and other unimplemented PAD global filter categories/types such as
|
||||
`cat=1 type=0`, `cat=0 type=6`, `cat=0 type=8`, and smaller buckets.
|
||||
Analog and state-variable band-pass/notch (`cat=0 type=4/5`,
|
||||
`cat=2 type=2/3`) now lower through AquaSynth's native `bpf`/`notch`
|
||||
filter authority.
|
||||
- Unknown PAD OscilGen pressure: unimplemented source filter types
|
||||
`10`, `12`, `11`, `4`, `5`, `3`, and `8`; unimplemented waveshapers
|
||||
`2`, `14`, `5`, `6`, `3`, `13`, `8`, and `9`.
|
||||
|
|
|
|||
|
|
@ -232,6 +232,8 @@ public static class FaustEmitter
|
|||
: "";
|
||||
var lpf = $"clip01({parameters.Expression(OwnerField(ownerPath, "filter/lpf"), voice.Filter.LowPass)} * (1.0 + {parameters.Expression(OwnerField(ownerPath, "filter/lpf_ramp"), voice.Filter.LowPassRamp)} * age * 1.8){lpfEnvelope} + patch_mod_lpf + {lpfMod})";
|
||||
var hpf = $"clip01({parameters.Expression(OwnerField(ownerPath, "filter/hpf"), voice.Filter.HighPass)} * (1.0 + {parameters.Expression(OwnerField(ownerPath, "filter/hpf_ramp"), voice.Filter.HighPassRamp)} * age * 2.0){hpfEnvelope} + patch_mod_hpf + {hpfMod})";
|
||||
var bpf = $"clip01({parameters.Expression(OwnerField(ownerPath, "filter/bpf"), voice.Filter.BandPass)})";
|
||||
var notch = $"clip01({parameters.Expression(OwnerField(ownerPath, "filter/notch"), voice.Filter.Notch)})";
|
||||
var highPassOrder = Math.Clamp(voice.Filter.HighPassOrder, 1, 12);
|
||||
var hasExplicitQ = voice.Filter.LowPassQ > 0 || parameters.IsBound(OwnerField(ownerPath, "filter/lpf_q"));
|
||||
var hasResonance = voice.Filter.LowPassResonance > 0 || parameters.IsBound(OwnerField(ownerPath, "filter/resonance"));
|
||||
|
|
@ -243,13 +245,27 @@ public static class FaustEmitter
|
|||
: hasResonance
|
||||
? $"fi.resonlp(max(20.0, {lpf} * 18000.0), 0.7 + clip01({resonance}) * 18.0, 1.0)"
|
||||
: $"fi.lowpass({lowPassOrder}, max(20.0, {lpf} * 18000.0))";
|
||||
var bandpass = BandPassCascade(
|
||||
$"max(20.0, {bpf} * 18000.0)",
|
||||
$"max(0.1, {parameters.Expression(OwnerField(ownerPath, "filter/bpf_q"), voice.Filter.BandPassQ)})",
|
||||
voice.Filter.BandPassOrder);
|
||||
var notchFilter = NotchCascade(
|
||||
$"max(20.0, {notch} * 18000.0)",
|
||||
$"max(1.0, (max(20.0, {notch} * 18000.0)) / max(0.1, {parameters.Expression(OwnerField(ownerPath, "filter/notch_q"), voice.Filter.NotchQ)}))",
|
||||
voice.Filter.NotchOrder);
|
||||
var bandPassStage = voice.Filter.BandPass > 0 || parameters.IsBound(OwnerField(ownerPath, "filter/bpf"))
|
||||
? $" : {bandpass}"
|
||||
: "";
|
||||
var notchStage = voice.Filter.Notch > 0 || parameters.IsBound(OwnerField(ownerPath, "filter/notch"))
|
||||
? $" : {notchFilter}"
|
||||
: "";
|
||||
|
||||
source.AppendLine($"{name}_freq = {frequency};");
|
||||
source.AppendLine($"{name}_osc = {oscillator};");
|
||||
source.AppendLine($"{name}_colored = ({name}_osc * (1.0 - {noiseMix}) + no.noise * {noiseMix});");
|
||||
source.AppendLine($"{name}_driven = ma.tanh({name}_colored * (1.0 + {driveExpression} * 12.0)) / ma.tanh(1.0 + {driveExpression} * 12.0);");
|
||||
source.AppendLine($"{name}_folded = {name}_driven * (1.0 - {foldExpression}) + fold({name}_driven * (1.0 + {foldExpression} * 3.5)) * {foldExpression};");
|
||||
source.AppendLine($"{name}_filtered = {name}_folded : {lowpass} : fi.highpass({highPassOrder}, max(5.0, ({hpf}) * ({hpf}) * 7000.0));");
|
||||
source.AppendLine($"{name}_filtered = {name}_folded : {lowpass} : fi.highpass({highPassOrder}, max(5.0, ({hpf}) * ({hpf}) * 7000.0)){bandPassStage}{notchStage};");
|
||||
if (voice.Phaser.OffsetSeconds != 0 || voice.Phaser.RampSecondsPerSecond != 0 ||
|
||||
parameters.IsBound(OwnerField(ownerPath, "phaser/offset")) ||
|
||||
parameters.IsBound(OwnerField(ownerPath, "phaser/ramp")))
|
||||
|
|
@ -272,6 +288,18 @@ public static class FaustEmitter
|
|||
return string.Join(" : ", Enumerable.Repeat($"fi.resonlp({cutoff}, {q}, 1.0)", stages));
|
||||
}
|
||||
|
||||
private static string BandPassCascade(string center, string q, int order)
|
||||
{
|
||||
var stages = Math.Max(1, (Math.Clamp(order, 1, 12) + 1) / 2);
|
||||
return string.Join(" : ", Enumerable.Repeat($"fi.resonbp({center}, {q}, 1.0)", stages));
|
||||
}
|
||||
|
||||
private static string NotchCascade(string center, string width, int order)
|
||||
{
|
||||
var stages = Math.Max(1, (Math.Clamp(order, 1, 12) + 1) / 2);
|
||||
return string.Join(" : ", Enumerable.Repeat($"fi.notchw({width}, {center})", stages));
|
||||
}
|
||||
|
||||
private static void EmitSpectralBank(
|
||||
StringBuilder source,
|
||||
SynthPatch patch,
|
||||
|
|
|
|||
|
|
@ -111,6 +111,12 @@ public sealed record Filter(
|
|||
float HighPass = 0,
|
||||
float HighPassRamp = 0,
|
||||
int HighPassOrder = 1,
|
||||
float BandPass = 0,
|
||||
float BandPassQ = 1,
|
||||
int BandPassOrder = 1,
|
||||
float Notch = 0,
|
||||
float NotchQ = 1,
|
||||
int NotchOrder = 1,
|
||||
RateLevelEnvelope? LowPassEnvelope = null,
|
||||
RateLevelEnvelope? HighPassEnvelope = null);
|
||||
|
||||
|
|
|
|||
|
|
@ -446,6 +446,12 @@ public static class PatchScript
|
|||
GetBoundFloat(fields, line, 0, OwnerField(ownerPath, "filter/hpf"), "hpf", "h"),
|
||||
GetBoundFloat(fields, line, 0, OwnerField(ownerPath, "filter/hpf_ramp"), "hpf_ramp", "hr"),
|
||||
GetBoundInt(fields, line, 1, OwnerField(ownerPath, "filter/hpf_order"), "hpf_order", "hpfo"),
|
||||
GetBoundFloat(fields, line, 0, OwnerField(ownerPath, "filter/bpf"), "bpf", "bp"),
|
||||
GetBoundFloat(fields, line, 1, OwnerField(ownerPath, "filter/bpf_q"), "bpf_q", "bpq"),
|
||||
GetBoundInt(fields, line, 1, OwnerField(ownerPath, "filter/bpf_order"), "bpf_order", "bpfo"),
|
||||
GetBoundFloat(fields, line, 0, OwnerField(ownerPath, "filter/notch"), "notch", "nt"),
|
||||
GetBoundFloat(fields, line, 1, OwnerField(ownerPath, "filter/notch_q"), "notch_q", "ntq"),
|
||||
GetBoundInt(fields, line, 1, OwnerField(ownerPath, "filter/notch_order"), "notch_order", "nto"),
|
||||
ParseFilterRateLevelEnvelope(fields, line, ownerPath, "lpf"),
|
||||
ParseFilterRateLevelEnvelope(fields, line, ownerPath, "hpf")),
|
||||
Phaser = new Phaser(
|
||||
|
|
|
|||
|
|
@ -342,6 +342,12 @@ public static class ZynInstrumentReader
|
|||
var lowPassOrder = ZynPadLowPassOrder(filter);
|
||||
var highPass = ZynPadHighPass(filter, playbackFrequencyHz);
|
||||
var highPassOrder = ZynPadHighPassOrder(filter);
|
||||
var bandPass = ZynPadBandPass(filter, playbackFrequencyHz);
|
||||
var bandPassQ = ZynPadFilterQ(filter);
|
||||
var bandPassOrder = ZynPadBandPassOrder(filter);
|
||||
var notch = ZynPadNotch(filter, playbackFrequencyHz);
|
||||
var notchQ = ZynPadFilterQ(filter);
|
||||
var notchOrder = ZynPadNotchOrder(filter);
|
||||
var lowPassEnvelope = ZynPadLowPassEnvelope(filter, lowPass);
|
||||
var highPassEnvelope = ZynPadHighPassEnvelope(filter, highPass);
|
||||
var safeName = includeKitSuffix ? $"{safeBaseName}_{kitId}" : safeBaseName;
|
||||
|
|
@ -377,6 +383,18 @@ public static class ZynInstrumentReader
|
|||
matched.Add(new($"{featurePrefix}filter_hpf", F(highPass), "Mapped static Zyn PAD global high-pass frequency into AquaSynth layer filtering."));
|
||||
matched.Add(new($"{featurePrefix}filter_hpf_order", highPassOrder.ToString(CultureInfo.InvariantCulture), "Mapped Zyn high-pass family and stage count into AquaSynth high-pass order."));
|
||||
}
|
||||
if (bandPass > 0)
|
||||
{
|
||||
matched.Add(new($"{featurePrefix}filter_bpf", F(bandPass), "Mapped static Zyn PAD global band-pass center into AquaSynth layer filtering."));
|
||||
matched.Add(new($"{featurePrefix}filter_bpf_q", F(bandPassQ), "Mapped Zyn band-pass Q into AquaSynth filter bandwidth."));
|
||||
matched.Add(new($"{featurePrefix}filter_bpf_order", bandPassOrder.ToString(CultureInfo.InvariantCulture), "Mapped Zyn band-pass family and stage count into AquaSynth band-pass order."));
|
||||
}
|
||||
if (notch > 0)
|
||||
{
|
||||
matched.Add(new($"{featurePrefix}filter_notch", F(notch), "Mapped static Zyn PAD global notch center into AquaSynth layer filtering."));
|
||||
matched.Add(new($"{featurePrefix}filter_notch_q", F(notchQ), "Mapped Zyn notch Q into AquaSynth notch width."));
|
||||
matched.Add(new($"{featurePrefix}filter_notch_order", notchOrder.ToString(CultureInfo.InvariantCulture), "Mapped Zyn notch family and stage count into AquaSynth notch order."));
|
||||
}
|
||||
if (lowPassEnvelope is not null)
|
||||
{
|
||||
matched.Add(new($"{featurePrefix}filter_lpf_envelope", "ratelevel", "Mapped Zyn PAD filter envelope octave offsets into AquaSynth low-pass cutoff motion."));
|
||||
|
|
@ -398,7 +416,9 @@ public static class ZynInstrumentReader
|
|||
: $" hpf_env=rl hpf_start={F(highPassEnvelope.StartLevel)} hpf_rates={F(highPassEnvelope.Rate1Seconds)},{F(highPassEnvelope.Rate2Seconds)},{F(highPassEnvelope.Rate3Seconds)},{F(highPassEnvelope.Rate4Seconds)} hpf_levels={F(highPassEnvelope.Level1)},{F(highPassEnvelope.Level2)},{F(highPassEnvelope.Level3)},{F(highPassEnvelope.Level4)} hpf_curves=lin,lin,lin,lin";
|
||||
var filterQText = lowPass < 1 ? $" lpf_q={F(lowPassQ)}" : "";
|
||||
var highPassText = highPass > 0 ? $" hpf={F(highPass)} hpf_order={highPassOrder}" : "";
|
||||
script.AppendLine($"layer name={safeName} engine=pad gain={F(layerGain)} lpf={F(lowPass)}{filterQText} lpf_order={lowPassOrder}{highPassText}{filterEnvelopeText}{highPassEnvelopeText} env=rl rates={F(attack)},{F(decay)},1,{F(release)} levels=1,1,1,0 curves=lin,lin,lin,lin gate=1.5");
|
||||
var bandPassText = bandPass > 0 ? $" bpf={F(bandPass)} bpf_q={F(bandPassQ)} bpf_order={bandPassOrder}" : "";
|
||||
var notchText = notch > 0 ? $" notch={F(notch)} notch_q={F(notchQ)} notch_order={notchOrder}" : "";
|
||||
script.AppendLine($"layer name={safeName} engine=pad gain={F(layerGain)} lpf={F(lowPass)}{filterQText} lpf_order={lowPassOrder}{highPassText}{bandPassText}{notchText}{filterEnvelopeText}{highPassEnvelopeText} 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(noteFrequencyHz)} spread=0 pad_mode={mode} pad_bandwidth={bandwidth} pad_bwscale={bandwidthScale} pad_profile={profile} pad_position={position} partials={partialText}");
|
||||
}
|
||||
|
||||
|
|
@ -1119,6 +1139,36 @@ public static class ZynInstrumentReader
|
|||
return Math.Clamp(MathF.Sqrt(cutoffHz / 7000.0f), 0f, 1f);
|
||||
}
|
||||
|
||||
private static float ZynPadBandPass(XElement? filter, float playbackFrequencyHz)
|
||||
{
|
||||
if (filter is null || !TryZynPadFilterCutoff(filter, playbackFrequencyHz, out var cutoffHz, out var category, out var type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!IsZynPadBandPassFilter(category, type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.Clamp(cutoffHz / 18000.0f, 20.0f / 18000.0f, 1f);
|
||||
}
|
||||
|
||||
private static float ZynPadNotch(XElement? filter, float playbackFrequencyHz)
|
||||
{
|
||||
if (filter is null || !TryZynPadFilterCutoff(filter, playbackFrequencyHz, out var cutoffHz, out var category, out var type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!IsZynPadNotchFilter(category, type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.Clamp(cutoffHz / 18000.0f, 20.0f / 18000.0f, 1f);
|
||||
}
|
||||
|
||||
private static int ZynPadHighPassOrder(XElement? filter)
|
||||
{
|
||||
if (filter is null)
|
||||
|
|
@ -1143,6 +1193,40 @@ public static class ZynInstrumentReader
|
|||
return Math.Clamp(poles * (DescendantIntParam(filter, "stages", 0) + 1), 1, 12);
|
||||
}
|
||||
|
||||
private static int ZynPadBandPassOrder(XElement? filter)
|
||||
{
|
||||
if (filter is null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var category = DescendantIntParam(filter, "category", 0);
|
||||
var type = DescendantIntParam(filter, "type", 0);
|
||||
if (!IsZynPadBandPassFilter(category, type))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Math.Clamp(2 * (DescendantIntParam(filter, "stages", 0) + 1), 1, 12);
|
||||
}
|
||||
|
||||
private static int ZynPadNotchOrder(XElement? filter)
|
||||
{
|
||||
if (filter is null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var category = DescendantIntParam(filter, "category", 0);
|
||||
var type = DescendantIntParam(filter, "type", 0);
|
||||
if (!IsZynPadNotchFilter(category, type))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Math.Clamp(2 * (DescendantIntParam(filter, "stages", 0) + 1), 1, 12);
|
||||
}
|
||||
|
||||
private static float ZynPadLowPassQ(XElement? filter)
|
||||
{
|
||||
if (filter is null)
|
||||
|
|
@ -1161,6 +1245,17 @@ public static class ZynInstrumentReader
|
|||
return MathF.Exp(q * q * MathF.Log(1000.0f)) - 0.9f;
|
||||
}
|
||||
|
||||
private static float ZynPadFilterQ(XElement? filter)
|
||||
{
|
||||
if (filter is null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var q = DescendantIntParam(filter, "q", 64) / 127.0f;
|
||||
return MathF.Exp(q * q * MathF.Log(1000.0f)) - 0.9f;
|
||||
}
|
||||
|
||||
private static bool TryZynPadFilterCutoff(XElement filter, float playbackFrequencyHz, out float cutoffHz, out int category, out int type)
|
||||
{
|
||||
category = DescendantIntParam(filter, "category", 0);
|
||||
|
|
@ -1185,6 +1280,14 @@ public static class ZynInstrumentReader
|
|||
(category == 0 && type is 1 or 3) ||
|
||||
(category == 2 && type == 1);
|
||||
|
||||
private static bool IsZynPadBandPassFilter(int category, int type) =>
|
||||
(category == 0 && type == 4) ||
|
||||
(category == 2 && type == 2);
|
||||
|
||||
private static bool IsZynPadNotchFilter(int category, int type) =>
|
||||
(category == 0 && type == 5) ||
|
||||
(category == 2 && type == 3);
|
||||
|
||||
private static RateLevelEnvelope? ZynPadLowPassEnvelope(XElement? filter, float baseLowPass)
|
||||
{
|
||||
var envelope = filter?.Element("FILTER_ENVELOPE");
|
||||
|
|
@ -1382,8 +1485,12 @@ public static class ZynInstrumentSurvey
|
|||
"cat=0 type=1",
|
||||
"cat=0 type=2",
|
||||
"cat=0 type=3",
|
||||
"cat=0 type=4",
|
||||
"cat=0 type=5",
|
||||
"cat=2 type=0",
|
||||
"cat=2 type=1"
|
||||
"cat=2 type=1",
|
||||
"cat=2 type=2",
|
||||
"cat=2 type=3"
|
||||
};
|
||||
|
||||
public static IReadOnlyList<ZynInstrumentSurveyItem> RankDirectory(string root, int take = 25)
|
||||
|
|
@ -1688,7 +1795,7 @@ public static class ZynInstrumentSurvey
|
|||
HandledPadGlobalFilters.Contains(filterKey) ? ZynCoverageStatus.Handled : ZynCoverageStatus.Unknown,
|
||||
relativePath,
|
||||
HandledPadGlobalFilters.Contains(filterKey)
|
||||
? "LP/HP PAD filters map to AquaSynth cutoff, order, Q, and envelope fields."
|
||||
? "PAD filter category/type maps to AquaSynth native filter fields."
|
||||
: "Observed PAD filter category/type is not translated by the current PAD rebuild path.");
|
||||
|
||||
foreach (var filterLfo in filter.Elements("FILTER_LFO"))
|
||||
|
|
|
|||
|
|
@ -93,3 +93,4 @@
|
|||
{"date":"2026-05-16","topic":"project-rename-aquasynth","lesson":"The C# synth repo is now AquaSynth and the Rust reference branch is AquaSynth-rs. Keep repo wiring, package metadata, namespaces, solution/project names, env vars, docs, and state aligned to AquaSynth; do not reintroduce AquariumSynthCSharp/AquariumSynth.Dsl names.","evidence":"Renamed solution to AquaSynth.slnx, projects to src/AquaSynth.Dsl and tests/AquaSynth.Dsl.Tests, namespaces/package to AquaSynth.Dsl, package version suffix to 0.1.0-aquasynth.1, DX7 env var to AQUASYNTH_DX7_PYTHON, and origin to https://github.com/GameCult/AquaSynth.git. Verified `dotnet build AquaSynth.slnx --no-restore`, `dotnet test tests\\AquaSynth.Dsl.Tests\\AquaSynth.Dsl.Tests.csproj --no-build -v minimal` with 108 passed, and `dotnet pack src\\AquaSynth.Dsl\\AquaSynth.Dsl.csproj -c Release --no-restore` producing AquaSynth.Dsl.0.1.0-aquasynth.1.nupkg."}
|
||||
{"date":"2026-05-16","topic":"zyn-coverage-map","lesson":"Zyn coverage must distinguish handled parity-backed behavior, counted pressure, and unknown subtypes. Broad parse success is inventory, not expressivity. The upstream GPL bank currently parses 1318/1318 files and yields 1459 enabled kit items / 63 layered instruments; PAD coverage is strongest, while ADD, SUB, active LFO routing, free envelopes, formant motion, effects, non-analog PAD filters, and several PAD OscilGen filter/waveshaper subtypes remain workout buckets.","evidence":"Added `ZynCoverageStatus`, `ZynCoverageBucket`, `ZynCoverageReport`, `ZynInstrumentSurvey.CoverageDirectory`, and `CoverageMarkdown`; `SurveysUpstreamGplInstrumentBankWhenAvailable` writes `artifacts/parity/zyn-upstream-bank-survey/coverage.md`. Focused ZynInstrumentTests passed 13/13."}
|
||||
{"date":"2026-05-16","topic":"zyn-pad-state-variable-filter","lesson":"Zyn PAD state-variable low-pass/high-pass filters are not a new Aqua authority. Category 2 type 0/1 maps cleanly onto existing `lpf`/`hpf` cutoff, Q, and order fields because Zyn `SVFilter` exposes low/high outputs and cascades `stages + 1`. Category 2 type 2/3 are band-pass/notch and must remain unknown until AquaSynth has a real band/notch filter owner.","evidence":"Mapped PAD filter `cat=2 type=0/1` in `ZynInstrumentReader`, moved those coverage buckets to handled, and added `RebuildMapsZynStateVariablePadLowPassToAquaFilterAuthority`. Focused ZynInstrumentTests passed 14/14."}
|
||||
{"date":"2026-05-16","topic":"native-bandpass-notch","lesson":"Band-pass and notch are ordinary AquaSynth filter authorities, not Zyn weirdness. `Filter` now owns `bpf`/`bpf_q`/`bpf_order` and `notch`/`notch_q`/`notch_order`; Zyn PAD analog and state-variable BPF/notch filters lower into those fields. Formants remain vowel/body color and PAD spectrum remains source-table construction.","evidence":"Added parser/model/Faust support for native BPF/notch, mapped Zyn PAD `cat=0 type=4/5` and `cat=2 type=2/3`, and added PatchScript plus ZynInstrument tests. Focused PatchScript/ZynInstrument tests passed 71/71."}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,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 AquaSynth 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. Zyn PAD `spectrum` banks can now carry explicit `zyn_mode`, `zyn_bandwidth`, `zyn_bwscale`, `zyn_profile`, and `zyn_position` table-generation fields, and `PadSynthWaveform` lowers those through Zyn-style profile/bandwidth math. 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, 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 AquaSynth 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 AquaSynth `spectrum` was not a close Zyn PAD emulation. User listening identified Zyn as pure wineglass and AquaSynth as angry bees. Cutting unearned air/noise/drive/soft-clip from the rebuild, adding interpolated wavetable reads, and raising AquaSynth 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, a handled/counted/unknown coverage map, and five upstream PAD listening fixtures under ignored artifacts. Coverage currently says PAD is the strongest exercised path, while ADD, SUB, active LFO routing, free envelopes, formant motion, effects, PAD formant/band/notch filters, and several PAD OscilGen filter/waveshaper subtypes remain workout buckets. Zyn PAD state-variable LP/HP filters now lower through existing AquaSynth cutoff/order/Q fields; state-variable band/notch still need a real filter authority before translation. `RebuildFirstPadAsAquaSynthScript` 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 AquaSynth 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. AquaSynth 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 AquaSynth 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 AquaSynth `spectrum` was not a close Zyn PAD emulation. User listening identified Zyn as pure wineglass and AquaSynth as angry bees. Cutting unearned air/noise/drive/soft-clip from the rebuild, adding interpolated wavetable reads, and raising AquaSynth 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, a handled/counted/unknown coverage map, and five upstream PAD listening fixtures under ignored artifacts. Coverage currently says PAD is the strongest exercised path, while ADD, SUB, active LFO routing, free envelopes, formant motion, effects, PAD formant/peak/shelf filters, and several PAD OscilGen filter/waveshaper subtypes remain workout buckets. Native AquaSynth filters now include `bpf` and `notch`; Zyn PAD analog and state-variable LP/HP/BPF/notch filters lower through existing cutoff/order/Q fields. `RebuildFirstPadAsAquaSynthScript` 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 AquaSynth 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. AquaSynth 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": "Continue Zyn PAD parity from the sampled OscilGen stage-order, multi-kit PAD, Zyn-curve static global-filter, low-pass/high-pass order, PAD frequency-detune, low-pass/high-pass filter-envelope, logarithmic Zyn envelope-time, generated Zyn PAD output-calibration, low-pass note tracking, explicit low-pass Q, Q+order cascade, one-based OscilGen oscillator-filter index, base-function-7 selected-table-root, base-function phase modulation, and adaptive-harmonics paths. Ghost Ensemble now expands its power-base multi-harmonic OscilGen source, applies Zyn filter note tracking from `freq_track`, emits `lpf_q` from the Zyn analog filter `q`, and preserves low-pass slope by cascading resonant Faust stages according to `lpf_order`; latest Ghost log-mel is 0.369402, envelope distance is 0.363685, RMS ratio is 1.054875, centroid ratio is 1.006808, and score is 0.57229. DoublePadBass is accepted by ear and latest survey reports log-mel 0.247674, envelope distance 0.208351, RMS ratio 0.888011, score 0.650319. Soft Pad is accepted by ear. Organ Choir now maps kit0 HP2/stage/filter-envelope motion and kit1's selected table root, `base_function_modulation=1`, and `adaptive_harmonics=1`; latest Organ log-mel is 0.471483, envelope distance 0.302978, RMS ratio 0.878, centroid ratio 1.011328, and score 0.541933. Its kit1 PAD table energy now matches the wind-body shape much more closely: 400-800 Hz 0.2713 vs Zyn 0.2780 and 8-16 kHz 0.1471 vs Zyn 0.1355. ZynPadReference has test-only `harmonics` and `selected` modes; selected roots are diagnostic/source-specific, not a global default, because global selected roots regressed accepted DoublePadBass. sin2x remains loud/concentrated after the one-based filter-index fix, so do not claim full Zyn PAD parity until broader OscilGen filtering/waveshaping/adaptive-harmonic behavior and note/global filter LFO ownership are mapped or deliberately excluded."
|
||||
},
|
||||
"note_and_envelope_model": {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ live_invariants:
|
|||
- PAD `spectrum` declarations own authored partial clouds under named layers and split table root from playback pitch: `root` is source/base frequency, while `freq` is the note played by the spectral voice. They generate PADsynth-style FFT wavetables with frequency-domain spreading and deterministic random phase, then emit Faust table readers before ordinary voice treatment. Richer PAD table shaping uses neutral `pad_mode`, `pad_bandwidth`, `pad_bwscale`, `pad_profile`, and `pad_position` syntax. The parser may accept older `zyn_*` parity-artifact aliases, but generated/authored `.aqua` should not expose reference-synth names for general DSP intent. Do not pretend this covers every Zyn OscilGen modulation/waveshaping/filter/adaptive-harmonic path yet.
|
||||
- Zyn OscilGen oscillator filters use one-based harmonic indices: first harmonic is `1`, not `0`. Preserve that index when translating filter types or spectral peaks move to the wrong partial.
|
||||
- Zyn PAD analog high-pass filters are filter authority too: HP1/HP2 type, stages, and FILTER_ENVELOPE motion lower through `hpf_order` and `hpf_env=rl`, not ad hoc layer gain or brightness compensation.
|
||||
- Zyn PAD state-variable LP/HP filters (`category=2`, `type=0/1`) are still cutoff/order/Q authority and lower through the existing AquaSynth `lpf`/`hpf` fields. State-variable band/notch (`type=2/3`) remain unknown until a band/notch filter authority earns itself.
|
||||
- Zyn PAD state-variable filters (`category=2`) are filter authority: LP/HP (`type=0/1`) lower through `lpf`/`hpf`, and band/notch (`type=2/3`) lower through `bpf`/`notch`.
|
||||
- Band-pass and notch are native AquaSynth filter authorities (`bpf`, `bpf_q`, `bpf_order`, `notch`, `notch_q`, `notch_order`), not Zyn-only compatibility. Zyn PAD analog/SV band-pass and notch filters lower into those fields; formants remain vowel/body color and PAD spectrum remains source-table construction.
|
||||
- Zyn PAD selected table roots are not a global default in AquaSynth lowering. Keep sample-0 roots unless a source rule earns the selected root; currently OscilGen shift-base sources (`base_function=7`) may use the selected note table root because Organ Choir proved sample-0 roots leave the octave voice misaligned.
|
||||
- Zyn OscilGen base-function modulation is source-table authority: apply it as phase modulation before base-function sampling, not as later oscillator modulation or filter/EQ compensation.
|
||||
- Zyn adaptive harmonics remap the prepared oscillator spectrum at the PAD table root frequency before PAD bandwidth/profile spreading. Do not skip it for sources whose wind/body character depends on sparse remapped harmonics.
|
||||
|
|
|
|||
|
|
@ -427,6 +427,23 @@ public sealed class PatchScriptTests
|
|||
Assert.Contains(") : fi.resonlp(max(20.0, clip01(0.3", export.Source);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BandPassAndNotchParseAndExportAsFilterAuthority()
|
||||
{
|
||||
var patch = PatchScript.Parse("v w=saw f=220 bpf=.35 bpf_q=4 bpf_order=3 notch=.6 notch_q=8 notch_order=2");
|
||||
var export = FaustEmitter.Emit(patch);
|
||||
|
||||
var voice = Assert.Single(patch.Voices);
|
||||
Assert.Equal(.35f, voice.Filter.BandPass, 5);
|
||||
Assert.Equal(4, voice.Filter.BandPassQ, 5);
|
||||
Assert.Equal(3, voice.Filter.BandPassOrder);
|
||||
Assert.Equal(.6f, voice.Filter.Notch, 5);
|
||||
Assert.Equal(8, voice.Filter.NotchQ, 5);
|
||||
Assert.Equal(2, voice.Filter.NotchOrder);
|
||||
Assert.Contains("fi.resonbp(max(20.0, clip01(0.35) * 18000.0), max(0.1, 4), 1.0)", export.Source);
|
||||
Assert.Contains("fi.notchw(max(1.0, (max(20.0, clip01(0.6) * 18000.0)) / max(0.1, 8)), max(20.0, clip01(0.6) * 18000.0))", export.Source);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SpectralBankSeparatesTableRootFromPlaybackFrequency()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -270,6 +270,27 @@ public sealed class ZynInstrumentTests
|
|||
Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "pad_filter_lpf_order" && feature.Value == "3");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RebuildMapsZynStateVariablePadBandAndNotchToAquaFilterAuthority()
|
||||
{
|
||||
var band = ZynInstrumentReader.RebuildFirstPadAsAquaSynthScript(Encoding.UTF8.GetBytes(ZynPadWithFilter(category: 2, type: 2)), tableRootFrequencyHz: 77.7813f);
|
||||
var notch = ZynInstrumentReader.RebuildFirstPadAsAquaSynthScript(Encoding.UTF8.GetBytes(ZynPadWithFilter(category: 2, type: 3)), tableRootFrequencyHz: 77.7813f);
|
||||
|
||||
var bandVoice = Assert.Single(PatchScript.Parse(band.Script).SpectralBanks).Treatment;
|
||||
Assert.True(bandVoice.Filter.BandPass > 0);
|
||||
Assert.True(bandVoice.Filter.BandPassQ > 0);
|
||||
Assert.Equal(6, bandVoice.Filter.BandPassOrder);
|
||||
Assert.Equal(0, bandVoice.Filter.Notch);
|
||||
Assert.Contains(band.MatchedFeatures, feature => feature.Name == "pad_filter_bpf");
|
||||
|
||||
var notchVoice = Assert.Single(PatchScript.Parse(notch.Script).SpectralBanks).Treatment;
|
||||
Assert.True(notchVoice.Filter.Notch > 0);
|
||||
Assert.True(notchVoice.Filter.NotchQ > 0);
|
||||
Assert.Equal(6, notchVoice.Filter.NotchOrder);
|
||||
Assert.Equal(0, notchVoice.Filter.BandPass);
|
||||
Assert.Contains(notch.MatchedFeatures, feature => feature.Name == "pad_filter_notch");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SurveysUpstreamGplInstrumentBankWhenAvailable()
|
||||
{
|
||||
|
|
@ -370,8 +391,8 @@ public sealed class ZynInstrumentTests
|
|||
</OSCIL>
|
||||
<FILTER_PARAMETERS>
|
||||
<FILTER>
|
||||
<par name="category" value="2"/>
|
||||
<par name="type" value="3"/>
|
||||
<par name="category" value="1"/>
|
||||
<par name="type" value="0"/>
|
||||
</FILTER>
|
||||
<FILTER_LFO>
|
||||
<par name="intensity" value="40"/>
|
||||
|
|
@ -425,7 +446,7 @@ public sealed class ZynInstrumentTests
|
|||
bucket.Key == "14");
|
||||
Assert.Contains(report.UnknownBuckets, bucket =>
|
||||
bucket.Area == "pad.filter" &&
|
||||
bucket.Key == "cat=2 type=3");
|
||||
bucket.Key == "cat=1 type=0");
|
||||
Assert.Contains(report.CountedBuckets, bucket =>
|
||||
bucket.Area == "pad.filter_lfo" &&
|
||||
bucket.Key == "intensity=40");
|
||||
|
|
@ -442,6 +463,38 @@ public sealed class ZynInstrumentTests
|
|||
private static string FixturePath(params string[] parts) =>
|
||||
Path.Combine([AppContext.BaseDirectory, "Fixtures", .. parts]);
|
||||
|
||||
private static string ZynPadWithFilter(int category, int type) =>
|
||||
$$"""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ZynAddSubFX-data>
|
||||
<INSTRUMENT>
|
||||
<INFO><string name="name">Filter PAD</string></INFO>
|
||||
<INSTRUMENT_KIT>
|
||||
<INSTRUMENT_KIT_ITEM id="0">
|
||||
<par_bool name="enabled" value="yes"/>
|
||||
<par_bool name="pad_enabled" value="yes"/>
|
||||
<PAD_SYNTH_PARAMETERS>
|
||||
<OSCIL>
|
||||
<HARMONICS>
|
||||
<HARMONIC id="1"><par name="mag" value="127"/></HARMONIC>
|
||||
</HARMONICS>
|
||||
</OSCIL>
|
||||
<FILTER_PARAMETERS>
|
||||
<FILTER>
|
||||
<par name="category" value="{{category}}"/>
|
||||
<par name="type" value="{{type}}"/>
|
||||
<par name="freq" value="48"/>
|
||||
<par name="q" value="32"/>
|
||||
<par name="stages" value="2"/>
|
||||
</FILTER>
|
||||
</FILTER_PARAMETERS>
|
||||
</PAD_SYNTH_PARAMETERS>
|
||||
</INSTRUMENT_KIT_ITEM>
|
||||
</INSTRUMENT_KIT>
|
||||
</INSTRUMENT>
|
||||
</ZynAddSubFX-data>
|
||||
""";
|
||||
|
||||
private static string RepositoryRoot()
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
|
|
|
|||
Loading…
Reference in a new issue