TP : Importer de l'audio dans la Session et l'Arrangement
Objectif : Automatiser l'importation audio dans Live
Dans ce TP pratique, nous allons concevoir une extension capable d'importer des fichiers audio à la volée directement depuis le menu contextuel du clic droit d'Ableton Live 12.4.5.
Vous allez apprendre à intégrer cette action à deux endroits stratégiques de l'interface :
- Sur un Slot de clip (ClipSlot) en vue Session.
- Sur une Sélection d'Arrangement (ArrangementSelection) sur une piste audio.
L'extension proposera à chaque fois deux options : importer l'audio brut (unwarped) ou importer l'audio synchronisé au tempo (warped).
import * as ableton from "@ableton-extensions/sdk";
// Remplacez ce chemin par le chemin absolu d'un fichier audio sur votre disque !
const filePath = "/your/path/to/sample.wav";
export function activate(activation: ableton.ActivationContext) {
const context = ableton.initialize(activation, "1.0.0");
// 1. Enregistrement des actions dans le menu contextuel (Session)
context.ui.registerContextMenuAction("ClipSlot", "Create unwarped clip", "clipslot.Unwarped");
context.ui.registerContextMenuAction("ClipSlot", "Create warped clip", "clipslot.Warped");
// 2. Enregistrement des actions dans le menu contextuel (Arrangement)
context.ui.registerContextMenuAction("AudioTrack.ArrangementSelection", "Create unwarped clip", "ArrangementSelection.Unwarped");
context.ui.registerContextMenuAction("AudioTrack.ArrangementSelection", "Create warped clip", "ArrangementSelection.Warped");
// 3. Commande : Importation brute dans un ClipSlot (Session)
context.commands.registerCommand("clipslot.Unwarped", async (arg: unknown) => {
try {
const clipSlot = context.getObjectFromHandle(arg as ableton.Handle, ableton.ClipSlot);
const imported = await context.resources.importIntoProject(filePath);
await clipSlot.createAudioClip({
filePath: imported,
isWarped: false,
loopSettings: { looping: false, startMarker: 1, endMarker: 5, loopStart: 1, loopEnd: 5 }
});
} catch (e) {
console.error(e);
}
});
// 4. Commande : Importation synchronisée (Warped) dans un ClipSlot (Session)
context.commands.registerCommand("clipslot.Warped", async (arg: unknown) => {
try {
const clipSlot = context.getObjectFromHandle(arg as ableton.Handle, ableton.ClipSlot);
const imported = await context.resources.importIntoProject(filePath);
await clipSlot.createAudioClip({
filePath: imported,
isWarped: true,
loopSettings: { looping: true, startMarker: 1, endMarker: 5, loopStart: 1, loopEnd: 5 }
});
} catch (e) {
console.error(e);
}
});
// 5. Commande : Importation brute dans l'Arrangement
context.commands.registerCommand("ArrangementSelection.Unwarped", async (arg: unknown) => {
try {
const selection = arg as ableton.ArrangementSelection;
const track = context.getObjectFromHandle(selection.selected_lanes[0]!, ableton.AudioTrack);
const imported = await context.resources.importIntoProject(filePath);
await track.createAudioClip({
filePath: imported,
startTime: selection.time_selection_start,
duration: selection.time_selection_end - selection.time_selection_start,
isWarped: false
});
} catch (e) {
console.error(e);
}
});
// 6. Commande : Importation synchronisée (Warped) dans l'Arrangement
context.commands.registerCommand("ArrangementSelection.Warped", async (arg: unknown) => {
try {
const selection = arg as ableton.ArrangementSelection;
const track = context.getObjectFromHandle(selection.selected_lanes[0]!, ableton.AudioTrack);
const imported = await context.resources.importIntoProject(filePath);
await track.createAudioClip({
filePath: imported,
startTime: selection.time_selection_start,
duration: selection.time_selection_end - selection.time_selection_start,
isWarped: true
});
} catch (e) {
console.error(e);
}
});
}
Contenu premium
Abonnez-vous ou achetez la formation pour accéder à l'intégralité du contenu.
- Accès illimité à 1700 formations