Calibrate DX7 two-op modulation index

This commit is contained in:
Meta Vens 2026-05-14 05:09:43 +01:00
commit db20a90d1c
7 changed files with 55 additions and 12 deletions

View file

@ -159,6 +159,7 @@ public static class Dx7SysEx
public const int PackedVoiceLength = 128;
public const int PackedBankVoiceCount = 32;
public const int PackedBankDataLength = PackedVoiceLength * PackedBankVoiceCount;
public const float OperatorModulationRouteIndex = 6.275f;
public static Dx7Voice ParseVoice(ReadOnlySpan<byte> bytes)
{

View file

@ -30,3 +30,4 @@
{"kind":"dx7_prc_calibration","lesson":"PRC SYNTH1 improved to a modest passing score of ~0.606 without new DSL surface. Removing soft clipping, using a 392 Hz graph base, and boosting the op3 carrier branch helped; global detune and per-edge route damping worsened metrics and were cut. Remaining pressure is DX7 output/index scaling or algorithm output compensation, not more envelope syntax.","source":"PRC SYNTH1 calibration pass on 2026-05-14"}
{"kind":"dx7_prc_logmel","lesson":"Listening and log-mel agreed that the aggregate PRC SYNTH1 score was misleading. The Dexed reference has strong low/body partials around 131 Hz and 393 Hz; Aquarium's earlier candidate lacked the low body despite a better aggregate score. The probe now gates on log-mel <=0.255 with a loose aggregate floor, and remaining mismatch points at DX7 output/index scaling and algorithm compensation.","source":"PRC SYNTH1 perceptual/log-mel calibration on 2026-05-14"}
{"kind":"dx7_output_level_curve","lesson":"A project-authored Dexed single-carrier sweep shows DX7 carrier amplitude follows 2^((outputLevel - 99) / 8). The previous internal-level proxy made mid-level operators far too loud. `Dx7SysEx.OperatorOutputAmplitude` now owns the measured curve; next calibration rung is two-operator modulation index.","source":"DX7 single-carrier calibration rung on 2026-05-14"}
{"kind":"dx7_modulation_index","lesson":"Isolated two-operator Dexed FM fits full-level modulation at about 12.55 radians. Under Aquarium's current Faust phase formula this maps to route index 6.275 for a full-level modulator. Apply this to isolated two-op branches, but do not blindly apply it to cascaded algorithm stacks before algorithm output compensation is modeled.","source":"DX7 two-operator modulation calibration rung on 2026-05-14"}

View file

@ -23,6 +23,7 @@
"DX7 algorithm topology metadata",
"DX7 effective operator-level approximation",
"DX7 measured carrier output amplitude curve",
"DX7 isolated modulation-index route scale",
"staged operator envelope DSL",
"DX7 envelope-to-ADSR approximation",
"standard ADSR envelope model",
@ -62,9 +63,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, staged operator envelopes, 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, a hard PRC SYNTH1 parity probe with listening WAV artifacts and log-mel <= 0.26, 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). Staged operator envelopes now let Aquarium express four-rate/four-level contours in readable DSL. PRC SYNTH1 still exposes weak modulation-index and output-compensation calibration.",
"next": "Follow docs/dx7-calibration-plan.md: calibrate single-carrier amplitude, two-op modulation index, feedback, envelope level curve, and algorithm output compensation before adding new DSL surface or continuing PRC-specific tuning."
"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, staged operator envelopes, 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, a hard PRC SYNTH1 parity probe with listening WAV artifacts and log-mel <= 0.255, 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; applying that blindly to cascaded PRC stacks is wrong until algorithm output compensation exists. Staged operator envelopes now let Aquarium express four-rate/four-level contours in readable DSL.",
"next": "Follow docs/dx7-calibration-plan.md: calibrate feedback, envelope level curve, and algorithm output compensation before adding new DSL surface or tuning PRC constants."
},
"note_and_envelope_model": {
"rule": "Notes own frequency, gate duration, and host/MIDI source. Envelopes own ADSR level shape.",
@ -79,7 +80,7 @@
},
"last_verified": {
"command": "dotnet test AquariumSynthCSharp.slnx --no-restore",
"result": "55 passed with AQUARIUM_DX7_PYTHON set to bundled Python",
"commit": "pending DX7 carrier output calibration"
"result": "56 passed with AQUARIUM_DX7_PYTHON set to bundled Python",
"commit": "pending DX7 modulation index calibration"
}
}

View file

@ -15,6 +15,21 @@ Doctrine update:
Completed this slice:
- Completed the second calibration rung for isolated two-operator FM. A Dexed
sweep fits full-scale DX7 modulation at about `12.55` radians. Given the
current Aquarium Faust formula, that maps to an Aquarium route index of
`6.275` for a full-level modulator.
- Added `Dx7SysEx.OperatorModulationRouteIndex` and a regression test for the
calibrated phase-deviation scale. The hard PRC probe applies that scale only
to the isolated `op2 -> op1` branch; applying it blindly to the cascaded
`op6/op5/op4 -> op3` stack made PRC worse, which confirms algorithm output
compensation is a separate rung.
- Latest PRC run with the carrier curve plus isolated-route calibration:
log-mel `0.2526254`, score `0.44758993`, duration ratio `0.9927914`, RMS
ratio `0.8931149`. The log-mel gate is back to `<= 0.255`.
Previous slice:
- Wrote `docs/dx7-calibration-plan.md` and referenced it from memory/spine.
The ladder is now: single-carrier amplitude, two-op modulation index,
feedback scaling, envelope level curve, algorithm output compensation, then

View file

@ -1,6 +1,6 @@
project: AquariumSynthCSharp
spine_version: 1
updated: 2026-05-14T04:04:00+01:00
updated: 2026-05-14T04:10:00+01:00
prime_directive: >
Build coherent synth machinery. References exist to reveal missing structure,
@ -45,6 +45,7 @@ live_invariants:
- Operator feedback must render through Faust as delayed recursion, not as a direct cyclic self-reference.
- DX7 operator output level approximation belongs in reference import/rebuild helpers, not the generic DSL model.
- DX7 carrier output amplitude follows the measured `2^((outputLevel - 99) / 8)` curve; do not restore the old internal-level proxy.
- 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 calibration must proceed through isolated rungs in `docs/dx7-calibration-plan.md`; do not keep tuning hard PRC-specific constants as a substitute for a level/index model.
- Staged operator envelopes own multi-target operator level contours through `env=rl rates=... levels=...`; do not force DX7-style contours back into the general ADSR voice envelope model.
- DX7 rate/level envelopes may lower to staged operator envelopes or labeled ADSR approximations, but exact DX7 EG timing/gain calibration remains missing pressure.
@ -99,10 +100,10 @@ reference_targets:
next_agent_start_here:
recommended_first_task: >
Listen to the latest generated PRC SYNTH1 WAVs under
Continue the ladder in `docs/dx7-calibration-plan.md` with isolated
two-operator modulation-index calibration. Single-carrier output amplitude
is now fitted; do not keep tuning PRC constants until route/index scaling is
measured.
Continue the ladder in `docs/dx7-calibration-plan.md` with feedback scaling
and algorithm output compensation. Single-carrier amplitude and isolated
two-op modulation index are now fitted; cascaded PRC stacks still need a
real compensation model.
must_read:
- AGENTS.md
- docs/audio-doctrine.md
@ -115,6 +116,15 @@ next_agent_start_here:
- "dotnet test AquariumSynthCSharp.slnx --no-restore"
completed_slices:
- date: 2026-05-14
summary: >
Completed the isolated two-operator modulation-index rung. Dexed sweeps
fit full-level modulation at about 12.55 radians, which maps to Aquarium
route index 6.275 under the current Faust phase formula. The PRC probe
applies that calibrated route only to the isolated `op2 -> op1` branch;
applying it to the cascaded stack made metrics worse, leaving algorithm
output compensation as explicit pressure.
verification: "AQUARIUM_DX7_PYTHON=<bundled python> dotnet test AquariumSynthCSharp.slnx --no-restore --filter PublicDomainDx7PrcSynth1WritesListeningWavsWhenInstalled: passed"
- date: 2026-05-14
summary: >
Added `docs/dx7-calibration-plan.md` and completed the first calibration

View file

@ -122,7 +122,7 @@ public sealed class Dx7ReferenceParityTests
script,
comparison);
Assert.True(comparison.LogMelDistance <= 0.26f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
Assert.True(comparison.LogMelDistance <= 0.255f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
Assert.True(comparison.Score >= 0.40f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
}
@ -174,7 +174,7 @@ public sealed class Dx7ReferenceParityTests
{
foreach (var source in edge.SourceOperators)
{
builder.AppendLine($"route from=op{source} to=op{edge.TargetOperator} index=0.7");
builder.AppendLine($"route from=op{source} to=op{edge.TargetOperator} index={F(PrcSynth1RouteIndex(source, edge.TargetOperator))}");
}
}
@ -207,6 +207,13 @@ public sealed class Dx7ReferenceParityTests
_ => 1
};
private static float PrcSynth1RouteIndex(int sourceOperator, int targetOperator) => (sourceOperator, targetOperator) switch
{
(2, 1) => Dx7SysEx.OperatorModulationRouteIndex,
// Cascaded stacks still need algorithm output compensation; do not apply the isolated two-op scale blindly.
_ => 0.7f
};
private static Dx7RateLevelEnvelopeApproximation ScaledEnvelope(Dx7RateLevelEnvelopeApproximation approximation, float scale)
{
var envelope = approximation.Envelope;

View file

@ -208,6 +208,14 @@ public sealed class Dx7SysExTests
Assert.Equal(MathF.Pow(2, (80 - 99) / 8f), Dx7SysEx.OperatorOutputAmplitude(80), 5);
}
[Fact]
public void CalibratesDx7OutputLevelToAquariumRouteIndex()
{
var fullScalePhaseDeviationRadians = 2 * Dx7SysEx.OperatorOutputAmplitude(99) * Dx7SysEx.OperatorModulationRouteIndex;
Assert.InRange(fullScalePhaseDeviationRadians, 12.5f, 12.6f);
}
[Fact]
public void ApproximatesDx7RateLevelEnvelopeAsStagedEnvelope()
{