Skip to main content
Glama

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
NameRequiredDescriptionDefault
filePathYesAbsoulate File Path to midi file
trackIndexYesTrack index number

Implementation Reference

  • 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), }, ] } }) )
  • 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'), },

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/midi-file-mcp'

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