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']);
|
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(
|
async function buildMidiClip(
|
||||||
koClip: AblClip,
|
koClip: AblClip,
|
||||||
clipIdx: number,
|
clipIdx: number,
|
||||||
@@ -160,6 +183,10 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
|||||||
device.LastPresetRef.Value = {};
|
device.LastPresetRef.Value = {};
|
||||||
switch (koTrack.playMode) {
|
switch (koTrack.playMode) {
|
||||||
case 'legato':
|
case 'legato':
|
||||||
|
device.Globals.PlaybackMode['@Value'] = 0;
|
||||||
|
device.Globals.NumVoices['@Value'] = 1;
|
||||||
|
device.Globals.RetriggerMode['@Value'] = 'false';
|
||||||
|
break;
|
||||||
case 'oneshot':
|
case 'oneshot':
|
||||||
device.Globals.PlaybackMode['@Value'] = 1;
|
device.Globals.PlaybackMode['@Value'] = 1;
|
||||||
break;
|
break;
|
||||||
@@ -167,9 +194,15 @@ async function buildSimplerDevice(koTrack: AblTrack, abletonVersion: AbletonVers
|
|||||||
device.Globals.PlaybackMode['@Value'] = 0;
|
device.Globals.PlaybackMode['@Value'] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleRef.FileRef.RelativePath[
|
const sampleRef = device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleRef;
|
||||||
'@Value'
|
if (abletonVersion === '10') {
|
||||||
] = toNativePath(`Samples/Imported/${koTrack.sampleName}`);
|
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.Name['@Value'] = koTrack.name;
|
||||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.RootKey['@Value'] = koTrack.rootNote;
|
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.RootKey['@Value'] = koTrack.rootNote;
|
||||||
device.Player.MultiSampleMap.SampleParts.MultiSamplePart.SampleStart['@Value'] = koTrack.trimLeft;
|
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);
|
pitch += Math.round(normalized * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// adding TUNE fader param if defined
|
|
||||||
if (koTrack.faderParams[FaderParam.TUNE] !== -1) {
|
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;
|
device.Pitch.TransposeKey.Manual['@Value'] = pitch;
|
||||||
|
|||||||
Reference in New Issue
Block a user