| Crates.io | yks_converter |
| lib.rs | yks_converter |
| version | 0.1.0 |
| created_at | 2025-08-09 17:39:53.905913+00 |
| updated_at | 2025-08-09 17:39:53.905913+00 |
| description | A Rust library for converting MML (Music Macro Language) to MIDI format |
| homepage | https://github.com/rajephon/YKSConverter |
| repository | https://github.com/rajephon/YKSConverter |
| max_upload_size | |
| id | 1788105 |
| size | 58,410 |
Modern Rust port of the MML to MIDI converter with 100% binary compatibility with the C++ version.
cargo build --release
Clone and run directly:
git clone https://github.com/rajephon/YKSConverter.git
cd YKSConverter/rust
cargo run --bin yks_converter -- "MML@t120l4cdefg,,;"
This generates output.midi in the current directory.
More examples:
# Simple melody
cargo run --bin yks_converter -- "MML@t120l4cdefg,,;"
# Complex multi-track piece
cargo run --bin yks_converter -- "MML@t190l8cdefgab>c4.,l8<cdefgab>c4.,l8>cdefgab>c4.;"
use yks_converter::YksConverter;
fn main() {
let mml = "MML@t190l8cdefgab>c4.,l8<cdefgab>c4.,l8>cdefgab>c4.;";
let converter = YksConverter::new(mml.to_string(), 1);
if let Some(buffer) = converter.to_buffer() {
std::fs::write("output.midi", buffer.as_slice()).unwrap();
}
}
use yks_converter::YksConverter;
fn main() {
let mml_tracks = vec![
"MML@t180l8ccccccc4,l8eeeeeee4,l8ggggggg4;".to_string(),
"MML@t180l8>ccccccc4,l8>eeeeeee4,l8>ggggggg4;".to_string(),
];
let instruments = vec![26, 74]; // MIDI instrument codes
let converter = YksConverter::new_multi(mml_tracks, instruments);
if let Some(buffer) = converter.to_buffer() {
std::fs::write("ensemble.midi", buffer.as_slice()).unwrap();
}
}
Add to your Cargo.toml:
[dependencies]
yks_converter = "0.1.0"
Or use cargo:
cargo add yks_converter
Run the comprehensive test suite:
cargo test # All tests
cargo test -- --nocapture # With debug output
cargo test binary_compatibility # Binary compatibility test
regex - MML pattern matchingbyteorder - MIDI binary format handlingThis Rust implementation mirrors the C++ architecture:
The Rust version produces identical MIDI output to the C++ version:
cargo bench # Run benchmarks
cargo build --release # Optimized build