get_pitchbends_by_index
Extract pitch bend data from a MIDI file for a specific track by providing the file path and track index.
Instructions
Get pitchbends from midi file by track index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absoulate File Path to midi file | |
| trackIndex | Yes | Track index number |
Implementation Reference
- src/main.ts:180-192 (handler)Handler function that loads the MIDI file using loadMidiFile, retrieves the specific track using getTrackByIndex, extracts the pitchBends array from the track's JSON representation, and returns it as a JSON string in the MCP response format.withErrorHandling(({ filePath, trackIndex }) => { const midi = loadMidiFile(filePath) const track = getTrackByIndex(midi, trackIndex) const pitchbends = track.toJSON().pitchBends return { content: [ { type: 'text', text: JSON.stringify(pitchbends), }, ] } })
- src/main.ts:173-193 (registration)Registers the 'get_pitchbends_by_index' tool with the MCP server, including name, description, input schema, and the handler function wrapped in error handling.server.tool( 'get_pitchbends_by_index', 'Get pitchbends from midi file by track index', { filePath: z.string().describe('Absoulate File Path to midi file'), trackIndex: z.number().describe('Track index number'), }, withErrorHandling(({ filePath, trackIndex }) => { const midi = loadMidiFile(filePath) const track = getTrackByIndex(midi, trackIndex) const pitchbends = track.toJSON().pitchBends return { content: [ { type: 'text', text: JSON.stringify(pitchbends), }, ] } }) )
- src/main.ts:176-179 (schema)Input schema defined using Zod for the tool parameters: filePath (absolute path to MIDI file) and trackIndex (numeric index of the track).{ filePath: z.string().describe('Absoulate File Path to midi file'), trackIndex: z.number().describe('Track index number'), },