UNPKG

@mseep/ableton-copilot-mcp

Version:
149 lines 5.73 kB
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 { z } from 'zod'; import { tool } from '../mcp/decorators/decorator.js'; import { commomProp, TrackType, ZodTrackType } from '../types/types.js'; import { Result } from '../utils/common.js'; import { getSongInfo } from '../utils/obj-utils.js'; import { recordByTimeRange } from '../utils/record-utils.js'; import { ableton } from '../ableton.js'; class SongTools { async getSongInfo() { const song = await ableton.song; return await getSongInfo(song); } async getAllTracks() { const tracks = await ableton.song.get('tracks'); return tracks.map((track) => track.raw); } async getTracksTotalCount() { const tracks = await ableton.song.get('tracks'); return tracks.length; } async createTrack(type, index) { let track; switch (type) { case TrackType.midi: track = await ableton.song.createMidiTrack(index); break; case TrackType.audio: track = await ableton.song.createAudioTrack(index); break; case TrackType.return: track = await ableton.song.createReturnTrack(); break; } return track.raw; } async deleteTrack(index, type) { switch (type) { case TrackType.midi || TrackType.audio: await ableton.song.deleteTrack(index); break; case TrackType.return: await ableton.song.deleteReturnTrack(index); break; } return Result.ok(); } async duplicateTrack(index) { await ableton.song.duplicateTrack(index); return Result.ok(); } async recordAudio(start_time, end_time) { return recordByTimeRange(ableton.song, start_time, end_time); } } __decorate([ tool({ name: 'get_song_info', description: `get song basic info, include tempo, time signature, root_note(begin from 0, C..B), scale name, song length`, }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], SongTools.prototype, "getSongInfo", null); __decorate([ tool({ name: 'get_all_tracks', description: 'get all tracks', }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], SongTools.prototype, "getAllTracks", null); __decorate([ tool({ name: 'get_tracks_count', description: 'get midi + audio tracks count', }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], SongTools.prototype, "getTracksTotalCount", null); __decorate([ tool({ name: 'create_track', description: 'create track and return raw track', paramsSchema: { type: ZodTrackType, index: z.number().optional().default(0).describe('[int] index of track default 0, range [0, track count]'), } }), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Number]), __metadata("design:returntype", Promise) ], SongTools.prototype, "createTrack", null); __decorate([ tool({ name: 'delete_track', description: 'delete track by index', paramsSchema: { index: z.number().describe('[int] index of track'), type: ZodTrackType, } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String]), __metadata("design:returntype", Promise) ], SongTools.prototype, "deleteTrack", null); __decorate([ tool({ name: 'duplicate_track', description: 'duplicate midi or audio track by index', paramsSchema: { index: z.number().describe('[int] index of track'), } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise) ], SongTools.prototype, "duplicateTrack", null); __decorate([ tool({ name: 'record_by_time_range', description: `Opens Ableton's audio record button and starts playback from start_time to end_time. Before recording, please: ENSURE: 1. Set the recording track to record mode 2. Set the recording track's input routing to Resample or a specific audio track/input routing 3. After recording, disable the track's record mode`, paramsSchema: { start_time: commomProp.time, end_time: z.number().describe('[int] end time of record'), } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Number]), __metadata("design:returntype", Promise) ], SongTools.prototype, "recordAudio", null); export default SongTools; //# sourceMappingURL=song-tools.js.map