From 4005fe357e2ba63d5a32999fbb596749db67a063 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 14 May 2026 15:24:22 +0100 Subject: [PATCH] Honor DX7 voice transpose in parity lowering --- docs/dx7-calibration-plan.md | 24 ++++++++++++------- src/AquariumSynth.Dsl/Dx7SysEx.cs | 6 +++++ state/evidence.jsonl | 3 ++- state/memory.json | 10 ++++---- state/scratch.md | 17 +++++++++++++ state/spine.yaml | 19 +++++++++++++-- .../Dx7ReferenceParityTests.cs | 17 +++++++------ .../AquariumSynth.Dsl.Tests/Dx7SysExTests.cs | 8 +++++++ 8 files changed, 78 insertions(+), 26 deletions(-) diff --git a/docs/dx7-calibration-plan.md b/docs/dx7-calibration-plan.md index 73b0d81..513e4ab 100644 --- a/docs/dx7-calibration-plan.md +++ b/docs/dx7-calibration-plan.md @@ -109,15 +109,21 @@ math is still fake in the places that matter perceptually. 9. **Community voice survey** - Use public-domain community SysEx fixtures as broader behavioral probes after each isolated calibration rung. - - `analog1.syx` from Musical Artifacts artifact 152 now has a broad rendered - parity test for four actual community voices: `ANLGSYN 1`, `{ Mooger }`, - `Piano Bass`, and `RES SYNTH1`. The test writes listening artifacts under - `artifacts/parity/dx7-community-analog1/` and gates log-mel at `<= 0.3`, - envelope distance at `<= 0.16`, and score at `>= 0.5`. - - A first survey also tried `DX1 LEAD B` and `MELLOWSOLO`; they were left - out of the passing gate because their log-mel/zero-crossing mismatch is - larger. Keep those failures as pressure for oscillator phase, feedback, - and transient detail rather than padding the test with weak thresholds. + - `analog1.syx` from Musical Artifacts artifact 152 now has a rendered + parity test for the community voices `{ Mooger }` and `Piano Bass`. The + test writes listening artifacts under + `artifacts/parity/dx7-community-analog1/` and gates log-mel at `<= 0.25`, + envelope distance at `<= 0.14`, zero-crossing ratio in `0.8..1.1`, and + score at `>= 0.6`. + - `Piano Bass` exposed a real pitch bug: the candidate ignored the DX7 voice + transpose byte, so `transpose=12` rendered one octave too high. Aquarium + now uses `Dx7SysEx.NoteFrequencyHz(midiNote, transpose)`, where `24` is + neutral. + - A first survey also tried `DX1 LEAD B`, `ANLGSYN 1`, `MELLOWSOLO`, and + `RES SYNTH1`; they were left out of the passing gate because listening and + log-mel/zero-crossing evidence do not justify calling them parity yet. + Keep those failures as pressure for oscillator phase, feedback, and + transient detail rather than padding the test with weak thresholds. ## Rejected Path diff --git a/src/AquariumSynth.Dsl/Dx7SysEx.cs b/src/AquariumSynth.Dsl/Dx7SysEx.cs index e8b1a8a..de2610d 100644 --- a/src/AquariumSynth.Dsl/Dx7SysEx.cs +++ b/src/AquariumSynth.Dsl/Dx7SysEx.cs @@ -258,6 +258,12 @@ public static class Dx7SysEx return coarse * fine * RatioModeDetuneFactor(op.Detune, midiNote); } + public static float NoteFrequencyHz(int midiNote = 60, int transpose = 24) + { + var effectiveNote = Math.Clamp(midiNote + transpose - 24, 0, 127); + return 440f * MathF.Pow(2, (effectiveNote - 69) / 12f); + } + public static Dx7RateLevelEnvelopeApproximation ApproximateRateLevelEnvelope(Dx7Envelope envelope) { var l1 = Level(envelope.Level1); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 3da71c5..19f15f5 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -46,4 +46,5 @@ {"kind":"patch_library","lesson":"Repo-owned Aquarium .aqua stock now lives under patches/ with library.yaml; every .aqua must parse/export in tests and the patch library must remain out of AquariumSynth.Dsl.nupkg unless intentionally promoted.","source":"Patch library folder slice on 2026-05-14"} {"kind":"dx7_algorithm8_split_route_parity","lesson":"The DX7 summed/cascaded route scale 6.0 is now backed by split project-authored algorithm-8 rendered probes, not only PRC or one combined stack. Latest real-Dexed run: combined stack log-mel 0.04029555 score 0.8664546, summed pair log-mel 0.042429477 score 0.870778, cascade log-mel 0.03811625 score 0.9157809. Keep isolated direct branches at 6.275 and summed/cascaded branches at 6.0 until broader evidence contradicts it.","source":"Split algorithm-8 parity probes on 2026-05-14"} {"kind":"patch_library_taste","lesson":"Not every parity probe belongs in the patch library. Harsh project-authored DX7 calibration probes should stay in tests and ignored listening artifacts unless they are musically useful stock; the navigable .aqua library is for reusable inspiration, not measurement torture signals.","source":"User listening correction on 2026-05-14"} -{"kind":"dx7_community_voice_parity","lesson":"Actual public-domain analog1.syx community voices now have a broad rendered parity gate. ANLGSYN 1, { Mooger }, Piano Bass, and RES SYNTH1 pass log-mel <= 0.3, envelope <= 0.16, score >= 0.5 using the current DX7 lowering. The first survey excluded DX1 LEAD B and MELLOWSOLO because their log-mel/zero-crossing mismatch is too large; remaining pressure is fine waveform/phase/feedback behavior, not only broad envelope shape.","source":"Community DX7 analog1.syx survey on 2026-05-14"} +{"kind":"dx7_community_voice_parity","lesson":"Actual public-domain analog1.syx community voices are useful broader probes, but listening rejected the first loose gate. ANLGSYN 1, RES SYNTH1, DX1 LEAD B, and MELLOWSOLO should remain pressure until their timbre/zero-crossing mismatch is understood. Only Mooger and fixed Piano Bass are currently defensible rendered community parity targets.","source":"Community DX7 analog1.syx survey on 2026-05-14"} +{"kind":"dx7_voice_transpose","lesson":"Piano Bass in analog1.syx proved imported DX7 voices must lower the voice transpose byte into graph frequency. Transpose 24 is neutral; transpose 12 lowers MIDI note 60 to 130.8128 Hz. Hardcoding 261.6256 made Piano Bass a full octave too high. After the fix, Piano Bass improves to log-mel 0.16180529, zero-crossing 0.905511, score 0.64267576. Do not call the broader analog1.syx survey passing; only Mooger and fixed Piano Bass are currently defensible.","source":"Piano Bass listening correction on 2026-05-14"} diff --git a/state/memory.json b/state/memory.json index cf9e29a..abca36d 100644 --- a/state/memory.json +++ b/state/memory.json @@ -74,9 +74,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, measured carrier output amplitude, isolated two-op modulation route scale, summed/cascaded route scale, calibrated feedback amount table, ratio detune lowering, ROM COM output compensation, topology-aware route lowering, staged operator envelopes with per-segment curves, raw and block-interpolated DX7 envelope tracing, applied-envelope curved lowering, two Aquarium DSL rebuild attempts, first-class OperatorGraph support, public-domain SysEx fixture coverage, dexed-py reference rendering, project-authored Dexed patch rendering, Aquarium candidate rendering through Faust-generated C#, one thresholded rendered parity test for analog1.syx voice 13, a hard PRC SYNTH1 parity probe with listening WAV artifacts and log-mel <= 0.18, project-authored algorithm-8 summed-stack/cascade/summed-pair parity, broad rendered community parity for four analog1.syx voices, 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. Static DX7 output-level approximation helped import/rebuild math but was mathematically wrong for carrier amplitude. A single-carrier Dexed sweep shows carrier amplitude follows 2^((outputLevel - 99) / 8). Isolated two-op DX7 FM maps full-level modulation to Aquarium route index 6.275; summed/cascaded algorithm-8 branches now use 6.0 after PRC listening, a project-authored combined stack probe, and split cascade/summed-pair probes showed lower values were under-bright. Feedback lowers through a fitted table instead of PRC-local constants. Ratio-mode detune belongs in operator frequency lowering. ROM COM values carry output-count compensation; because the amplitude curve was fitted against algorithm 32, DX7 carriers scale by 6/(COM+1). Project-authored Dexed patch rendering now gives lawful calibration targets. Reusing the operator output curve for EG levels was tested and cut because it failed hard-target log-mel. Direct envelope tracing shows current linear `env=rl` cannot express DX7 EG spike/drop behavior. Dexed-style audio samples EG once per 64-sample block and interpolates applied gain, so raw EG parity alone is not audio parity. Staged operator envelopes now support linear/exponential segments and supranormal levels. `ApproximateAppliedRateLevelEnvelope` uses that surface and now picks the first near-peak before gate so slower rising modulators hit early instead of swelling late. PRC log-mel is down to 0.13874426 with RMS at unity; broader analog1.syx community voices pass broad log-mel/envelope gates but expose high zero-crossing mismatch, especially on analog synth and piano-bass timbres.", - "next": "Use the now-validated algorithm-8 route scale as fixed input while isolating remaining PRC high-air/timbre mismatch and community-voice zero-crossing mismatch, then expand to broader public-domain banks." + "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, measured carrier output amplitude, isolated two-op modulation route scale, summed/cascaded route scale, calibrated feedback amount table, ratio detune lowering, voice transpose lowering, ROM COM output compensation, topology-aware route lowering, staged operator envelopes with per-segment curves, raw and block-interpolated DX7 envelope tracing, applied-envelope curved lowering, two Aquarium DSL rebuild attempts, first-class OperatorGraph support, public-domain SysEx fixture coverage, dexed-py reference rendering, project-authored Dexed patch rendering, Aquarium candidate rendering through Faust-generated C#, one thresholded rendered parity test for analog1.syx voice 13, a hard PRC SYNTH1 parity probe with listening WAV artifacts and log-mel <= 0.18, project-authored algorithm-8 summed-stack/cascade/summed-pair parity, rendered community parity for Mooger and fixed Piano Bass, 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. Static DX7 output-level approximation helped import/rebuild math but was mathematically wrong for carrier amplitude. A single-carrier Dexed sweep shows carrier amplitude follows 2^((outputLevel - 99) / 8). Isolated two-op DX7 FM maps full-level modulation to Aquarium route index 6.275; summed/cascaded algorithm-8 branches now use 6.0 after PRC listening, a project-authored combined stack probe, and split cascade/summed-pair probes showed lower values were under-bright. Feedback lowers through a fitted table instead of PRC-local constants. Ratio-mode detune belongs in operator frequency lowering. DX7 voice transpose belongs in graph base frequency: transpose 24 is neutral, transpose 12 lowers MIDI note 60 to 130.8128 Hz. ROM COM values carry output-count compensation; because the amplitude curve was fitted against algorithm 32, DX7 carriers scale by 6/(COM+1). Project-authored Dexed patch rendering now gives lawful calibration targets. Reusing the operator output curve for EG levels was tested and cut because it failed hard-target log-mel. Direct envelope tracing shows current linear `env=rl` cannot express DX7 EG spike/drop behavior. Dexed-style audio samples EG once per 64-sample block and interpolates applied gain, so raw EG parity alone is not audio parity. Staged operator envelopes now support linear/exponential segments and supranormal levels. `ApproximateAppliedRateLevelEnvelope` uses that surface and now picks the first near-peak before gate so slower rising modulators hit early instead of swelling late. PRC log-mel is down to 0.13874426 with RMS at unity; community voices beyond Mooger and fixed Piano Bass still expose timbre/zero-crossing mismatch and must not be called passing.", + "next": "Use the now-validated algorithm-8 route scale and transpose lowering as fixed inputs while isolating remaining community-voice zero-crossing/timbre mismatch, then expand to broader public-domain banks." }, "note_and_envelope_model": { "rule": "Notes own frequency, gate duration, and host/MIDI source. Envelopes own ADSR level shape.", @@ -91,7 +91,7 @@ }, "last_verified": { "command": "AQUARIUM_DX7_PYTHON= dotnet test AquariumSynthCSharp.slnx --no-restore", - "result": "70 passed; four actual public-domain analog1.syx community voices pass broad rendered parity and write listening artifacts", - "commit": "pending community DX7 voices" + "result": "71 passed; Piano Bass transpose fixed and community gate narrowed to Mooger plus Piano Bass", + "commit": "pending DX7 transpose fix" } } diff --git a/state/scratch.md b/state/scratch.md index 8226ee5..b12d9cb 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -15,6 +15,23 @@ Doctrine update: Completed this slice: +- Fixed the `Piano Bass` octave bug. The parsed voice has `transpose=12`; the + old generated Aquarium script hardcoded `freq=261.6256`, so it rendered an + octave too high. `Dx7SysEx.NoteFrequencyHz(midiNote, transpose)` now treats + transpose `24` as neutral and transpose `12` as one octave down. +- `Dx7VoiceProbeScript` now uses the voice transpose for graph frequency and + for the detune note basis. Fresh `Piano Bass` artifact emits `freq=130.8128`. +- Narrowed the community parity gate to the two voices we can currently defend: + `{ Mooger }` and fixed `Piano Bass`. `ANLGSYN 1`, `RES SYNTH1`, `DX1 LEAD B`, + and `MELLOWSOLO` remain pressure, not passing parity. +- Fixed `Piano Bass` metrics: log-mel `.16180529`, envelope `.13544041`, + zero-crossing `.905511`, score `.64267576`. +- Verified with bundled Python/dexed-py: + `AQUARIUM_DX7_PYTHON= dotnet test AquariumSynthCSharp.slnx --no-restore`: + 71 passed. + +Previous slice: + - Added `PublicDomainDx7AnalogCommunityVoicesMeetBroadRenderedParityWhenInstalled`, which renders actual public-domain `analog1.syx` community voices through Dexed and the current Aquarium DX7 lowering. Kept four broad parity voices: diff --git a/state/spine.yaml b/state/spine.yaml index 5ad1b4d..aae3fd9 100644 --- a/state/spine.yaml +++ b/state/spine.yaml @@ -1,6 +1,6 @@ project: AquariumSynthCSharp spine_version: 1 -updated: 2026-05-14T14:09:00+01:00 +updated: 2026-05-14T14:24:00+01:00 prime_directive: > Build coherent synth machinery. References exist to reveal missing structure, @@ -49,6 +49,7 @@ live_invariants: - DX7 isolated two-operator modulation uses Aquarium route index `6.275` for full-level modulators; do not apply that blindly to cascaded stacks before algorithm output compensation is modeled. - DX7 feedback lowers through `Dx7SysEx.OperatorFeedbackAmount`; do not restore PRC-local `feedback * constant` folklore. - DX7 ratio-mode detune lowers through `Dx7SysEx.OperatorFrequencyRatio`; do not silently drop detune from operator graph scripts. + - DX7 voice transpose lowers through `Dx7SysEx.NoteFrequencyHz`; transpose 24 is neutral, 12 is one octave down. Do not hardcode `freq=261.6256` for imported voices. - DX7 algorithm output compensation lowers through ROM `COM` values relative to the algorithm-32 six-output baseline; do not restore PRC-local carrier scale tables. - DX7 route lowering is topology-aware: isolated direct branches use `OperatorModulationRouteIndex` (`6.275`); summed edges and direct edges feeding summed modulation use `SummedOperatorModulationRouteIndex` (`6.0`). - `SummedOperatorModulationRouteIndex` is backed by the hard PRC target, a project-authored algorithm-8 stack probe, and split cascade/summed-pair probes; do not restore the older under-bright `1.6` scale. @@ -124,7 +125,9 @@ next_agent_start_here: modulation. Split project-authored algorithm-8 cascade and summed-pair probes now back the 6.0 summed/cascaded route scale. Next pressure is residual PRC high-air/timbre mismatch and high zero-crossing mismatch on - broader public-domain community voices before broad import. + broader public-domain community voices before broad import. The community + gate is currently only `{ Mooger }` and fixed `Piano Bass`; do not describe + the other analog1.syx survey voices as passing. must_read: - AGENTS.md - docs/audio-doctrine.md @@ -137,6 +140,18 @@ next_agent_start_here: - "dotnet test AquariumSynthCSharp.slnx --no-restore" completed_slices: + - date: 2026-05-14 + summary: > + Fixed DX7 voice transpose lowering after listening caught `Piano Bass` + rendering an octave too high. Added `Dx7SysEx.NoteFrequencyHz`, where + transpose 24 is neutral and transpose 12 lowers MIDI note 60 to + 130.8128 Hz. `Dx7VoiceProbeScript` now uses the voice transpose for graph + frequency and detune note basis. Narrowed the community parity gate to + the two defensible voices, `{ Mooger }` and `Piano Bass`; `ANLGSYN 1`, + `RES SYNTH1`, `DX1 LEAD B`, and `MELLOWSOLO` remain pressure, not passing + parity. Fixed `Piano Bass` improves to log-mel 0.16180529, envelope + 0.13544041, zero-crossing 0.905511, and score 0.64267576. + verification: "AQUARIUM_DX7_PYTHON= dotnet test AquariumSynthCSharp.slnx --no-restore: 71 passed" - date: 2026-05-14 summary: > Added a rendered public-domain community DX7 parity test against four diff --git a/tests/AquariumSynth.Dsl.Tests/Dx7ReferenceParityTests.cs b/tests/AquariumSynth.Dsl.Tests/Dx7ReferenceParityTests.cs index b4947d5..682c1a8 100644 --- a/tests/AquariumSynth.Dsl.Tests/Dx7ReferenceParityTests.cs +++ b/tests/AquariumSynth.Dsl.Tests/Dx7ReferenceParityTests.cs @@ -137,14 +137,12 @@ public sealed class Dx7ReferenceParityTests } [Fact] - public async Task PublicDomainDx7AnalogCommunityVoicesMeetBroadRenderedParityWhenInstalled() + public async Task PublicDomainDx7MoogerAndPianoBassMeetRenderedParityWhenInstalled() { var cases = new[] { - new CommunityDx7VoiceCase(7, "ANLGSYN 1", 0.65f, 1.0f, 0.25f), new CommunityDx7VoiceCase(19, "{ Mooger }", 0.65f, 1.0f, 0.25f), - new CommunityDx7VoiceCase(22, "Piano Bass", 0.45f, 0.8f, 0.25f), - new CommunityDx7VoiceCase(31, "RES SYNTH1", 0.65f, 1.0f, 0.25f) + new CommunityDx7VoiceCase(22, "Piano Bass", 0.45f, 0.8f, 0.25f) }; var comparisons = new List<(CommunityDx7VoiceCase Case, AudioComparison Comparison, string ArtifactDir)>(); @@ -166,9 +164,10 @@ public sealed class Dx7ReferenceParityTests $"{ParityReport(item.Comparison)}{Environment.NewLine}" + $"artifacts: {item.ArtifactDir}")); - Assert.All(comparisons, item => Assert.True(item.Comparison.LogMelDistance <= 0.3f, report)); - Assert.All(comparisons, item => Assert.True(item.Comparison.EnvelopeDistance <= 0.16f, report)); - Assert.All(comparisons, item => Assert.True(item.Comparison.Score >= 0.5f, report)); + Assert.All(comparisons, item => Assert.True(item.Comparison.LogMelDistance <= 0.25f, report)); + Assert.All(comparisons, item => Assert.True(item.Comparison.EnvelopeDistance <= 0.14f, report)); + Assert.All(comparisons, item => Assert.InRange(item.Comparison.ZeroCrossingRatio, 0.8f, 1.1f)); + Assert.All(comparisons, item => Assert.True(item.Comparison.Score >= 0.6f, report)); } [Fact] @@ -355,7 +354,7 @@ public sealed class Dx7ReferenceParityTests builder.AppendLine(); builder.AppendLine("opgraph"); builder.AppendLine($" name={graphName}"); - builder.AppendLine(" freq=261.6256"); + builder.AppendLine($" freq={F(Dx7SysEx.NoteFrequencyHz(midiNote: 60, voice.Transpose))}"); builder.AppendLine($" gain={F(graphGain)}"); builder.AppendLine(); @@ -364,7 +363,7 @@ public sealed class Dx7ReferenceParityTests var level = Dx7SysEx.ApproximateOperatorLevel(op).LinearLevel * Dx7SysEx.OperatorOutputCompensation(topology, op.Number); builder.AppendLine($"operator name=op{op.Number}"); - builder.AppendLine($" ratio={F(Dx7SysEx.OperatorFrequencyRatio(op))}"); + builder.AppendLine($" ratio={F(Dx7SysEx.OperatorFrequencyRatio(op, midiNote: Math.Clamp(60 + voice.Transpose - 24, 0, 127)))}"); builder.AppendLine($" level={F(level)}"); if (topology.SelfFeedbackOperators.Contains(op.Number)) { diff --git a/tests/AquariumSynth.Dsl.Tests/Dx7SysExTests.cs b/tests/AquariumSynth.Dsl.Tests/Dx7SysExTests.cs index 204583b..c3887cf 100644 --- a/tests/AquariumSynth.Dsl.Tests/Dx7SysExTests.cs +++ b/tests/AquariumSynth.Dsl.Tests/Dx7SysExTests.cs @@ -270,6 +270,14 @@ public sealed class Dx7SysExTests Assert.InRange(Dx7SysEx.OperatorFrequencyRatio(flat, midiNote: 60), 0.9951f, 0.9952f); } + [Fact] + public void AppliesDx7VoiceTransposeToRenderedNoteFrequency() + { + Assert.InRange(Dx7SysEx.NoteFrequencyHz(midiNote: 60, transpose: 24), 261.62f, 261.63f); + Assert.InRange(Dx7SysEx.NoteFrequencyHz(midiNote: 60, transpose: 12), 130.81f, 130.82f); + Assert.InRange(Dx7SysEx.NoteFrequencyHz(midiNote: 60, transpose: 36), 523.25f, 523.26f); + } + [Fact] public void ApproximatesDx7RateLevelEnvelopeAsStagedEnvelope() {