Skip to main content
Glama

record_by_time_range

Automate audio recording in Ableton Live by specifying start and end times. Ensure the track is in record mode with correct input routing before initiating playback from the defined time range.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_timeYes[int] end time of record
start_timeYes[float] the time in beats of absolute clip time. such as 4 is 4 beats

Implementation Reference

  • Core handler function that implements the recording logic for the specified time range. It configures the song's start time and record mode, sets up a listener to monitor current song time, and stops recording and playback upon reaching the end time.
    export async function recordByTimeRange(song: Song, start_time: number, end_time: number) { await song.set('start_time' as any, start_time) await song.set('record_mode', 1) return new Promise<string>((resolve, reject) => { let removeFunc: (() => Promise<boolean | undefined>) | undefined song.addListener('current_song_time', async (time) => { try { if (time >= end_time) { // remove this listener if (removeFunc) { const release = await mutex.acquire() try { if (removeListenerFuncs.includes(removeFunc)) { await removeFunc() // remove from array removeListenerFuncs.splice(removeListenerFuncs.indexOf(removeFunc), 1) logger.info('remove listener in record_by_time_range') } } finally { release() } } await song.set('record_mode', 0) await song.stopPlaying() resolve(Result.ok()) } } catch (err) { if (removeFunc) { const release = await mutex.acquire() try { if (removeListenerFuncs.includes(removeFunc)) { await removeFunc() // remove from array removeListenerFuncs.splice(removeListenerFuncs.indexOf(removeFunc), 1) logger.info('remove listener in record_by_time_range') } } finally { release() } } reject(`record_by_time_range failed: ${err}`) } }).then(async listenerRemoveFunc => { removeFunc = listenerRemoveFunc const release = await mutex.acquire() try { removeListenerFuncs.push(listenerRemoveFunc) } finally { release() } }).catch(err => { logger.error(err) resolve('record_by_time_range failed') }) }) }
  • Zod schema defining the input parameters for the tool: start_time and end_time.
    paramsSchema: { start_time: commomProp.time, end_time: z.number().describe('[int] end time of record'), } })
  • Registers the 'record_by_time_range' tool using the @tool decorator, includes description and schema, and defines the handler method that delegates to the core recordByTimeRange function.
    @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(get from get_track_available_input_routings tool) 3. After recording, disable the track's record mode`, paramsSchema: { start_time: commomProp.time, end_time: z.number().describe('[int] end time of record'), } }) async recordAudio({ start_time, end_time }: { start_time: number, end_time: number, }) { return recordByTimeRange(ableton.song, start_time, end_time) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaolaa2/ableton-copilot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server