Fix serializeModulation field names; add mod:base test assertion

This commit is contained in:
c0dev0id 2026-06-24 16:41:12 +02:00
parent e4b5cf6887
commit 89198ec37e
2 changed files with 7 additions and 6 deletions

View File

@ -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;
}

View File

@ -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`);