From 89198ec37eb976617c39e49375158adb3fc5f56a Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Wed, 24 Jun 2026 16:41:12 +0200 Subject: [PATCH] Fix serializeModulation field names; add mod:base test assertion --- static/exporter.js | 12 ++++++------ test-parser.mjs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/static/exporter.js b/static/exporter.js index 734d6b8..92d941c 100644 --- a/static/exporter.js +++ b/static/exporter.js @@ -23,12 +23,12 @@ function serializeShape(shape) { // ── FM / AM modulation ───────────────────────────────────────────────────── // RFC §3.2.1.1.6-7: FM = FREQUENCY ["f"/"F"] ["@" OSC] ["[" SHAPE "]"] ";" MOD ":" BASE -function serializeModulation(fm) { - let s = String(fm.frequency ?? ''); - if (fm.factor) s += fm.factor; - if (fm.osc) s += `@${fm.osc}`; - if (fm.shape) s += `[${serializeShape(fm.shape)}]`; - s += `;${fm.mod ?? ''}:${fm.base ?? ''}`; +function serializeModulation(m) { + let s = String(m.frequency ?? ''); + if (m.oscillator) s += `@${m.oscillator}`; + if (m.shape) s += `[${serializeShape(m.shape)}]`; + s += `;${m.mod_share ?? ''}:${m.base_share ?? ''}`; + if (m.init_phase != null) s += m.init_phase >= 0 ? `+${m.init_phase}` : String(m.init_phase); return s; } diff --git a/test-parser.mjs b/test-parser.mjs index babfaef..2c39db9 100644 --- a/test-parser.mjs +++ b/test-parser.mjs @@ -243,6 +243,7 @@ ok('FM shape start', fm?.shape?.start === '6' || fm?.shape?.start === 6); fmInstr.isDirty = true; const fmOut = exportInstrument(fmInstr); ok('FM exported with [shape]', /FM:.*\[.*\]/.test(fmOut)); +ok('FM exported with mod:base', /FM:.*;\d+:\d+/.test(fmOut)); // ── Summary ──────────────────────────────────────────────────────────────── console.log(`\n══ ${pass} passed, ${fail} failed ══\n`);