Fix serializeModulation field names; add mod:base test assertion
This commit is contained in:
parent
e4b5cf6887
commit
89198ec37e
@ -23,12 +23,12 @@ function serializeShape(shape) {
|
|||||||
// ── FM / AM modulation ─────────────────────────────────────────────────────
|
// ── FM / AM modulation ─────────────────────────────────────────────────────
|
||||||
// RFC §3.2.1.1.6-7: FM = FREQUENCY ["f"/"F"] ["@" OSC] ["[" SHAPE "]"] ";" MOD ":" BASE
|
// RFC §3.2.1.1.6-7: FM = FREQUENCY ["f"/"F"] ["@" OSC] ["[" SHAPE "]"] ";" MOD ":" BASE
|
||||||
|
|
||||||
function serializeModulation(fm) {
|
function serializeModulation(m) {
|
||||||
let s = String(fm.frequency ?? '');
|
let s = String(m.frequency ?? '');
|
||||||
if (fm.factor) s += fm.factor;
|
if (m.oscillator) s += `@${m.oscillator}`;
|
||||||
if (fm.osc) s += `@${fm.osc}`;
|
if (m.shape) s += `[${serializeShape(m.shape)}]`;
|
||||||
if (fm.shape) s += `[${serializeShape(fm.shape)}]`;
|
s += `;${m.mod_share ?? ''}:${m.base_share ?? ''}`;
|
||||||
s += `;${fm.mod ?? ''}:${fm.base ?? ''}`;
|
if (m.init_phase != null) s += m.init_phase >= 0 ? `+${m.init_phase}` : String(m.init_phase);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -243,6 +243,7 @@ ok('FM shape start', fm?.shape?.start === '6' || fm?.shape?.start === 6);
|
|||||||
fmInstr.isDirty = true;
|
fmInstr.isDirty = true;
|
||||||
const fmOut = exportInstrument(fmInstr);
|
const fmOut = exportInstrument(fmInstr);
|
||||||
ok('FM exported with [shape]', /FM:.*\[.*\]/.test(fmOut));
|
ok('FM exported with [shape]', /FM:.*\[.*\]/.test(fmOut));
|
||||||
|
ok('FM exported with mod:base', /FM:.*;\d+:\d+/.test(fmOut));
|
||||||
|
|
||||||
// ── Summary ────────────────────────────────────────────────────────────────
|
// ── Summary ────────────────────────────────────────────────────────────────
|
||||||
console.log(`\n══ ${pass} passed, ${fail} failed ══\n`);
|
console.log(`\n══ ${pass} passed, ${fail} failed ══\n`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user