Tools, patterns, and utilities for creating music with code. Output as a .mp3 file with realistic instrument sounds. Write custom compositions to bring creativity to life through music. This skill should be used whenever the user asks for music to be created. Never use this skill for replicating songs, beats, riffs, or other sensitive works. The skill is not suitable for vocal/lyrical music, audio mixing/mastering (reverb, EQ, compression), real-time MIDI playback, or professional studio recording quality.
This skill provides tools and patterns for music composition, not pre-baked solutions. The intelligence and music21 library should be used to compose dynamically based on user requests.
Core Principle: Write custom code that composes music algorithmically rather than calling functions with hardcoded melodies.
Run the automated installer for complete setup: install.sh. This installs all system dependencies, Python packages, and verifies the installation.
Note: The install script may display "error: externally-managed-environment" messages at the end. These are expected and can be safely ignored - the dependencies are already installed. If such messages appear, the installation was successful.
Traditional Pipeline (Orchestral/Acoustic):
/usr/share/sounds/sf2/FluidR3_GM.sf2 (141MB, General MIDI soundfont - use for high-quality orchestral/acoustic samples)/usr/share/sounds/sf2/default.sf2 (symlink to best available)Electronic Pipeline:
instrument.Violin(), instrument.Violoncello(), instrument.Piano(), instrument.Trumpet(), etc.This skill supports TWO rendering pipelines optimized for different musical styles. Read the user's request carefully and choose the correct pipeline by reading the correct next file.
Identify from the user's request:
Use electronic-music-pipeline.md when request includes:
How it works:
→ See electronic-music-pipeline.md for detailed instructions
Use traditional-music-pipeline.md when request includes:
How it works:
→ See traditional-music-pipeline.md for detailed instructions
All scripts are located in ./scripts:
Traditional Rendering:
midi_inventory.py - Extract complete structure from ANY MIDI file to JSON formatmidi_render.py - Render JSON music structure to MP3 using FluidSynth with dynamic range compressionmidi_utils.py - MIDI utility functions (extract drums, get BPM, etc.)Utilities:
audio_validate.py - Validate audio file quality and formatNote: Both electronic and traditional music use the same rendering pipeline (FluidSynth + FluidR3_GM.sf2). The difference is which GM programs you choose.
CRITICAL: music21 does NOT reliably export program_change messages. You MUST ALWAYS use mido to set program numbers after export, even for traditional instruments like saxophone, guitar, or bass. Without this step, tracks will default to piano (program 0).
INSTRUMENT CATEGORIZATION FOR SYNTHESIS: When composing electronic music, classify instruments by their sonic characteristics for proper synthesis:
# Piano (0-7)