Refactor and fix Ableton exporter logic across multiple files
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { FaderParam } from '../../../types/types';
|
||||
import { AblGroupPatternOccurrence, AblTrack } from '../../transformers/ableton';
|
||||
import {
|
||||
convertGroupFaderValue,
|
||||
getFaderDefaultValue,
|
||||
getFaderPolicy,
|
||||
} from './faderPolicies';
|
||||
import { convertGroupFaderValue, getFaderDefaultValue, getFaderPolicy } from './faderPolicies';
|
||||
|
||||
export type AbletonAutomationTarget = {
|
||||
arrangement?: number;
|
||||
@@ -101,13 +97,7 @@ function getArrangementPoints(
|
||||
const points: AutomationPoint[] = [];
|
||||
let previousValue = orderedPatterns[0]
|
||||
? getConvertedStaticValue(orderedPatterns[0], parameter, track, groupMixer, target)
|
||||
: convertFaderValue(
|
||||
parameter,
|
||||
getFaderDefaultValue(parameter),
|
||||
track,
|
||||
groupMixer,
|
||||
target,
|
||||
);
|
||||
: convertFaderValue(parameter, getFaderDefaultValue(parameter), track, groupMixer, target);
|
||||
|
||||
orderedPatterns.forEach((pattern) => {
|
||||
const patternTicks = Math.max(1, pattern.loopDuration * 96);
|
||||
|
||||
@@ -373,10 +373,8 @@ async function buildSimplerDevice(
|
||||
simplerFilter.ModByLfo.Manual['@Value'] = 0;
|
||||
device.Lfo.IsOn.Manual['@Value'] = 'false';
|
||||
device.Pitch.PitchLfoAmount.Manual['@Value'] = 0;
|
||||
device.VolumeAndPan.OneShotEnvelope.FadeInTime.Manual['@Value'] =
|
||||
padEnvelope.oneShotFadeInMs;
|
||||
device.VolumeAndPan.OneShotEnvelope.FadeOutTime.Manual['@Value'] =
|
||||
padEnvelope.oneShotFadeOutMs;
|
||||
device.VolumeAndPan.OneShotEnvelope.FadeInTime.Manual['@Value'] = padEnvelope.oneShotFadeInMs;
|
||||
device.VolumeAndPan.OneShotEnvelope.FadeOutTime.Manual['@Value'] = padEnvelope.oneShotFadeOutMs;
|
||||
device.VolumeAndPan.OneShotEnvelope.SustainMode.Manual['@Value'] = 0;
|
||||
device.VolumeAndPan.Envelope.AttackTime.Manual['@Value'] = padEnvelope.classicAttackMs;
|
||||
device.VolumeAndPan.Envelope.ReleaseTime.Manual['@Value'] = padEnvelope.classicReleaseMs;
|
||||
@@ -449,10 +447,7 @@ async function buildSimplerDevice(
|
||||
device.Pitch.TransposeKey.Manual['@Value'] = pitch;
|
||||
|
||||
// adding vibrato from MOD fader param if defined
|
||||
if (
|
||||
koTrack.faderParams[FaderParam.MOD] !== -1 ||
|
||||
automatedParameters.has(FaderParam.MOD)
|
||||
) {
|
||||
if (koTrack.faderParams[FaderParam.MOD] !== -1 || automatedParameters.has(FaderParam.MOD)) {
|
||||
device.Lfo.IsOn.Manual['@Value'] = 'true';
|
||||
if (!device.Lfo.Slot.Value.SimplerLfo && abletonVersion === '10') {
|
||||
const simplerLfoTemplate = await loadTemplate<any>('simplerLfo', abletonVersion);
|
||||
@@ -583,11 +578,7 @@ async function buildDrumRackDevice(
|
||||
drumBranch.BranchInfo.ChokeGroup['@Value'] = subtrack.inChokeGroup ? 1 : 0;
|
||||
drumBranch.MixerDevice.Volume.Manual['@Value'] = subtrack.volume;
|
||||
drumBranch.MixerDevice.SendInfos = {};
|
||||
const branchDevices = await buildSimplerDevice(
|
||||
subtrack,
|
||||
abletonVersion,
|
||||
automatedParameters,
|
||||
);
|
||||
const branchDevices = await buildSimplerDevice(subtrack, abletonVersion, automatedParameters);
|
||||
assignDeviceListIds([branchDevices]);
|
||||
drumBranch.DeviceChain.MidiToAudioDeviceChain.Devices = branchDevices;
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ export const FADER_POLICIES = {
|
||||
renderStrategy: 'target',
|
||||
targetScope: 'track',
|
||||
status: 'mapped',
|
||||
toLive: (value, context) =>
|
||||
context.groupMixer ? value : context.track.volume * value,
|
||||
toLive: (value, context) => (context.groupMixer ? value : context.track.volume * value),
|
||||
},
|
||||
[FaderParam.PTC]: {
|
||||
defaultValue: 0.5,
|
||||
|
||||
@@ -52,10 +52,8 @@ export function getPadSoundState(track: AblTrack): PadSoundState {
|
||||
|
||||
export function getPadEnvelopeState(sound: PadSoundState): PadEnvelopeState {
|
||||
return {
|
||||
classicAttackMs:
|
||||
koEnvRangeToSeconds(sound.envelope.attack, sound.soundLength) * 1000,
|
||||
classicReleaseMs:
|
||||
koEnvRangeToSeconds(sound.envelope.release, sound.soundLength) * 1000,
|
||||
classicAttackMs: koEnvRangeToSeconds(sound.envelope.attack, sound.soundLength) * 1000,
|
||||
classicReleaseMs: koEnvRangeToSeconds(sound.envelope.release, sound.soundLength) * 1000,
|
||||
oneShotFadeInMs: 0,
|
||||
oneShotFadeOutMs: 5,
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
FADER_POLICIES,
|
||||
convertGroupFaderValue,
|
||||
FADER_POLICIES,
|
||||
getFaderPolicy,
|
||||
} from '../src/lib/exporters/ableton/faderPolicies';
|
||||
import { AblTrack } from '../src/lib/transformers/ableton';
|
||||
@@ -28,8 +28,5 @@ test('separates Live targets, note transforms and unsupported group parameters',
|
||||
test('uses one group-fader conversion path for mixer and pad targets', () => {
|
||||
assert.equal(convertGroupFaderValue(FaderParam.LVL, 0.5, { track }), 0.2);
|
||||
assert.equal(convertGroupFaderValue(FaderParam.PAN, 0.75, { track }), 0.5);
|
||||
assert.equal(
|
||||
convertGroupFaderValue(FaderParam.PTC, 0.75, { track, valueOffset: 7 }),
|
||||
9.5,
|
||||
);
|
||||
assert.equal(convertGroupFaderValue(FaderParam.PTC, 0.75, { track, valueOffset: 7 }), 9.5);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
getPadEnvelopeState,
|
||||
getPadSoundState,
|
||||
} from '../src/lib/exporters/ableton/padSound';
|
||||
import { getPadEnvelopeState, getPadSoundState } from '../src/lib/exporters/ableton/padSound';
|
||||
import { AblTrack } from '../src/lib/transformers/ableton';
|
||||
|
||||
const track = {
|
||||
|
||||
Reference in New Issue
Block a user