https://github.com/ruin0x11/midplay
Play MIDI files from Rust
https://github.com/ruin0x11/midplay
audio cross-platform midi rust-bindings rust-library
Last synced: 11 months ago
JSON representation
Play MIDI files from Rust
- Host: GitHub
- URL: https://github.com/ruin0x11/midplay
- Owner: Ruin0x11
- License: mit
- Created: 2017-05-11T01:26:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T07:58:20.000Z (about 5 years ago)
- Last Synced: 2025-03-22T13:25:22.797Z (over 1 year ago)
- Topics: audio, cross-platform, midi, rust-bindings, rust-library
- Language: Rust
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# midplay
`midplay` is a library for playing MIDI files from Rust. It can use MCI on Windows or a generic driver ([midir](https://github.com/Boddlnagg/midir)) on Windows, macOS and Linux.
## Usage
```rust
// MCI driver. (Windows only)
use midplay::native;
native::play_midi("data/CANYON.MID")?;
assert_eq!(true, native::is_midi_playing());
native::stop_midi()?;
assert_eq!(false, native::is_midi_playing());
```
``` rust
// Cross-platform driver.
use midplay::generic;
let mut out_ports = generic::get_ports()?;
for port in out_ports.iter() {
println!("Index: {} Name: {}", port.index, port.name);
}
let port = out_ports[0];
generic::play_midi("data/CANYON.MID", &port)?;
assert_eq!(true, generic::is_midi_playing());
generic::stop_midi()?;
assert_eq!(false, generic::is_midi_playing());
```
Run the example for each driver:
```sh
cargo run --example test_native
cargo run --example test_generic
```
## Credits
Most of the code for the generic driver was taken from [rusthesia](https://github.com/gin66/rusthesia).
## License
MIT.