Enhance Ableton export with value inversion support for automation and envelopes
This commit is contained in:
@@ -7,6 +7,7 @@ export type AbletonAutomationTarget = {
|
|||||||
session?: number;
|
session?: number;
|
||||||
maxValue?: number;
|
maxValue?: number;
|
||||||
soundLength?: number;
|
soundLength?: number;
|
||||||
|
invertValue?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AbletonAutomationTargets = Partial<Record<FaderParam, AbletonAutomationTarget[]>>;
|
export type AbletonAutomationTargets = Partial<Record<FaderParam, AbletonAutomationTarget[]>>;
|
||||||
@@ -64,11 +65,17 @@ export function convertFaderValue(
|
|||||||
break;
|
break;
|
||||||
case FaderParam.ATK:
|
case FaderParam.ATK:
|
||||||
convertedValue =
|
convertedValue =
|
||||||
koEnvRangeToSeconds(value * 255, target?.soundLength ?? track.soundLength) * 1000;
|
koEnvRangeToSeconds(
|
||||||
|
(target?.invertValue ? 1 - value : value) * 255,
|
||||||
|
target?.soundLength ?? track.soundLength,
|
||||||
|
) * 1000;
|
||||||
break;
|
break;
|
||||||
case FaderParam.REL:
|
case FaderParam.REL:
|
||||||
convertedValue =
|
convertedValue =
|
||||||
koEnvRangeToSeconds(value * 255, target?.soundLength ?? track.soundLength) * 1000;
|
koEnvRangeToSeconds(
|
||||||
|
(target?.invertValue ? 1 - value : value) * 255,
|
||||||
|
target?.soundLength ?? track.soundLength,
|
||||||
|
) * 1000;
|
||||||
break;
|
break;
|
||||||
case FaderParam.PAN:
|
case FaderParam.PAN:
|
||||||
convertedValue = (value - 0.5) * 2;
|
convertedValue = (value - 0.5) * 2;
|
||||||
|
|||||||
@@ -67,8 +67,14 @@ function getAbletonVersion(exporterParams: ExporterParams): AbletonVersion {
|
|||||||
return exporterParams.abletonVersion === '10' ? '10' : '11';
|
return exporterParams.abletonVersion === '10' ? '10' : '11';
|
||||||
}
|
}
|
||||||
|
|
||||||
function simplerEnvelopeMilliseconds(value: number, soundLength: number, oneshot: boolean) {
|
function simplerEnvelopeMilliseconds(
|
||||||
const milliseconds = koEnvRangeToSeconds(value, soundLength) * 1000;
|
value: number,
|
||||||
|
soundLength: number,
|
||||||
|
oneshot: boolean,
|
||||||
|
invertValue: boolean = false,
|
||||||
|
) {
|
||||||
|
const convertedValue = invertValue ? 255 - value : value;
|
||||||
|
const milliseconds = koEnvRangeToSeconds(convertedValue, soundLength) * 1000;
|
||||||
return oneshot ? Math.min(2000, milliseconds) : milliseconds;
|
return oneshot ? Math.min(2000, milliseconds) : milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +110,12 @@ function setLive10SampleReference(fileRef: any, sampleName: string) {
|
|||||||
fileRef.LivePackId = { '@Value': '' };
|
fileRef.LivePackId = { '@Value': '' };
|
||||||
}
|
}
|
||||||
|
|
||||||
function targetFor(parameter: any, maxValue?: number, soundLength?: number) {
|
function targetFor(
|
||||||
|
parameter: any,
|
||||||
|
maxValue?: number,
|
||||||
|
soundLength?: number,
|
||||||
|
invertValue?: boolean,
|
||||||
|
) {
|
||||||
const automationTarget =
|
const automationTarget =
|
||||||
parameter?.AutomationTarget?.['@Id'] === undefined
|
parameter?.AutomationTarget?.['@Id'] === undefined
|
||||||
? undefined
|
? undefined
|
||||||
@@ -114,6 +125,7 @@ function targetFor(parameter: any, maxValue?: number, soundLength?: number) {
|
|||||||
session: automationTarget,
|
session: automationTarget,
|
||||||
maxValue,
|
maxValue,
|
||||||
soundLength,
|
soundLength,
|
||||||
|
invertValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +216,7 @@ function trackAutomationTargets(midiTrack: any, includeArrangementMixer: boolean
|
|||||||
: simpler.VolumeAndPan.Envelope.AttackTime,
|
: simpler.VolumeAndPan.Envelope.AttackTime,
|
||||||
oneshot ? 2000 : undefined,
|
oneshot ? 2000 : undefined,
|
||||||
soundLength,
|
soundLength,
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
addTarget(
|
addTarget(
|
||||||
@@ -215,6 +228,7 @@ function trackAutomationTargets(midiTrack: any, includeArrangementMixer: boolean
|
|||||||
: simpler.VolumeAndPan.Envelope.ReleaseTime,
|
: simpler.VolumeAndPan.Envelope.ReleaseTime,
|
||||||
oneshot ? 2000 : undefined,
|
oneshot ? 2000 : undefined,
|
||||||
soundLength,
|
soundLength,
|
||||||
|
oneshot,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
addTarget(targets, FaderParam.MOD, targetFor(simpler.Pitch.PitchLfoAmount));
|
addTarget(targets, FaderParam.MOD, targetFor(simpler.Pitch.PitchLfoAmount));
|
||||||
@@ -452,6 +466,7 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
|||||||
koTrack.release,
|
koTrack.release,
|
||||||
koTrack.soundLength,
|
koTrack.soundLength,
|
||||||
oneshot,
|
oneshot,
|
||||||
|
oneshot,
|
||||||
);
|
);
|
||||||
device.VolumeAndPan.Panorama.Manual['@Value'] = koTrack.pan;
|
device.VolumeAndPan.Panorama.Manual['@Value'] = koTrack.pan;
|
||||||
|
|
||||||
@@ -470,6 +485,7 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
|||||||
koTrack.faderParams[FaderParam.REL] * 255,
|
koTrack.faderParams[FaderParam.REL] * 255,
|
||||||
koTrack.soundLength,
|
koTrack.soundLength,
|
||||||
oneshot,
|
oneshot,
|
||||||
|
oneshot,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user