add_audio_keyframes
Apply precise audio keyframes to clips in Adobe Premiere Pro for customizable volume adjustments. Define time and dB levels to automate dynamic audio changes.
Instructions
Adds keyframes to audio levels for dynamic volume changes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clipId | Yes | The ID of the audio clip | |
| keyframes | Yes | Array of keyframe data |
Implementation Reference
- src/tools/index.ts:1419-1469 (handler)The handler function that executes the 'add_audio_keyframes' tool. It generates an ExtendScript that finds the audio clip, accesses its Volume property, and adds keyframes at specified times with given levels.private async addAudioKeyframes(clipId: string, keyframes: Array<{time: number, level: number}>): Promise<any> { const script = ` try { var clip = app.project.getClipByID("${clipId}"); if (!clip) { JSON.stringify({ success: false, error: "Clip not found" }); return; } var audioComponent = clip.components[0]; if (!audioComponent || !audioComponent.properties["Volume"]) { JSON.stringify({ success: false, error: "Audio component not found or clip has no audio" }); return; } var volumeProperty = audioComponent.properties["Volume"]; var addedKeyframes = []; ${keyframes.map(kf => ` try { volumeProperty.addKey(new Time("${kf.time}s")); volumeProperty.setValueAtKey(new Time("${kf.time}s"), ${kf.level}); addedKeyframes.push({ time: ${kf.time}, level: ${kf.level} }); } catch (e) { // Keyframe already exists or invalid time } `).join('\n')} JSON.stringify({ success: true, message: "Audio keyframes added successfully", clipId: "${clipId}", addedKeyframes: addedKeyframes, totalKeyframes: addedKeyframes.length }); } catch (e) { JSON.stringify({ success: false, error: e.toString() }); } `; return await this.bridge.executeScript(script); }
- src/tools/index.ts:238-248 (schema)The input schema definition for the 'add_audio_keyframes' tool, using Zod for validation.{ name: 'add_audio_keyframes', description: 'Adds keyframes to audio levels for dynamic volume changes.', inputSchema: z.object({ clipId: z.string().describe('The ID of the audio clip'), keyframes: z.array(z.object({ time: z.number().describe('Time in seconds'), level: z.number().describe('Audio level in dB') })).describe('Array of keyframe data') }) },
- src/tools/index.ts:486-487 (registration)The switch case in executeTool that registers and dispatches to the addAudioKeyframes handler.case 'add_audio_keyframes': return await this.addAudioKeyframes(args.clipId, args.keyframes);