A Python command-line tool that analyzes MIDI files and generates skeletal diagrams based on Minao Shibata's skeletal figure theory. The system performs melodic analysis using fourth-interval relationships and generates visual diagrams showing core notes and ornamental notes.
- MIDI Input Processing: Reads MIDI files and extracts primary melodic lines
- Key Detection: Automatic key signature detection with manual override option
- Relative Pitch Conversion: Converts MIDI notes to solfege notation (Do, Re, Mi, etc.)
- Skeletal Analysis: Identifies fourth-interval core note pairs following Shibata's theory
- Ornamental Classification: Classifies decorative notes based on interval distance from core notes
- Visual Diagrams: Generates high-quality skeletal diagrams with precise positioning
- Multiple Segmentation: Supports measure, phrase, section, and automatic segmentation modes
- Clone this repository:
git clone <repository-url>
cd skeletal_diagram- Install dependencies:
pip install -r requirements.txt- Install the package:
pip install -e .skeletal-gen analyze input.midThis will create diagrams in the ./diagrams/ directory by default.
# Specify custom output directory and segmentation mode
skeletal-gen analyze input.mid --output ./my_analysis --unit phrase
# Manual key specification
skeletal-gen analyze input.mid --key "C major"
# Generate overview grid
skeletal-gen analyze input.mid --overview
# Verbose output for debugging
skeletal-gen analyze input.mid --verboseBy default, generated diagrams are saved to ./diagrams/ to keep your workspace organized. You can specify a different directory using the --output option.
skeletal-gen info input.midThe analysis is based on Minao Shibata's skeletal figure theory, which identifies structurally important notes (core notes) typically in fourth-interval relationships, with other notes classified as ornamental based on their interval distance from core notes.
- Semitone intervals: Positioned inside core note circles
- Whole tone intervals: Positioned on circle boundaries
- Larger intervals: Positioned outside circles
- Measure: Fixed 1-2 measure segments
- Phrase: Natural phrase boundaries detected by rests
- Section: Larger 8-measure structural units
- Auto: Intelligent selection based on melody length
The tool generates:
- Individual skeletal diagrams for each analysis unit (PNG format)
- Optional overview grid showing all units together
- Analysis summary with confidence scores and statistics
Generated diagrams show:
- Core notes as labeled circles connected by lines
- Ornamental notes positioned by interval distance
- Analysis metadata (confidence scores, unit information)
- Clear solfege notation labels
- Python 3.8+
- music21 (MIDI processing)
- matplotlib (diagram generation)
- numpy (numerical computations)
- click (CLI framework)
src/skeletal_gen/
├── cli.py # Command-line interface
├── input/ # MIDI processing modules
├── analysis/ # Core detection & classification
├── visualization/ # Diagram generation
└── models/ # Data classes
Test with the provided sample MIDI files:
python create_test_midi.py # Generate test files
skeletal-gen analyze tests/fixtures/test_melody.mid --overviewMIT License