Generate MIDI files with GM instruments and music theory. Use when creating music, composing melodies, or generating MIDI files.
Generate MIDI files with proper music theory. Use the provided Python scripts in skills/. Do NOT write custom code.
skills/ directory (Python)pip install midiutilAlways follow these to avoid harsh sounds:
Only read the resource that matches your current task:
| When you need... | Read this file |
|---|---|
| Scales, chords, intervals, cadences | resources/music-theory.md |
| Chord progressions by genre | resources/chord-progressions.md |
| Avoiding dissonance, voice spacing | resources/voice-leading.md |
| Classical/Baroque counterpoint | resources/counterpoint.md |
| Modes (Dorian, Phrygian, etc.) | resources/modes-scales.md |
| Rhythm, time signatures, syncopation | resources/rhythm-patterns.md |
| Instrument ranges, combinations | resources/orchestration.md |
pip install midiutil| Script | Purpose |
|---|---|
skills/generate_midi.py | Generate MIDI (auto-assigns channels per track) |
skills/normalize_composition.py | Validate and normalize input |
skills/refine_composition.py | Adjust length, extend tracks |
skills/convert_to_wav.py | MIDI → WAV (requires FluidSynth) |
import sys
sys.path.insert(0, '/path/to/midi-skill')
from skills.generate_midi import generate_midi_from_dict
composition = {
"title": "My Song",
"bpm": 120,
"tracks": [
{
"instrument": "acoustic-grand-piano",
"notes": [
{"pitch": "C4", "duration": "4"},
{"pitch": "E4", "duration": "4"},
{"pitch": "G4", "duration": "4"},
{"pitch": "C5", "duration": "2"}
]
},
{
"instrument": "acoustic-bass",
"notes": [
{"pitch": "C2", "duration": "2"},
{"pitch": "G2", "duration": "2"}
]
}
]
}
midi_path = generate_midi_from_dict(composition)
print(f"Generated: {midi_path}")
{
"title": "My Song",
"bpm": 120,
"tracks": [
{
"instrument": "acoustic-grand-piano",
"notes": [
{ "pitch": "C4", "duration": "4" },
{ "pitch": "E4", "duration": "4" }
]
},
{
"instrument": "acoustic-bass",
"notes": [
{ "pitch": "C2", "duration": "2" }
]
}
]
}
| Value | Note |
|---|---|
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) |
| Alias | GM Instrument |
|---|---|
piano | acoustic-grand-piano |
guitar | acoustic-guitar-nylon |
bass | acoustic-bass |
strings | string-ensemble-1 |
brass | brass-section |
sax | alto-sax |
Full list: midi_types/gm_instruments.py
output/ directorysoundfonts/