feat: added MIDI CC recording and list event table operation support.

This commit is contained in:
Xiaohan-Tian
2026-05-07 22:12:06 -07:00
parent 6305983df8
commit f3d26126fa
30 changed files with 1250 additions and 53 deletions
+30
View File
@@ -4,6 +4,7 @@ import {
collectRegionMidiAutomationPoints,
normalizeMidiAutomationPoints,
resolveMidiAutomationValueAtBeat,
resolveSustainExtendedEndBeat,
type MidiAutomationPoint,
} from './midiAutomationUtil';
@@ -159,4 +160,33 @@ describe('midiAutomationUtil', () => {
expect(baked.some(point => point.beat === 5 && point.value === 6144)).toBe(true);
expect(baked.some(point => point.beat === 6 && point.value === 8192)).toBe(true);
});
it('uses step interpolation for switch-style automation', () => {
const points = [
{ beat: 1, value: 127 },
{ beat: 3, value: 0 },
];
expect(resolveMidiAutomationValueAtBeat(points, 2, 0, 'step')).toBe(127);
expect(bakeMidiAutomationPointsInWindow(points, 0, 4, {
...defaultOptions,
defaultValue: 0,
interpolationMode: 'step',
quantizeValue: (value) => value,
})).toEqual([
{ beat: 0, value: 0 },
{ beat: 1, value: 127 },
{ beat: 3, value: 0 },
]);
});
it('extends note ends until the next sustain release', () => {
const points = [
{ beat: 1, value: 127 },
{ beat: 4, value: 0 },
];
expect(resolveSustainExtendedEndBeat(points, 2, 0)).toBe(4);
expect(resolveSustainExtendedEndBeat(points, 5, 0)).toBe(5);
});
});