@mseep/ableton-copilot-mcp
Version:
Ableton Live MCP depend on Ableton JS
207 lines • 7.76 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { tool } from '../mcp/decorators/decorator.js';
import { z } from 'zod';
import { NOTE, ClipSettableProp } from '../types/types.js';
import { modifyClipProp } from '../utils/obj-utils.js';
import { getClipById, Result } from '../utils/common.js';
import { ableton } from '../ableton.js';
import { removeAllNotes } from '../utils/clip-utils.js';
async function getDetailClip() {
const detailClip = await ableton.song.view.get('detail_clip');
if (detailClip === null || detailClip === undefined) {
throw new Error('please open piano roll');
}
return detailClip;
}
class ClipTools {
async getDetailClip() {
const detailClip = await getDetailClip();
return detailClip.raw;
}
async getClipInfoById(clip_id) {
const clip = getClipById(clip_id);
return clip.raw;
}
async getClipNotes(clip_id) {
const clip = getClipById(clip_id);
return clip.getNotes(0, 0, 9999, 127);
}
async removeALlClipNotes(clip_id) {
const clip = getClipById(clip_id);
await removeAllNotes(clip);
return Result.ok();
}
async addClipNotes(notes, clip_id) {
const clip = getClipById(clip_id);
await clip.setNotes(notes);
return Result.ok();
}
async replaceAllDetailClipNotes(notes, clip_id) {
const clip = getClipById(clip_id);
await clip.selectAllNotes();
await clip.replaceSelectedNotes(notes);
return Result.ok();
}
async setClipProperty(clip_id, property) {
const clip = getClipById(clip_id);
await modifyClipProp(clip, property);
return Result.ok();
}
async cropClip(clip_id) {
const clip = getClipById(clip_id);
await clip.crop();
return Result.ok();
}
async duplicateLoop(clip_id) {
const clip = getClipById(clip_id);
await clip.duplicateLoop();
return Result.ok();
}
async duplicateRegion(clip_id, region_start, region_end, destination_time, pitch, transposition_amount) {
const clip = getClipById(clip_id);
await clip.duplicateRegion(region_start, region_end, destination_time, pitch, transposition_amount);
return Result.ok();
}
}
__decorate([
tool({
name: 'get_detail_clip',
description: 'Get detail clip/piano roll clip',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "getDetailClip", null);
__decorate([
tool({
name: 'get_clip_info_by_id',
description: 'Get clip info by clip id',
paramsSchema: {
clip_id: z.string()
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "getClipInfoById", null);
__decorate([
tool({
name: 'get_all_notes_by_clipid',
description: 'Get clip all notes by clip id',
paramsSchema: {
clip_id: z.string()
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "getClipNotes", null);
__decorate([
tool({
name: 'remove_clip_all_notes',
description: 'Remove clip all notes by clip id',
paramsSchema: {
clip_id: z.string()
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "removeALlClipNotes", null);
__decorate([
tool({
name: 'add_notes_to_clip',
description: 'Add notes to clip by clip id',
paramsSchema: {
notes: z.array(NOTE).describe('[array] the notes to add.'),
clip_id: z.string()
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "addClipNotes", null);
__decorate([
tool({
name: 'replace_all_notes_to_clip',
description: 'Replace clip all notes by clip id',
paramsSchema: {
notes: z.array(NOTE).describe('[array] the notes to remove.'),
clip_id: z.string()
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "replaceAllDetailClipNotes", null);
__decorate([
tool({
name: 'set_clip_property',
description: 'set clip property',
paramsSchema: {
clip_id: z.string(),
property: ClipSettableProp,
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, void 0]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "setClipProperty", null);
__decorate([
tool({
name: 'crop_clip',
description: `Crops the clip. The region that is cropped depends on whether the clip is looped or not.
If looped, the region outside of the loop is removed. If not looped,
the region outside the start and end markers is removed.`,
paramsSchema: {
clip_id: z.string(),
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "cropClip", null);
__decorate([
tool({
name: 'duplicate_clip_loop',
description: `Makes the loop twice as long and duplicates notes and envelopes.
Duplicates the clip start/end range if the clip is not looped.`,
paramsSchema: {
clip_id: z.string(),
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "duplicateLoop", null);
__decorate([
tool({
name: 'duplicate_clip_region',
description: `Duplicates the notes in the specified region to the destination_time.
Only notes of the specified pitch are duplicated if pitch is not -1.
If the transposition_amount is not 0, the notes in the region will be
transposed by the transposition_amount of semitones.
Raises an error on audio clips..`,
paramsSchema: {
clip_id: z.string(),
region_start: z.number(),
region_end: z.number(),
destination_time: z.number(),
pitch: z.number(),
transposition_amount: z.number(),
}
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Number, Number, Number, Number, Number]),
__metadata("design:returntype", Promise)
], ClipTools.prototype, "duplicateRegion", null);
export default ClipTools;
//# sourceMappingURL=clip-tools.js.map