Refactor and simplify Ableton exporter builders logic
This commit is contained in:
@@ -52,7 +52,6 @@ import {
|
|||||||
fixIds,
|
fixIds,
|
||||||
getId,
|
getId,
|
||||||
gzipString,
|
gzipString,
|
||||||
koEnvRangeToSeconds,
|
|
||||||
loadTemplate,
|
loadTemplate,
|
||||||
resetIds,
|
resetIds,
|
||||||
TIME_SIGNATURES,
|
TIME_SIGNATURES,
|
||||||
@@ -65,30 +64,16 @@ let _localTrackColor = -1;
|
|||||||
let _localGroupTrackColor = -1;
|
let _localGroupTrackColor = -1;
|
||||||
|
|
||||||
const MIN_CLIP_LAUNCHER_SCENES = 8;
|
const MIN_CLIP_LAUNCHER_SCENES = 8;
|
||||||
|
const SIMPLER_FADE_IN_MS = 0;
|
||||||
|
const SIMPLER_FADE_OUT_MS = 5;
|
||||||
|
const SIMPLER_ATTACK_MS = 0.1;
|
||||||
|
const SIMPLER_RELEASE_MS = 50;
|
||||||
type AbletonVersion = '10' | '11';
|
type AbletonVersion = '10' | '11';
|
||||||
|
|
||||||
function getAbletonVersion(exporterParams: ExporterParams): AbletonVersion {
|
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,
|
|
||||||
invertValue: boolean = false,
|
|
||||||
) {
|
|
||||||
const convertedValue = invertValue ? 255 - value : value;
|
|
||||||
const milliseconds = koEnvRangeToSeconds(convertedValue, soundLength) * 1000;
|
|
||||||
return oneshot ? Math.min(2000, milliseconds) : milliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
function simplerPlaybackDuration(koTrack: AblTrack) {
|
|
||||||
const trimmedFrames = koTrack.trimRight - koTrack.trimLeft;
|
|
||||||
return trimmedFrames > 0 && koTrack.sampleRate > 0
|
|
||||||
? trimmedFrames / koTrack.sampleRate
|
|
||||||
: koTrack.soundLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setColorValue(node: any, value: number) {
|
function setColorValue(node: any, value: number) {
|
||||||
const color = node.Color || node.ColorIndex;
|
const color = node.Color || node.ColorIndex;
|
||||||
color['@Value'] = value;
|
color['@Value'] = value;
|
||||||
@@ -129,12 +114,7 @@ export function assignDeviceListIds(devices: Record<string, any>[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function targetFor(
|
function targetFor(parameter: any): AbletonAutomationTarget {
|
||||||
parameter: any,
|
|
||||||
maxValue?: number,
|
|
||||||
soundLength?: number,
|
|
||||||
invertValue?: boolean,
|
|
||||||
): AbletonAutomationTarget {
|
|
||||||
const automationTarget =
|
const automationTarget =
|
||||||
parameter?.AutomationTarget?.['@Id'] === undefined
|
parameter?.AutomationTarget?.['@Id'] === undefined
|
||||||
? undefined
|
? undefined
|
||||||
@@ -142,9 +122,6 @@ function targetFor(
|
|||||||
return {
|
return {
|
||||||
arrangement: automationTarget,
|
arrangement: automationTarget,
|
||||||
session: automationTarget,
|
session: automationTarget,
|
||||||
maxValue,
|
|
||||||
soundLength,
|
|
||||||
invertValue,
|
|
||||||
staticValue:
|
staticValue:
|
||||||
parameter?.Manual?.['@Value'] === undefined ? undefined : Number(parameter.Manual['@Value']),
|
parameter?.Manual?.['@Value'] === undefined ? undefined : Number(parameter.Manual['@Value']),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user