Skip to content
midi-generation logo

MIDI Generation Skill

midi-generation

Generate MIDI files with GM instruments and music theory. Use when creating music, composing melodies, or generating MIDI files.

SKILL.md

Full skill instructions

MIDI Generation Skill

Generate MIDI files with proper music theory. Use the provided Python scripts in skills/. Do NOT write custom code.

Important Rules

  1. Use provided scripts in skills/ directory (Python)
  2. Never write custom Python/​JS for MIDI generation
  3. Install dependencies first: pip install midiutil
  4. Consult music theory resources when needed (see below)

Quick Dissonance Rules

Always follow these to avoid harsh sounds:

  1. Never play notes 1 semitone apart (C+C#, E+F, B+C)
  2. Bass plays root or fifth of the chord
  3. Spread voices across octaves (don't cluster)
  4. Each track uses different MIDI channel (automatic)

Music Theory Resources (Read When Needed)

Only read the resource that matches your current task:

When you need...Read this file
Scales, chords, intervals, cadencesresources/​music-theory.md
Chord progressions by genreresources/​chord-progressions.md
Avoiding dissonance, voice spacingresources/​voice-leading.md
Classical/​Baroque counterpointresources/​counterpoint.md
Modes (Dorian, Phrygian, etc.)resources/​modes-scales.md
Rhythm, time signatures, syncopationresources/​rhythm-patterns.md
Instrument ranges, combinationsresources/​orchestration.md

When to Read Each Resource

  • Pop/​Rock song → chord-progressions.md + voice-leading.md
  • Classical piece → counterpoint.md + orchestration.md
  • Jazz composition → modes-scales.md + chord-progressions.md
  • Film score → orchestration.md + modes-scales.md
  • Any composition → Always check voice-leading.md for dissonance

Workflow

  1. Install dependencies: pip install midiutil
  2. Identify genre/​style → Select appropriate resources
  3. Read relevant theory → Only the files you need
  4. Choose instruments → See midi_types/​gm_instruments.py
  5. Create composition JSON
  6. Use scripts to generate MIDI

Python Scripts

ScriptPurpose
skills/​generate_midi.pyGenerate MIDI (auto-assigns channels per track)
skills/​normalize_composition.pyValidate and normalize input
skills/​refine_composition.pyAdjust length, extend tracks
skills/​convert_to_wav.pyMIDI → WAV (requires FluidSynth)

Usage Example

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}")

Composition Format

{
  "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" }
      ]
    }
  ]
}

Duration Notation

ValueNote
1Whole note (4 beats)
2Half note (2 beats)
d2Dotted half (3 beats)
4Quarter note (1 beat)
d4Dotted quarter (1.5 beats)
8Eighth note (0.5 beats)
16Sixteenth note (0.25 beats)

Instrument Aliases

AliasGM Instrument
pianoacoustic-grand-piano
guitaracoustic-guitar-nylon
bassacoustic-bass
stringsstring-ensemble-1
brassbrass-section
saxalto-sax

Full list: midi_types/​gm_instruments.py

Notes

  • Max 15 melodic tracks (MIDI channels 0-8, 10-15; ch.9 = drums)
  • Output: output/ directory
  • WAV requires: FluidSynth + A320U.sf2 in soundfonts/

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View