Fix minor syntax and logic errors in Ableton exporter
This commit is contained in:
@@ -7,9 +7,7 @@ export type AbletonAutomationTarget = {
|
||||
session?: number;
|
||||
};
|
||||
|
||||
export type AbletonAutomationTargets = Partial<
|
||||
Record<FaderParam, AbletonAutomationTarget[]>
|
||||
>;
|
||||
export type AbletonAutomationTargets = Partial<Record<FaderParam, AbletonAutomationTarget[]>>;
|
||||
|
||||
type AutomationPoint = {
|
||||
time: number;
|
||||
@@ -76,7 +74,8 @@ export function getFaderValueAt(
|
||||
position: number,
|
||||
) {
|
||||
const staticValue = occurrence?.faderParams[parameter];
|
||||
let value = staticValue === undefined || staticValue === -1 ? defaultValue(parameter) : staticValue;
|
||||
let value =
|
||||
staticValue === undefined || staticValue === -1 ? defaultValue(parameter) : staticValue;
|
||||
const points = (occurrence?.faderAutomation || [])
|
||||
.filter((point) => point.parameter === parameter && point.position <= position)
|
||||
.sort((a, b) => a.position - b.position);
|
||||
@@ -110,8 +109,7 @@ function getArrangementPoints(
|
||||
);
|
||||
|
||||
patterns.forEach((pattern) => {
|
||||
const beats =
|
||||
pattern.timeSignature.numerator * (4 / pattern.timeSignature.denominator);
|
||||
const beats = pattern.timeSignature.numerator * (4 / pattern.timeSignature.denominator);
|
||||
const patternTicks = pattern.bars * beats * 96;
|
||||
const sceneTicks = pattern.sceneBars * beats * 96;
|
||||
const startTime = pattern.offset * beats;
|
||||
|
||||
@@ -14,6 +14,12 @@ import abletonTransformer, {
|
||||
AblTrack,
|
||||
} from '../../transformers/ableton';
|
||||
import { getQuarterNotesPerBar } from '../utils';
|
||||
import {
|
||||
AbletonAutomationTargets,
|
||||
buildArrangementEnvelopes,
|
||||
buildClipEnvelopes,
|
||||
getFaderValueAt,
|
||||
} from './automation';
|
||||
import { ALSDrumBranch } from './types/drumBranch';
|
||||
import { ALSDrumRack } from './types/drumRack';
|
||||
import { ALSChorus } from './types/effectChorus';
|
||||
@@ -30,12 +36,6 @@ import { ALSReturnTrack } from './types/returnTrack';
|
||||
import { ALSScene, ALSSceneContent } from './types/scene';
|
||||
import { ALSSimpler } from './types/simpler';
|
||||
import { ALSTrackSendHolder } from './types/trackSendHolder';
|
||||
import {
|
||||
AbletonAutomationTargets,
|
||||
buildArrangementEnvelopes,
|
||||
buildClipEnvelopes,
|
||||
getFaderValueAt,
|
||||
} from './automation';
|
||||
import {
|
||||
filterFreqFromNormalized,
|
||||
fixIds,
|
||||
@@ -141,9 +141,7 @@ function trackAutomationTargets(midiTrack: any, includeArrangementMixer: boolean
|
||||
const mixer = midiTrack.DeviceChain.Mixer;
|
||||
const sequencer = midiTrack.DeviceChain.MainSequencer;
|
||||
addTarget(targets, FaderParam.LVL, {
|
||||
arrangement: includeArrangementMixer
|
||||
? Number(mixer.Volume.AutomationTarget['@Id'])
|
||||
: undefined,
|
||||
arrangement: includeArrangementMixer ? Number(mixer.Volume.AutomationTarget['@Id']) : undefined,
|
||||
session: Number(sequencer.VolumeModulationTarget['@Id']),
|
||||
});
|
||||
addTarget(targets, FaderParam.PAN, {
|
||||
@@ -723,8 +721,7 @@ async function buildGroupTrack(
|
||||
|
||||
if (!exporterParams.clips) {
|
||||
if (koTrack.faderParams[FaderParam.LVL] !== -1) {
|
||||
groupTrack.DeviceChain.Mixer.Volume.Manual['@Value'] =
|
||||
koTrack.faderParams[FaderParam.LVL];
|
||||
groupTrack.DeviceChain.Mixer.Volume.Manual['@Value'] = koTrack.faderParams[FaderParam.LVL];
|
||||
}
|
||||
if (koTrack.faderParams[FaderParam.PAN] !== -1) {
|
||||
groupTrack.DeviceChain.Mixer.Pan.Manual['@Value'] =
|
||||
@@ -828,13 +825,7 @@ async function buildTracks(
|
||||
result.push(groupTrack);
|
||||
}
|
||||
|
||||
const midiTrack = await buildTrack(
|
||||
koTrack,
|
||||
groupLane,
|
||||
maxScenes,
|
||||
trackGroupId,
|
||||
exporterParams,
|
||||
);
|
||||
const midiTrack = await buildTrack(koTrack, groupLane, maxScenes, trackGroupId, exporterParams);
|
||||
|
||||
result.push(midiTrack);
|
||||
}
|
||||
@@ -904,9 +895,7 @@ async function buildReturnTrack(
|
||||
if (projectData.effects.effectType === EffectType.Chorus) {
|
||||
const effectChorusTemplate = await loadTemplate<ALSChorus>('effectChorus', abletonVersion);
|
||||
const effectChorus = structuredClone(
|
||||
abletonVersion === '10'
|
||||
? (effectChorusTemplate as any).Chorus
|
||||
: effectChorusTemplate.Chorus2,
|
||||
abletonVersion === '10' ? (effectChorusTemplate as any).Chorus : effectChorusTemplate.Chorus2,
|
||||
);
|
||||
|
||||
if (abletonVersion === '10') {
|
||||
|
||||
@@ -81,7 +81,8 @@ export async function loadTemplate<T>(
|
||||
return templateCache[cacheKey];
|
||||
}
|
||||
|
||||
const importFn = abletonVersion === '10' ? live10TemplateMap[templateName] : templateMap[templateName];
|
||||
const importFn =
|
||||
abletonVersion === '10' ? live10TemplateMap[templateName] : templateMap[templateName];
|
||||
if (!importFn) {
|
||||
throw new Error(`Unknown template: ${templateName}`);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ function ExportProjectDialog({
|
||||
<div className="text-sm whitespace-pre-line">{NOTES[format]}</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
<div className="mt-4 min-h-13.5">
|
||||
|
||||
Reference in New Issue
Block a user