Midra
Midra is an agentic prompt-to-code MIDI composition framework for editable and controllable music generation.
A Python tool that converts a text prompt describing music into an editable MIDI file, using an AI model to plan each instrument track through staged checkpoints so you can open and adjust the result in any music software.
Midra is a Python tool that turns text descriptions into music files. You type a prompt describing what you want, such as a cyberpunk boss battle background track with drums, bass, chords, and lead, and Midra produces a MIDI file. MIDI is a standard format for musical notation that most audio software can open, edit, and play back.
The thing that sets Midra apart from most AI music tools is that it works through structured symbolic music code rather than generating audio directly. Most AI music generators take your prompt and produce an audio file you cannot easily change. Midra instead breaks the work into planning stages, writes out a musical blueprint first, saves intermediate checkpoint files at each step, and finally renders a MIDI file. Because MIDI is an editable format, you can open the result in any music software, move notes around, change instruments, or pick up from a saved checkpoint and re-run part of the process.
The tool has two note-generation modes. In LLM mode, the notes for each track are planned by the AI model, which tries to match the mood and variation you described. In rule mode, notes are generated by deterministic code, giving more consistent and repeatable results but less creative variation. You can run Midra from the command line or through a web interface via Docker.
Setup requires Python 3.11 and an OpenAI API key. You also need two system tools, ffmpeg and fluidsynth, for rendering the final audio from MIDI. Docker Compose is available if you want to run the full frontend and backend together.
The project is licensed under Apache 2.0.
Where it fits
- Generate a multi-track MIDI file from a text description such as a cyberpunk boss battle with drums, bass, and lead, then open it in any music software to adjust individual notes.
- Resume generation from a saved checkpoint file if you want to change a specific instrument track without redoing the entire composition.
- Run Midra in rule mode to get a consistent, repeatable MIDI arrangement without AI variation for use in automated pipelines.