MIDI Generation Skill is a custom Agent Skill for Claude.ai that enables AI agents to generate MIDI files from natural language music descriptions, with full General MIDI instrument support optimized for the A320U.sf2 SoundFont.
- Generate MIDI from text prompts
- 128 GM instruments - Full General MIDI support (A320U.sf2 compatible)
- WAV export - Convert MIDI to audio using FluidSynth
- Claude Skills compatible - Automatic skill invocation
- Python implementation using midiutil
/
├─ skills/ # Skill implementation (Python)
│ ├─ generate_midi.py # MIDI file generation
│ ├─ convert_to_wav.py # MIDI to WAV conversion (FluidSynth)
│ ├─ normalize_composition.py # Input validation
│ └─ refine_composition.py # Adjust composition length
├─ midi_types/
│ ├─ music.py # Composition types
│ └─ gm_instruments.py # 128 GM instruments list
├─ resources/ # Music theory references
│ ├─ music-theory.md
│ ├─ chord-progressions.md
│ ├─ voice-leading.md
│ ├─ counterpoint.md
│ ├─ modes-scales.md
│ ├─ rhythm-patterns.md
│ └─ orchestration.md
├─ soundfonts/ # Place A320U.sf2 here
├─ output/ # Generated MIDI/WAV files
├─ SKILL.md # Claude Skill definition
├─ requirements.txt # Python dependencies
└─ README.md
All 128 General MIDI instruments are supported. Common examples:
| Category | Instruments |
|---|---|
| Piano | acoustic-grand-piano, electric-piano-1, harpsichord |
| Guitar | acoustic-guitar-nylon, electric-guitar-clean, distortion-guitar |
| Bass | acoustic-bass, electric-bass-finger, synth-bass-1 |
| Strings | violin, cello, string-ensemble-1, orchestral-harp |
| Brass | trumpet, trombone, french-horn, brass-section |
| Woodwind | flute, clarinet, oboe, alto-sax |
| Synth | lead-1-square, pad-1-new-age, synth-strings-1 |
Simple aliases like piano, guitar, bass, strings, brass, sax are also supported.
See midi_types/gm_instruments.py for the full list.
pip install midiutilOr using requirements.txt:
pip install -r requirements.txt- Download A320U.sf2 from Musical Artifacts
- Place it in
soundfonts/A320U.sf2
# macOS
brew install fluidsynth
# Linux
apt-get install fluidsynth- Open Claude Settings
- Enable Skills
- Upload this repository as a ZIP file
- Turn the skill ON
Simply ask Claude something related to music:
Added the “midi-generation” skill. Use it to create grand classical music. I look forward to bright, grand, and beautiful melodies layered together. Once you have the MIDI, please convert it to WAV.
Claude will automatically:
- Detect that the request matches this skill
- Use the provided Python scripts in
skills/directory - Generate MIDI with proper GM instruments (each track on different channel)
- Optionally convert to WAV
1.mp4
The skill uses a structured JSON format:
{
"title": "My Song",
"bpm": 120,
"tracks": [
{
"instrument": "acoustic-grand-piano",
"notes": [
{ "pitch": "C4", "duration": "4" },
{ "pitch": "E4", "duration": "4" },
{ "pitch": "G4", "duration": "2" }
]
},
{
"instrument": "acoustic-bass",
"notes": [
{ "pitch": "C2", "duration": "1" }
]
}
]
}| Value | Duration |
|---|---|
"1" |
Whole note (4 beats) |
"2" |
Half note (2 beats) |
"d2" |
Dotted half (3 beats) |
"4" |
Quarter note (1 beat) |
"d4" |
Dotted quarter (1.5 beats) |
"8" |
Eighth note (0.5 beats) |
"16" |
Sixteenth note (0.25 beats) |
Generate a MIDI file from a Composition object.
- Input: Composition object with title, bpm, and tracks
- Output: Path to the generated
.midfile
Generate a MIDI file from a dictionary.
- Input: Dictionary with title, bpm, and tracks
- Output: Path to the generated
.midfile
Convert a MIDI file to WAV using FluidSynth and A320U.sf2.
- Input: Path to MIDI file
- Output: Path to the generated
.wavfile
Validate and normalize user input into a proper Composition object.
Adjust composition length (ensures minimum notes per track).
Convert instrument name to GM program number (0-127).
Create a calm ambient piece with pad synths and strings
Generate a rock song with distortion guitar and drums at 140 BPM
Compose a classical piece with violin, cello, and harpsichord
SKILL.mddefines when and how Claude should use this skill- The
skills/directory contains pre-built Python scripts that Claude must use - Claude should NOT write custom code - it should use the provided functions
- All instruments are GM-compatible for A320U.sf2 playback
- Each track is assigned to a different MIDI channel for proper multi-instrument playback
MIT License
See LICENSE.txt for details including third-party licenses.