Fix minor bugs in Ableton export logic and refactor code
This commit is contained in:
@@ -708,9 +708,7 @@ async function buildTrack(
|
||||
const hasAutomation = [
|
||||
...(groupLane?.sessionPatterns || []),
|
||||
...(groupLane?.arrangementPatterns || []),
|
||||
].some((pattern) =>
|
||||
pattern.faderAutomation.some((point) => point.parameter === parameter),
|
||||
);
|
||||
].some((pattern) => pattern.faderAutomation.some((point) => point.parameter === parameter));
|
||||
if (hasAutomation || (staticValue !== -1 && staticValue !== defaultValue)) {
|
||||
midiTrack.DeviceChain.DeviceChain.Devices['#'].push(
|
||||
await buildFaderFilterDevice(
|
||||
@@ -916,9 +914,8 @@ async function buildScenes(
|
||||
sceneContent.Tempo['@Value'] = settings.bpm;
|
||||
if (scene?.timeSignature) {
|
||||
sceneContent.TimeSignatureId['@Value'] =
|
||||
TIME_SIGNATURES[
|
||||
`${scene.timeSignature.numerator}/${scene.timeSignature.denominator}`
|
||||
] || TIME_SIGNATURES['4/4'];
|
||||
TIME_SIGNATURES[`${scene.timeSignature.numerator}/${scene.timeSignature.denominator}`] ||
|
||||
TIME_SIGNATURES['4/4'];
|
||||
sceneContent.IsTimeSignatureEnabled['@Value'] = 'true';
|
||||
} else {
|
||||
sceneContent.IsTimeSignatureEnabled['@Value'] = 'false';
|
||||
|
||||
@@ -143,23 +143,22 @@ function getScenePatterns(scene: Scene, patternLookup: Map<string, GroupPattern>
|
||||
}
|
||||
|
||||
function getSceneDuration(scene: Scene, patternLookup: Map<string, GroupPattern>) {
|
||||
const sceneBars = Math.max(1, ...getScenePatterns(scene, patternLookup).map((pattern) => pattern.bars));
|
||||
const sceneBars = Math.max(
|
||||
1,
|
||||
...getScenePatterns(scene, patternLookup).map((pattern) => pattern.bars),
|
||||
);
|
||||
return sceneBars * getQuarterNotesPerBar(scene.timeSignature);
|
||||
}
|
||||
|
||||
function getTrackNoteValues(track: AblTrack) {
|
||||
const clips = [
|
||||
...(track.lane?.sessionClips || []),
|
||||
...(track.lane?.arrangementClips || []),
|
||||
];
|
||||
const clips = [...(track.lane?.sessionClips || []), ...(track.lane?.arrangementClips || [])];
|
||||
return [...new Set(clips.flatMap((clip) => clip.notes.map((note) => note.note)))];
|
||||
}
|
||||
|
||||
function hasTrackMidiEvents(track: AblTrack) {
|
||||
return [
|
||||
...(track.lane?.sessionClips || []),
|
||||
...(track.lane?.arrangementClips || []),
|
||||
].some((clip) => clip.midiEvents.length > 0);
|
||||
return [...(track.lane?.sessionClips || []), ...(track.lane?.arrangementClips || [])].some(
|
||||
(clip) => clip.midiEvents.length > 0,
|
||||
);
|
||||
}
|
||||
|
||||
function fallbackPad(group: Group, source: number): Pad {
|
||||
@@ -199,10 +198,7 @@ function abletonTransformer(data: ProjectRawData, exporterParams: ExporterParams
|
||||
const trackLookup = new Map<PadCode, AblTrack>();
|
||||
const laneLookup = new Map<PadCode, AblLane>();
|
||||
const groupLaneLookup = new Map<Group, AblGroupLane>(
|
||||
PROJECT_GROUPS.map((group) => [
|
||||
group,
|
||||
{ group, sessionPatterns: [], arrangementPatterns: [] },
|
||||
]),
|
||||
PROJECT_GROUPS.map((group) => [group, { group, sessionPatterns: [], arrangementPatterns: [] }]),
|
||||
);
|
||||
const ablScenes: AblScene[] = [];
|
||||
const arrangementSections: AblArrangementSection[] = [];
|
||||
@@ -551,8 +547,7 @@ function abletonTransformer(data: ProjectRawData, exporterParams: ExporterParams
|
||||
trimLeft: 0,
|
||||
trimRight: 0,
|
||||
pad: 0,
|
||||
lane:
|
||||
lane.sessionClips.length > 0 || lane.arrangementClips.length > 0 ? lane : undefined,
|
||||
lane: lane.sessionClips.length > 0 || lane.arrangementClips.length > 0 ? lane : undefined,
|
||||
playMode: 'oneshot',
|
||||
pan: 0,
|
||||
pitch: 0,
|
||||
|
||||
Reference in New Issue
Block a user