Add PAD spectral cloud DSL surface
This commit is contained in:
parent
bfd1e19e5b
commit
ff43eef5e3
11 changed files with 212 additions and 23 deletions
|
|
@ -832,9 +832,8 @@ public static class BuiltInScripts
|
|||
layer name=pad_high engine=pad min_key=48 max_key=108 gain=0.044 vibrato=0.009 vibrato_hz=0.11 env=rl rates=0.42,0.58,0.9,1.25 levels=1,0.84,0.72,0 curves=lin,exp,lin,lin gate=1.9
|
||||
layer name=air engine=add min_key=0 max_key=127 gain=0.018 wave=noise noise=0.82 env=rl rates=0.8,0.6,1.1,1.1 levels=1,0.82,0.55,0 curves=lin,lin,exp,lin gate=2.5 lpf=0.36 hpf=0.22
|
||||
|
||||
voice layer=pad_low freq=130.8128
|
||||
voice layer=pad_low freq=196 gain=0.052 vibrato=0.012 vibrato_hz=0.13
|
||||
voice layer=pad_high freq=261.6256 wave=triangle
|
||||
spectrum layer=pad_low root=130.8128 spread=0.012 partials=1:0.07,1.5:0.052
|
||||
spectrum layer=pad_high root=261.6256 spread=0.009 partials=1:0.044 wave=triangle
|
||||
voice layer=air freq=1800
|
||||
""";
|
||||
|
||||
|
|
|
|||
|
|
@ -201,6 +201,12 @@ public sealed record HarmonicBank(
|
|||
float RootFrequencyHz,
|
||||
IReadOnlyList<HarmonicPartial> Partials);
|
||||
|
||||
public sealed record SpectralBank(
|
||||
string LayerName,
|
||||
float RootFrequencyHz,
|
||||
float SpreadRatio,
|
||||
IReadOnlyList<HarmonicPartial> Partials);
|
||||
|
||||
public sealed record ReferencePatch(
|
||||
string Id,
|
||||
string Family,
|
||||
|
|
@ -236,6 +242,7 @@ public sealed record SynthPatch
|
|||
public IReadOnlyList<Voice> Voices { get; init; } = Array.Empty<Voice>();
|
||||
public IReadOnlyList<PatchLayer> Layers { get; init; } = Array.Empty<PatchLayer>();
|
||||
public IReadOnlyList<HarmonicBank> HarmonicBanks { get; init; } = Array.Empty<HarmonicBank>();
|
||||
public IReadOnlyList<SpectralBank> SpectralBanks { get; init; } = Array.Empty<SpectralBank>();
|
||||
public IReadOnlyList<OperatorGraph> OperatorGraphs { get; init; } = Array.Empty<OperatorGraph>();
|
||||
public IReadOnlyList<ControlLane> Controls { get; init; } = Array.Empty<ControlLane>();
|
||||
public IReadOnlyList<PatchParameter> Parameters { get; init; } = Array.Empty<PatchParameter>();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public static class PatchScript
|
|||
private readonly List<ParameterBinding> _parameterBindings = [];
|
||||
private readonly List<PatchLayer> _layers = [];
|
||||
private readonly List<HarmonicBank> _harmonicBanks = [];
|
||||
private readonly List<SpectralBank> _spectralBanks = [];
|
||||
private readonly Dictionary<string, string> _defaults = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, Dictionary<string, string>> _layerDefaults = new(StringComparer.OrdinalIgnoreCase);
|
||||
private PendingOperatorGraph? _pendingOperatorGraph;
|
||||
|
|
@ -56,6 +57,7 @@ public static class PatchScript
|
|||
Voices = Voices,
|
||||
Layers = _layers,
|
||||
HarmonicBanks = _harmonicBanks,
|
||||
SpectralBanks = _spectralBanks,
|
||||
OperatorGraphs = _operatorGraphs,
|
||||
Controls = _controls,
|
||||
Parameters = _parameters,
|
||||
|
|
@ -103,6 +105,10 @@ public static class PatchScript
|
|||
FlushPendingOperatorGraph();
|
||||
AddHarmonicBank(fields, line);
|
||||
break;
|
||||
case "spectrum":
|
||||
FlushPendingOperatorGraph();
|
||||
AddSpectralBank(fields, line);
|
||||
break;
|
||||
case "voice":
|
||||
FlushPendingOperatorGraph();
|
||||
Voices.Add(ParseVoice(ExpandVoiceFields(fields, line), Voices.Count, line));
|
||||
|
|
@ -188,6 +194,79 @@ public static class PatchScript
|
|||
}
|
||||
}
|
||||
|
||||
private void AddSpectralBank(IReadOnlyDictionary<string, string> fields, int line)
|
||||
{
|
||||
var layerName = Required(fields, "layer", line);
|
||||
if (!_layerDefaults.ContainsKey(layerName))
|
||||
{
|
||||
throw new PatchScriptException(line, $"unknown layer `{layerName}`");
|
||||
}
|
||||
|
||||
var rootFrequency = GetFloat(fields, line, 440, "root", "base", "freq", "frequency");
|
||||
if (rootFrequency <= 0)
|
||||
{
|
||||
throw new PatchScriptException(line, "spectral root frequency must be greater than zero");
|
||||
}
|
||||
|
||||
var spread = GetFloat(fields, line, 0, "spread", "width", "detune");
|
||||
if (spread is < 0 or >= 1)
|
||||
{
|
||||
throw new PatchScriptException(line, "spectral spread must be at least zero and less than one");
|
||||
}
|
||||
|
||||
var partials = ParseHarmonicPartials(
|
||||
GetAny(fields, ["partials", "bank", "tones"], ""),
|
||||
line);
|
||||
if (partials.Count == 0)
|
||||
{
|
||||
throw new PatchScriptException(line, "spectrum needs at least one partial");
|
||||
}
|
||||
|
||||
_spectralBanks.Add(new SpectralBank(layerName, rootFrequency, spread, partials));
|
||||
|
||||
var sharedFields = Without(fields,
|
||||
"layer",
|
||||
"root",
|
||||
"base",
|
||||
"freq",
|
||||
"frequency",
|
||||
"spread",
|
||||
"width",
|
||||
"detune",
|
||||
"partials",
|
||||
"bank",
|
||||
"tones",
|
||||
"gain",
|
||||
"g");
|
||||
foreach (var partial in partials)
|
||||
{
|
||||
if (spread == 0)
|
||||
{
|
||||
AddSpectralVoice(sharedFields, layerName, rootFrequency * partial.Ratio, partial.Gain, line);
|
||||
continue;
|
||||
}
|
||||
|
||||
AddSpectralVoice(sharedFields, layerName, rootFrequency * partial.Ratio * (1 - spread), partial.Gain * 0.5f, line);
|
||||
AddSpectralVoice(sharedFields, layerName, rootFrequency * partial.Ratio * (1 + spread), partial.Gain * 0.5f, line);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSpectralVoice(
|
||||
IReadOnlyDictionary<string, string> sharedFields,
|
||||
string layerName,
|
||||
float frequency,
|
||||
float gain,
|
||||
int line)
|
||||
{
|
||||
var voiceFields = new Dictionary<string, string>(sharedFields, StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["layer"] = layerName,
|
||||
["freq"] = F(frequency),
|
||||
["gain"] = F(gain)
|
||||
};
|
||||
Voices.Add(ParseVoice(ExpandVoiceFields(voiceFields, line), Voices.Count, line));
|
||||
}
|
||||
|
||||
private Dictionary<string, string> ExpandVoiceFields(Dictionary<string, string> fields, int line)
|
||||
{
|
||||
var expanded = new Dictionary<string, string>(_defaults, StringComparer.OrdinalIgnoreCase);
|
||||
|
|
@ -982,6 +1061,7 @@ public static class PatchScript
|
|||
"def" or "t" or "template" => "template",
|
||||
"layer" or "kit" => "layer",
|
||||
"harmonics" or "partials" or "drawbars" => "harmonics",
|
||||
"spectrum" or "spectral" or "padsource" or "pad_source" => "spectrum",
|
||||
"v" or "voice" => "voice",
|
||||
"opgraph" or "ops" or "operators" => "opgraph",
|
||||
"operator" or "op" => "operator",
|
||||
|
|
|
|||
|
|
@ -42,16 +42,17 @@ public static class ReferenceRebuildCatalog
|
|||
[
|
||||
new("engine_pad", "1", "Approximated as slow layered oscillators plus an air/noise layer."),
|
||||
new("named_layers", "pad_low,pad_high,air", "Layer declarations separate PAD body from air/noise texture."),
|
||||
new("pad_spectral_source", "2 spectral banks / 3 partials", "PAD layers declare spectral partial clouds before lowering to detuned Aquarium voices."),
|
||||
new("filter_count", "1", "Represented with low-pass/high-pass field sites."),
|
||||
new("free_envelope_count", "1", "Approximated with staged voice rate/level envelopes and macro spread."),
|
||||
new("voice_rate_level_envelope", "3", "PAD body and air layers use staged rate/level envelopes attached through layer defaults."),
|
||||
new("slow_modulation", "patch_lfo", "The rebuild adds slow patch modulation because PAD texture wants motion even though the minimal fixture only marks PAD/filter/free-envelope pressure.")
|
||||
],
|
||||
[
|
||||
new("pad_spectral_source", "PADsynth wavetable/spectral generation", "Aquarium has no PAD-style spectral source; this rebuild is a texture approximation."),
|
||||
new("padsynth_wavetable_exactness", "PADsynth FFT/wavetable generation", "Aquarium has spectral source syntax, but it lowers to detuned voices rather than generating a PADsynth wavetable."),
|
||||
new("free_envelope_shape", "arbitrary Zyn envelope points", "Aquarium has staged voice envelopes now, but not arbitrary point/free-mode Zyn envelope curves.")
|
||||
],
|
||||
"This is pressure, not a claim of PAD parity. The current voice DSL can sketch the texture, but PAD-style spectral generation deserves its own source authority if repeated targets need it."),
|
||||
"This is pressure, not a claim of PADsynth parity. Aquarium can now state a layered spectral cloud, while exact PAD wavetable generation remains separate pressure."),
|
||||
new(
|
||||
"zyn/project-vocal-layer/aquarium",
|
||||
"zynaddsubfx",
|
||||
|
|
|
|||
Loading…
Reference in a new issue