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