Update Ableton MIDI exporter to support locked envelopes and improve robustness
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import type { AblMidiEvent } from '../../transformers/ableton';
|
||||
|
||||
export type AbletonMidiControllerTargets = Record<string, { '@Id': number }>;
|
||||
export type AbletonMidiControllerTargets = Record<
|
||||
string,
|
||||
{ '@Id': number; LockEnvelope?: { '@Value': number | string } }
|
||||
>;
|
||||
|
||||
type AutomationPoint = {
|
||||
time: number;
|
||||
@@ -36,10 +39,13 @@ export function buildMidiClipEnvelopes(
|
||||
events: AblMidiEvent[],
|
||||
controllerTargets: AbletonMidiControllerTargets,
|
||||
) {
|
||||
const target = controllerTargets[`ControllerTargets.${CHANNEL_PRESSURE_TARGET}`]?.['@Id'];
|
||||
if (target === undefined) {
|
||||
const target = controllerTargets[`ControllerTargets.${CHANNEL_PRESSURE_TARGET}`];
|
||||
if (!target) {
|
||||
return [];
|
||||
}
|
||||
if (target.LockEnvelope) {
|
||||
target.LockEnvelope['@Value'] = 1;
|
||||
}
|
||||
|
||||
const points: AutomationPoint[] = [{ time: SENTINEL_TIME, value: 0 }];
|
||||
let previousValue = 0;
|
||||
@@ -70,7 +76,7 @@ export function buildMidiClipEnvelopes(
|
||||
return [
|
||||
{
|
||||
'@Id': 0,
|
||||
EnvelopeTarget: { PointeeId: { '@Value': target } },
|
||||
EnvelopeTarget: { PointeeId: { '@Value': target['@Id'] } },
|
||||
Automation: {
|
||||
Events: { FloatEvent: floatEvents(points) },
|
||||
AutomationTransformViewState: {
|
||||
|
||||
Reference in New Issue
Block a user