Update Ableton export logic for sample references and playback modes
This commit is contained in:
@@ -59,6 +59,29 @@ function getColorValue(node: any): number {
|
||||
return Number(color['@Value']);
|
||||
}
|
||||
|
||||
function setLive10SampleReference(fileRef: any, sampleName: string) {
|
||||
const pathElements = ['Samples', 'Imported'].map((dir, id) => ({
|
||||
'@Id': id,
|
||||
'@Dir': dir,
|
||||
}));
|
||||
fileRef.HasRelativePath = { '@Value': 'true' };
|
||||
fileRef.RelativePathType = { '@Value': 3 };
|
||||
fileRef.RelativePath = { RelativePathElement: pathElements };
|
||||
fileRef.Name = { '@Value': sampleName };
|
||||
fileRef.Type = { '@Value': 2 };
|
||||
fileRef.Data = {};
|
||||
fileRef.RefersToFolder = { '@Value': 'false' };
|
||||
fileRef.SearchHint = {
|
||||
PathHint: { RelativePathElement: pathElements },
|
||||
FileSize: { '@Value': 0 },
|
||||
Crc: { '@Value': 0 },
|
||||
MaxCrcSize: { '@Value': 16384 },
|
||||
HasExtendedInfo: { '@Value': 'false' },
|
||||
};
|
||||
fileRef.LivePackName = { '@Value': '' };
|
||||
fileRef.LivePackId = { '@Value': '' };
|
||||
}
|
||||
|
||||
async function buildMidiClip(
|
||||
koClip: AblClip,
|
||||
clipIdx: number,
|
||||
@@ -160,6 +183,10 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
||||
device.LastPresetRef.Value = {};
|
||||
switch (koTrack.playMode) {
|
||||
case 'legato':
|
||||
device.Globals.PlaybackMode['@Value'] = 0;
|
||||
device.Globals.NumVoices['@Value'] = 1;
|
||||
device.Globals.RetriggerMode['@Value'] = 'false';
|
||||
break;
|
||||
case 'oneshot':
|
||||
device.Globals.PlaybackMode['@Value'] = 1;
|
||||
break;
|
||||
@@ -167,9 +194,15 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
||||
device.Globals.PlaybackMode['@Value'] = 0;
|
||||
break;
|
||||
}
|
||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleRef.FileRef.RelativePath[
|
||||
'@Value'
|
||||
] = toNativePath(`Samples/Imported/${koTrack.sampleName}`);
|
||||
const sampleRef = device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleRef;
|
||||
if (abletonVersion === '10') {
|
||||
setLive10SampleReference(sampleRef.FileRef, koTrack.sampleName);
|
||||
sampleRef.SourceContext = {};
|
||||
} else {
|
||||
sampleRef.FileRef.RelativePath['@Value'] = toNativePath(
|
||||
`Samples/Imported/${koTrack.sampleName}`,
|
||||
);
|
||||
}
|
||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.Name['@Value'] = koTrack.name;
|
||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.RootKey['@Value'] = koTrack.rootNote;
|
||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleStart['@Value'] = koTrack.trimLeft;
|
||||
@@ -213,9 +246,9 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
||||
pitch += Math.round(normalized * 5);
|
||||
}
|
||||
|
||||
// adding TUNE fader param if defined
|
||||
if (koTrack.faderParams[FaderParam.TUNE] !== -1) {
|
||||
pitch += Math.round(koTrack.faderParams[FaderParam.TUNE] * 23.5 - 12); // the range is slightly less than +/-12 cause that's how KO does it
|
||||
device.Pitch.TransposeFine.Manual['@Value'] =
|
||||
Math.max(-0.5, Math.min(0.5, koTrack.faderParams[FaderParam.TUNE] - 0.5)) * 100;
|
||||
}
|
||||
|
||||
device.Pitch.TransposeKey.Manual['@Value'] = pitch;
|
||||
|
||||
Reference in New Issue
Block a user