Add AM modulation support to parser and exporter
This commit is contained in:
parent
1706404b7e
commit
923aa5d41a
@ -181,6 +181,7 @@ function buildInstrument(node) {
|
|||||||
volumes: null,
|
volumes: null,
|
||||||
timbre: null,
|
timbre: null,
|
||||||
fmModulations: [],
|
fmModulations: [],
|
||||||
|
amModulations: [],
|
||||||
rawChildren: [],
|
rawChildren: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -201,6 +202,9 @@ function buildInstrument(node) {
|
|||||||
case 'FM.modulation':
|
case 'FM.modulation':
|
||||||
instr.fmModulations.push({ ...child.props });
|
instr.fmModulations.push({ ...child.props });
|
||||||
break;
|
break;
|
||||||
|
case 'AM.modulation':
|
||||||
|
instr.amModulations.push({ ...child.props });
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
instr.rawChildren.push(buildGeneric(child));
|
instr.rawChildren.push(buildGeneric(child));
|
||||||
}
|
}
|
||||||
@ -253,6 +257,7 @@ function buildBasicProperties(node) {
|
|||||||
A: null, S: null, R: null,
|
A: null, S: null, R: null,
|
||||||
oscillator: null,
|
oscillator: null,
|
||||||
fmModulations: [],
|
fmModulations: [],
|
||||||
|
amModulations: [],
|
||||||
rawChildren: [],
|
rawChildren: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -271,6 +276,11 @@ function buildBasicProperties(node) {
|
|||||||
const envChild = child.children.find(c => c.slot === 'shape');
|
const envChild = child.children.find(c => c.slot === 'shape');
|
||||||
if (envChild) fm.shape = buildShape(envChild);
|
if (envChild) fm.shape = buildShape(envChild);
|
||||||
bp.fmModulations.push(fm);
|
bp.fmModulations.push(fm);
|
||||||
|
} else if (child.parentSlot === 'AM' && child.slot === 'modulation') {
|
||||||
|
const am = { ...child.props };
|
||||||
|
const envChild = child.children.find(c => c.slot === 'shape');
|
||||||
|
if (envChild) am.shape = buildShape(envChild);
|
||||||
|
bp.amModulations.push(am);
|
||||||
} else {
|
} else {
|
||||||
bp.rawChildren.push(buildGeneric(child));
|
bp.rawChildren.push(buildGeneric(child));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ function basicPropLines(bp) {
|
|||||||
const r = serializeShape(bp.R);
|
const r = serializeShape(bp.R);
|
||||||
if (r) lines.push(`R: "${r}"`);
|
if (r) lines.push(`R: "${r}"`);
|
||||||
for (const fm of (bp.fmModulations ?? [])) lines.push(`FM: "${serializeFm(fm)}"`);
|
for (const fm of (bp.fmModulations ?? [])) lines.push(`FM: "${serializeFm(fm)}"`);
|
||||||
|
for (const am of (bp.amModulations ?? [])) lines.push(`AM: "${serializeFm(am)}"`);
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ function variationLines(v) {
|
|||||||
const timbre = serializeShape(v.timbre);
|
const timbre = serializeShape(v.timbre);
|
||||||
if (timbre) lines.push(`TIMBRE: "${timbre}"`);
|
if (timbre) lines.push(`TIMBRE: "${timbre}"`);
|
||||||
for (const fm of (v.fmModulations ?? [])) lines.push(`FM: "${serializeFm(fm)}"`);
|
for (const fm of (v.fmModulations ?? [])) lines.push(`FM: "${serializeFm(fm)}"`);
|
||||||
|
for (const am of (v.amModulations ?? [])) lines.push(`AM: "${serializeFm(am)}"`);
|
||||||
for (const sv of (v.subvariations ?? [])) lines.push(...variationLines(sv));
|
for (const sv of (v.subvariations ?? [])) lines.push(...variationLines(sv));
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
@ -89,7 +91,8 @@ function variationLines(v) {
|
|||||||
function instrCharacterLines(instr) {
|
function instrCharacterLines(instr) {
|
||||||
const variations = instr.variations ?? [];
|
const variations = instr.variations ?? [];
|
||||||
const hasRootProps = instr.basicProperties || instr.volumes || instr.timbre ||
|
const hasRootProps = instr.basicProperties || instr.volumes || instr.timbre ||
|
||||||
(instr.fmModulations ?? []).length > 0;
|
(instr.fmModulations ?? []).length > 0 ||
|
||||||
|
(instr.amModulations ?? []).length > 0;
|
||||||
const syntheticRoot = hasRootProps
|
const syntheticRoot = hasRootProps
|
||||||
? {
|
? {
|
||||||
basicProperties: instr.basicProperties,
|
basicProperties: instr.basicProperties,
|
||||||
@ -98,6 +101,7 @@ function instrCharacterLines(instr) {
|
|||||||
volumes: instr.volumes,
|
volumes: instr.volumes,
|
||||||
timbre: instr.timbre,
|
timbre: instr.timbre,
|
||||||
fmModulations: instr.fmModulations ?? [],
|
fmModulations: instr.fmModulations ?? [],
|
||||||
|
amModulations: instr.amModulations ?? [],
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user