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': '' };
|
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(
|
function targetFor(
|
||||||
parameter: any,
|
parameter: any,
|
||||||
maxValue?: number,
|
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.SendingNote['@Value'] = subtrack.drumRackSendingNote ?? subtrack.rootNote; // not sure if this matters
|
||||||
drumBranch.BranchInfo.ChokeGroup['@Value'] = subtrack.inChokeGroup ? 1 : 0;
|
drumBranch.BranchInfo.ChokeGroup['@Value'] = subtrack.inChokeGroup ? 1 : 0;
|
||||||
drumBranch.MixerDevice.Volume.Manual['@Value'] = subtrack.volume;
|
drumBranch.MixerDevice.Volume.Manual['@Value'] = subtrack.volume;
|
||||||
drumBranch.DeviceChain.MidiToAudioDeviceChain.Devices = await buildSimplerDevice(
|
const branchDevices = await buildSimplerDevice(
|
||||||
subtrack,
|
subtrack,
|
||||||
abletonVersion,
|
abletonVersion,
|
||||||
);
|
);
|
||||||
|
assignDeviceListIds([branchDevices]);
|
||||||
|
drumBranch.DeviceChain.MidiToAudioDeviceChain.Devices = branchDevices;
|
||||||
|
|
||||||
device.Branches.DrumBranch.push(drumBranch);
|
device.Branches.DrumBranch.push(drumBranch);
|
||||||
}
|
}
|
||||||
@@ -727,11 +737,7 @@ async function buildTrack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure id's are sequential in device chain
|
// make sure id's are sequential in device chain
|
||||||
midiTrack.DeviceChain.DeviceChain.Devices['#'].forEach((device, deviceIdx) => {
|
assignDeviceListIds(midiTrack.DeviceChain.DeviceChain.Devices['#']);
|
||||||
Object.values(device).forEach((devContent: any) => {
|
|
||||||
devContent['@Id'] = deviceIdx;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (exporterParams.groupTracks) {
|
if (exporterParams.groupTracks) {
|
||||||
midiTrack.DeviceChain.AudioOutputRouting.Target['@Value'] = 'AudioOut/GroupTrack';
|
midiTrack.DeviceChain.AudioOutputRouting.Target['@Value'] = 'AudioOut/GroupTrack';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
|
import { assignDeviceListIds } from '../src/lib/exporters/ableton/builders';
|
||||||
import abletonTransformer, { AblTrack, getDrumRackMidiNote } from '../src/lib/transformers/ableton';
|
import abletonTransformer, { AblTrack, getDrumRackMidiNote } from '../src/lib/transformers/ableton';
|
||||||
import {
|
import {
|
||||||
EffectType,
|
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', () => {
|
test('automatically builds a per-group rack without flattening chromatic pads', () => {
|
||||||
const result = abletonTransformer(project(), {
|
const result = abletonTransformer(project(), {
|
||||||
includeArchivedSamples: true,
|
includeArchivedSamples: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user