docs.rs failed to build mkmidilibrary-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
mkmidilibrary
A comprehensive Rust library for music notation, MIDI file I/O, and real-time MIDI communication.
Overview
mkmidilibrary is a Rust translation and unification of three popular music libraries:
- music21 (Python) → Music notation and analysis
- midifile (C++) → MIDI file reading/writing
- rtmidi (C++) → Real-time MIDI I/O
Features
- Core Music Primitives: Pitch, Duration, Note, Rest, Chord, Interval
- Stream Hierarchy: Score, Part, Measure, Voice containers
- MIDI File I/O: Read and write Standard MIDI Files (SMF)
- Real-time MIDI: Cross-platform MIDI input/output (macOS, Linux, Windows)
- Music Notation: Clefs, key signatures, time signatures, dynamics, articulations
- Score Rendering: Graphical rendering via mkgraphic (optional)
- Music Analysis: Chord identification, roman numeral analysis
Installation
Add to your Cargo.toml:
[]
= "0.1"
Feature Flags
realtime- Real-time MIDI I/O (enabled by default)graphics- Score rendering with mkgraphic (enabled by default)
To disable optional features:
[]
= { = "0.1", = false }
Quick Start
Creating Notes and Chords
use *;
// Create a pitch (Middle C)
let pitch = new;
// Create notes with different durations
let quarter_note = quarter;
let half_note = half;
let dotted_quarter = dotted_quarter;
// Create a C major chord
let c_major = major_triad;
Building a Score
use *;
// Create a new score
let mut score = new;
score.set_title;
// Create a part
let mut part = with_name;
// Create a measure with time signature
let mut measure = new;
measure.set_time_signature;
// Add notes
measure.append;
measure.append;
measure.append;
measure.append;
part.add_measure;
score.add_part;
MIDI File I/O
use ;
// Read a MIDI file
let midi = read?;
println!;
println!;
// Create a new MIDI file
let mut midi = new;
midi.set_ticks_per_quarter;
let track = midi.add_track;
track.add_note; // C4 quarter note
track.add_note; // E4 quarter note
midi.write?;
Real-time MIDI
use ;
// List available ports
let input = new?;
for port in input.ports
let mut output = new?;
for port in output.ports
// Open a port and send a note
output.open_port?;
output.send_message?; // Note On
output.send_message?; // Note Off
Score Rendering
use ;
// Create a renderer
let renderer = new;
// Render to PNG
let config = default;
if let Some = render_score_to_image
Module Structure
mkmidilibrary/
├── core/ # Music primitives (Pitch, Duration, Note, etc.)
├── stream/ # Container hierarchy (Score, Part, Measure, Voice)
├── midi/ # MIDI file I/O and translation
├── realtime/ # Real-time MIDI I/O (platform-specific)
├── notation/ # Musical notation elements
├── render/ # Graphical rendering (requires "graphics" feature)
└── analysis/ # Music analysis tools
Platform Support
| Platform | Real-time MIDI Backend |
|---|---|
| macOS | CoreMIDI |
| Linux | ALSA |
| Windows | Windows MM |
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.