Refactor and simplify Ableton exporter builders logic
This commit is contained in:
@@ -52,7 +52,6 @@ import {
|
||||
fixIds,
|
||||
getId,
|
||||
gzipString,
|
||||
koEnvRangeToSeconds,
|
||||
loadTemplate,
|
||||
resetIds,
|
||||
TIME_SIGNATURES,
|
||||
@@ -65,30 +64,16 @@ let _localTrackColor = -1;
|
||||
let _localGroupTrackColor = -1;
|
||||
|
||||
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';
|
||||
|
||||
function getAbletonVersion(exporterParams: ExporterParams): AbletonVersion {
|
||||
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) {
|
||||
const color = node.Color || node.ColorIndex;
|
||||
color['@Value'] = value;
|
||||
@@ -129,12 +114,7 @@ export function assignDeviceListIds(devices: Record<string, any>[]) {
|
||||
});
|
||||
}
|
||||
|
||||
function targetFor(
|
||||
parameter: any,
|
||||
maxValue?: number,
|
||||
soundLength?: number,
|
||||
invertValue?: boolean,
|
||||
): AbletonAutomationTarget {
|
||||
function targetFor(parameter: any): AbletonAutomationTarget {
|
||||
const automationTarget =
|
||||
parameter?.AutomationTarget?.['@Id'] === undefined
|
||||
? undefined
|
||||
@@ -142,9 +122,6 @@ function targetFor(
|
||||
return {
|
||||
arrangement: automationTarget,
|
||||
session: automationTarget,
|
||||
maxValue,
|
||||
soundLength,
|
||||
invertValue,
|
||||
staticValue:
|
||||
parameter?.Manual?.['@Value'] === undefined ? undefined : Number(parameter.Manual['@Value']),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user