YKSConverter Rust Implementation
Modern Rust port of the MML to MIDI converter with 100% binary compatibility with the C++ version.
Building
Usage
Command Line Tool
Clone and run directly:
This generates output.midi in the current directory.
More examples:
# Simple melody
# Complex multi-track piece
Library Usage
Single Track Example
use YksConverter;
Multi-Track Example
use YksConverter;
Adding to Your Project
Add to your Cargo.toml:
[]
= "0.1.0"
Or use cargo:
Testing
Run the comprehensive test suite:
Test Coverage
- ✅ MML regex parsing
- ✅ Single note parsing
- ✅ Multi-note sequences
- ✅ Length tokens (l8, l4, etc.)
- ✅ Octave changes (<, >)
- ✅ Dotted notes (4.)
- ✅ Tempo changes (t190)
- ✅ Multi-track support
- ✅ 100% Binary compatibility with C++
Dependencies
regex- MML pattern matchingbyteorder- MIDI binary format handling
Architecture
This Rust implementation mirrors the C++ architecture:
- YksConverter: Main converter struct
- Mf2tt2mf: MML parsing and MIDI track building
- TrackBuilder: MIDI track construction
- TrackEvent: Trait for MIDI event types
- MetaText, Tempo, SysEx
- ProgramChange, ControlChange
- NoteOn, NoteOff, EndOfTrack
- ByteBuffer: Binary MIDI data handling with big-endian support
Binary Compatibility
The Rust version produces identical MIDI output to the C++ version:
- Same timing calculations (384 ticks per whole note)
- Same velocity values (8 * volume)
- Same MIDI event encoding
- Verified with comprehensive binary comparison tests
Performance