Render operator feedback through Faust
This commit is contained in:
parent
c4c5472521
commit
5d2818f499
7 changed files with 60 additions and 16 deletions
|
|
@ -345,13 +345,7 @@ public static class FaustEmitter
|
|||
.Where(edge => edge.TargetId == op.Id && operatorIds.Contains(edge.SourceId))
|
||||
.Select(edge => $"{name}_op_{edge.SourceId} * {parameters.Expression($"{graphPath}/routes/{edge.SourceId}>{edge.TargetId}/index", edge.Index)}")
|
||||
.ToList();
|
||||
if (op.Feedback != 0)
|
||||
{
|
||||
incoming.Add($"{opName} * {parameters.Expression($"{operatorPath}/feedback", op.Feedback)} : si.smoo");
|
||||
warnings.Add($"{name}: operator {op.Id} feedback is approximated with smoothed self-reference");
|
||||
}
|
||||
|
||||
var phaseMod = incoming.Count == 0 ? "0.0" : string.Join(" + ", incoming);
|
||||
var externalPhaseMod = incoming.Count == 0 ? "0.0" : string.Join(" + ", incoming);
|
||||
var envelope = EnvelopeExpression(
|
||||
op.Envelope,
|
||||
UsesHostPlayback(playback) || op.Note.Source == NoteSource.Host ? graphNoteGate : F(op.Note.GateSeconds),
|
||||
|
|
@ -364,7 +358,15 @@ public static class FaustEmitter
|
|||
"env/release" => parameters.Expression($"{operatorPath}/env/release", op.Envelope.ReleaseSeconds),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(field), field, null)
|
||||
});
|
||||
source.AppendLine($"{opName} = sin(2.0 * ma.PI * (os.phasor(1.0, {name}_freq * max(0.0, {parameters.Expression($"{operatorPath}/ratio", op.Ratio)})) + ({phaseMod}) / ma.PI)) * {envelope} * {parameters.Expression($"{operatorPath}/level", op.Level)};");
|
||||
if (op.Feedback != 0)
|
||||
{
|
||||
var feedback = parameters.Expression($"{operatorPath}/feedback", op.Feedback);
|
||||
source.AppendLine($"{opName} = ((_ * {feedback} + ({externalPhaseMod})) : \\(pm).(sin(2.0 * ma.PI * (os.phasor(1.0, {name}_freq * max(0.0, {parameters.Expression($"{operatorPath}/ratio", op.Ratio)})) + pm / ma.PI)) * {envelope} * {parameters.Expression($"{operatorPath}/level", op.Level)})) ~ _;");
|
||||
}
|
||||
else
|
||||
{
|
||||
source.AppendLine($"{opName} = sin(2.0 * ma.PI * (os.phasor(1.0, {name}_freq * max(0.0, {parameters.Expression($"{operatorPath}/ratio", op.Ratio)})) + ({externalPhaseMod}) / ma.PI)) * {envelope} * {parameters.Expression($"{operatorPath}/level", op.Level)};");
|
||||
}
|
||||
}
|
||||
|
||||
source.AppendLine($"{name} = ({string.Join(" + ", carrierIds.Select(id => $"{name}_op_{id}"))}) * {parameters.Expression($"{graphPath}/gain", graph.Gain)};");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public static class ReferenceRebuildCatalog
|
|||
new("operator_envelope_approximation", "DX7 EG -> ADSR", "DX7 four-rate/four-level envelopes can now be lowered to labeled ADSR approximations.")
|
||||
],
|
||||
[
|
||||
new("dx7_feedback_register", "one-sample feedback register", "Aquarium operator feedback currently uses a smoothed self-reference approximation, not exact DX7 feedback register timing."),
|
||||
new("dx7_feedback_register", "DX7 feedback scaling/register details", "Aquarium operator feedback is now renderable as a one-sample delayed self-reference, but not calibrated to exact DX7 feedback scaling."),
|
||||
new("operator_envelope_exactness", "independent DX7 rate/level envelopes", "Aquarium has per-operator ADSR approximation, not exact DX7 EG execution.")
|
||||
],
|
||||
"This patch is deliberately a pressure test. The new operator graph owns the topology; exact DX7 envelope and feedback-register behavior remain pressure for later refinement."),
|
||||
|
|
|
|||
|
|
@ -23,3 +23,4 @@
|
|||
{"kind":"reference_parity_doctrine","lesson":"External synth references exist to exercise Aquarium DSL expressiveness, not to clone foreign internals. Consume only references that can be backed by parity tests proving Aquarium can reproduce the behavior in terse, readable syntax; parsing a format is inventory, not evidence.","source":"user clarified reference-synth purpose and parity-test requirement on 2026-05-13"}
|
||||
{"kind":"dx7_reference_rendering","lesson":"DX7 reference rendering now uses dexed-py as optional test tooling against a public-domain SysEx fixture. Keep fixtures and renderer helpers under the test project, preserve provenance and SHA-256 beside vendored banks, and keep AquariumSynth.Dsl.nupkg free of SysEx/Python/test assets.","source":"dexed-py public-domain fixture harness slice on 2026-05-13"}
|
||||
{"kind":"dx7_rendered_parity","lesson":"The first thresholded rendered DX7 parity target is analog1.syx voice 13, MC-MM 5-3. Aquarium matches the rendered behavior with a short sine-like patch and explicit score/log-mel/envelope/duration/RMS/zero-crossing/centroid thresholds. Treat this as proof of the parity loop, not proof of exact DX7 operator execution; next target should audibly require operator routing.","source":"first thresholded DX7 rendered parity slice on 2026-05-13"}
|
||||
{"kind":"operator_feedback","lesson":"A harder DX7 algorithm-8 target exposed direct operator self-reference as non-renderable Faust. Operator feedback now emits as delayed Faust recursion, which keeps the render path alive and is closer to DX7 feedback pressure; exact DX7 feedback scaling remains unsolved.","source":"PRC SYNTH1 parity probe and delayed feedback render fix on 2026-05-13"}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
"own_here": [
|
||||
"patch graph model",
|
||||
"operator graph model",
|
||||
"renderable delayed operator feedback",
|
||||
"patch parameter contracts",
|
||||
"reference patch contracts",
|
||||
"test-only public-domain DX7 fixtures",
|
||||
|
|
@ -56,9 +57,9 @@
|
|||
"rule": "Add DSL abstractions only when reference rebuilds prove the missing invariant. Do not consume references that cannot be backed by parity tests; parsing alone is inventory, not evidence of expressivity."
|
||||
},
|
||||
"dx7_reference_path": {
|
||||
"status": "DX7 SysEx parser extracts voice edit buffers, packed voices, packed 32-voice banks, six operators, envelopes, algorithm, feedback, oscillator sync, LFO, transpose, voice name, checksum validation, ReferencePatch features, algorithm topology from the reverse-engineered OPS algorithm ROM table, envelope-to-ADSR approximations, two Aquarium DSL rebuild attempts, first-class OperatorGraph support, public-domain SysEx fixture coverage, dexed-py reference rendering, Aquarium candidate rendering through Faust-generated C#, and one thresholded rendered parity test for analog1.syx voice 13.",
|
||||
"lesson": "Algorithm 32's additive six-carrier shape maps cleanly to six Aquarium voices. Algorithm 8 justified OperatorGraph: operators, modulation edges, carriers, and feedback belong to a graph authority, not Voice fields. The first rendered parity rung is behavioral and sine-like, not exact DX7 operator execution. Readable authoring uses operator/route/carrier declarations; compact ops/edges tuples are scaffolding only.",
|
||||
"next": "Choose a harder public-domain DX7 fixture voice whose rendered audio needs audible operator routing, rebuild it with a readable Aquarium operator graph, and add explicit parity thresholds; exact DX7 feedback-register timing and exact DX7 EG execution remain separate pressure."
|
||||
"status": "DX7 SysEx parser extracts voice edit buffers, packed voices, packed 32-voice banks, six operators, envelopes, algorithm, feedback, oscillator sync, LFO, transpose, voice name, checksum validation, ReferencePatch features, algorithm topology from the reverse-engineered OPS algorithm ROM table, envelope-to-ADSR approximations, two Aquarium DSL rebuild attempts, first-class OperatorGraph support, public-domain SysEx fixture coverage, dexed-py reference rendering, Aquarium candidate rendering through Faust-generated C#, one thresholded rendered parity test for analog1.syx voice 13, and renderable delayed operator feedback.",
|
||||
"lesson": "Algorithm 32's additive six-carrier shape maps cleanly to six Aquarium voices. Algorithm 8 justified OperatorGraph: operators, modulation edges, carriers, and feedback belong to a graph authority, not Voice fields. The first rendered parity rung is behavioral and sine-like, not exact DX7 operator execution. A harder algorithm-8 target exposed that feedback must be delayed recursion in Faust, not a direct cyclic self-reference. Readable authoring uses operator/route/carrier declarations; compact ops/edges tuples are scaffolding only.",
|
||||
"next": "Choose a harder public-domain DX7 fixture voice whose rendered audio needs audible operator routing, rebuild it with delayed feedback available, and add explicit parity thresholds; exact DX7 feedback scaling and exact DX7 EG execution remain separate pressure."
|
||||
},
|
||||
"note_and_envelope_model": {
|
||||
"rule": "Notes own frequency, gate duration, and host/MIDI source. Envelopes own ADSR level shape.",
|
||||
|
|
@ -73,7 +74,7 @@
|
|||
},
|
||||
"last_verified": {
|
||||
"command": "dotnet test AquariumSynthCSharp.slnx --no-restore",
|
||||
"result": "48 passed",
|
||||
"commit": "pending first thresholded DX7 rendered parity"
|
||||
"result": "49 passed",
|
||||
"commit": "pending delayed operator feedback render fix"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,18 @@ Doctrine update:
|
|||
|
||||
Completed this slice:
|
||||
|
||||
- Tried the harder `analog1.syx` voice 17, `PRC SYNTH1` (algorithm 8). The
|
||||
initial routed Aquarium candidate scored badly (~0.23), which exposed a real
|
||||
missing invariant rather than a threshold-tuning problem.
|
||||
- Reworked operator feedback emission from a cyclic smoothed self-reference to
|
||||
a renderable Faust feedback expression using delayed recursion. Added
|
||||
`FaustCompilerRendersOperatorFeedbackWhenInstalled`.
|
||||
- Exact DX7 feedback scaling and EG behavior are still not solved, but feedback
|
||||
no longer makes the Faust render path fall over.
|
||||
- Verified with `dotnet test AquariumSynthCSharp.slnx --no-restore`: 49 passed.
|
||||
|
||||
Previous slice:
|
||||
|
||||
- Added the first thresholded DX7 rendered-audio parity rebuild:
|
||||
`BuiltInScripts.Dx7StylePublicDomainMcMm53` maps public-domain
|
||||
`analog1.syx` voice 13, `MC-MM 5-3`, to a terse Aquarium sine patch.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
project: AquariumSynthCSharp
|
||||
spine_version: 1
|
||||
updated: 2026-05-13T14:37:00+01:00
|
||||
updated: 2026-05-13T15:16:00+01:00
|
||||
|
||||
prime_directive: >
|
||||
Build coherent synth machinery. References exist to reveal missing structure,
|
||||
|
|
@ -41,6 +41,7 @@ live_invariants:
|
|||
- Exposed patch parameters are runtime controls, not compile-time constants.
|
||||
- Parameter binding uses field-site references like `lpf=@/macro/brightness`; do not add target-routing semantics unless a later map proves a new authority is needed.
|
||||
- Operator graph parameter binding also uses exact field-site paths under `/opgraphs/...`; do not add graph-wide macro routing.
|
||||
- Operator feedback must render through Faust as delayed recursion, not as a direct cyclic self-reference.
|
||||
- DX7 rate/level envelopes may lower to labeled ADSR approximations, but exact DX7 EG execution remains missing pressure.
|
||||
- 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.
|
||||
|
|
@ -55,7 +56,7 @@ reference_targets:
|
|||
priority: 1
|
||||
purpose: "Structured FM/operator graph pressure test."
|
||||
source: "https://github.com/asb2m10/dexed"
|
||||
status: "DX7 SysEx parser, public-domain SysEx fixture, dexed-py reference rendering, first thresholded rendered parity test for analog1.syx voice 13, algorithm topology extraction, envelope-to-ADSR approximation, two Aquarium DSL rebuild attempts, first-class operator graph support, and Aquarium candidate rendering through Faust-generated C# exist."
|
||||
status: "DX7 SysEx parser, public-domain SysEx fixture, dexed-py reference rendering, first thresholded rendered parity test for analog1.syx voice 13, renderable delayed operator feedback, algorithm topology extraction, envelope-to-ADSR approximation, two Aquarium DSL rebuild attempts, first-class operator graph support, and Aquarium candidate rendering through Faust-generated C# exist."
|
||||
first_slice:
|
||||
- "Add a harder public-domain DX7 parity target that audibly needs operator routing."
|
||||
zynaddsubfx:
|
||||
|
|
@ -106,6 +107,14 @@ next_agent_start_here:
|
|||
- "dotnet test AquariumSynthCSharp.slnx --no-restore"
|
||||
|
||||
completed_slices:
|
||||
- date: 2026-05-13
|
||||
summary: >
|
||||
Probed the harder `analog1.syx` voice 17 (`PRC SYNTH1`) and found the
|
||||
routed candidate failed badly instead of being thresholdable. The useful
|
||||
cut was feedback: operator feedback now emits as Faust delayed recursion
|
||||
instead of a direct cyclic self-reference, and a render test covers it.
|
||||
Exact DX7 feedback scaling and EG behavior remain pressure.
|
||||
verification: "dotnet test AquariumSynthCSharp.slnx --no-restore: 49 passed"
|
||||
- date: 2026-05-13
|
||||
summary: >
|
||||
Added the first thresholded rendered DX7 parity rebuild for
|
||||
|
|
|
|||
|
|
@ -509,4 +509,23 @@ public sealed class PatchScriptTests
|
|||
.Compare(render.Samples, render.Samples);
|
||||
Assert.True(comparison.Score > 0.99f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FaustCompilerRendersOperatorFeedbackWhenInstalled()
|
||||
{
|
||||
var export = FaustEmitter.EmitScript("""
|
||||
opgraph name=fb freq=220 gain=.2
|
||||
operator name=op1 ratio=1 level=1 feedback=.2 env=ad:.01:.1
|
||||
carrier name=op1
|
||||
""");
|
||||
var render = await FaustCompiler.RenderAsync(export.Source, new FaustRenderOptions(DurationSeconds: .1f));
|
||||
|
||||
if (render is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.True(render.Samples.Length > 1000, render.Stderr);
|
||||
Assert.True(render.Samples.Max(MathF.Abs) > 0.001f, render.Stderr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue