Feature: Implement device ID assignment utility and apply it to build processes
This commit is contained in:
@@ -121,6 +121,14 @@ function setLive10SampleReference(fileRef: any, sampleName: string) {
|
||||
fileRef.LivePackId = { '@Value': '' };
|
||||
}
|
||||
|
||||
export function assignDeviceListIds(devices: Record<string, any>[]) {
|
||||
devices.forEach((device, deviceIdx) => {
|
||||
Object.values(device).forEach((devContent: any) => {
|
||||
devContent['@Id'] = deviceIdx;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function targetFor(
|
||||
parameter: any,
|
||||
maxValue?: number,
|
||||
@@ -647,10 +655,12 @@ async function buildDrumRackDevice(koTrack: AblTrack, abletonVersion: AbletonVer
|
||||
drumBranch.BranchInfo.SendingNote['@Value'] = subtrack.drumRackSendingNote ?? subtrack.rootNote; // not sure if this matters
|
||||
drumBranch.BranchInfo.ChokeGroup['@Value'] = subtrack.inChokeGroup ? 1 : 0;
|
||||
drumBranch.MixerDevice.Volume.Manual['@Value'] = subtrack.volume;
|
||||
drumBranch.DeviceChain.MidiToAudioDeviceChain.Devices = await buildSimplerDevice(
|
||||
const branchDevices = await buildSimplerDevice(
|
||||
subtrack,
|
||||
abletonVersion,
|
||||
);
|
||||
assignDeviceListIds([branchDevices]);
|
||||
drumBranch.DeviceChain.MidiToAudioDeviceChain.Devices = branchDevices;
|
||||
|
||||
device.Branches.DrumBranch.push(drumBranch);
|
||||
}
|
||||
@@ -727,11 +737,7 @@ async function buildTrack(
|
||||
}
|
||||
|
||||
// make sure id's are sequential in device chain
|
||||
midiTrack.DeviceChain.DeviceChain.Devices['#'].forEach((device, deviceIdx) => {
|
||||
Object.values(device).forEach((devContent: any) => {
|
||||
devContent['@Id'] = deviceIdx;
|
||||
});
|
||||
});
|
||||
assignDeviceListIds(midiTrack.DeviceChain.DeviceChain.Devices['#']);
|
||||
|
||||
if (exporterParams.groupTracks) {
|
||||
midiTrack.DeviceChain.AudioOutputRouting.Target['@Value'] = 'AudioOut/GroupTrack';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { assignDeviceListIds } from '../src/lib/exporters/ableton/builders';
|
||||
import abletonTransformer, { AblTrack, getDrumRackMidiNote } from '../src/lib/transformers/ableton';
|
||||
import {
|
||||
EffectType,
|
||||
@@ -144,6 +145,15 @@ function trackShape(tracks: AblTrack[]) {
|
||||
}));
|
||||
}
|
||||
|
||||
test('assigns IDs to every device-list member, including nested rack devices', () => {
|
||||
const devices = [{ OriginalSimpler: {} }, { AutoFilter: {} }];
|
||||
|
||||
assignDeviceListIds(devices);
|
||||
|
||||
assert.equal(devices[0].OriginalSimpler['@Id'], 0);
|
||||
assert.equal(devices[1].AutoFilter['@Id'], 1);
|
||||
});
|
||||
|
||||
test('automatically builds a per-group rack without flattening chromatic pads', () => {
|
||||
const result = abletonTransformer(project(), {
|
||||
includeArchivedSamples: true,
|
||||
|
||||
Reference in New Issue
Block a user