# bevy_rustysynth


A plugin which adds MIDI file and soundfont audio support to the bevy engine via rustysynth.
From version 0.4, the crate has undergone significant rewrites, and now works with the default `bevy_audio` backend (`bevy_audio` feature) OR [`bevy_kira_audio`](https://github.com/NiklasEi/bevy_kira_audio) (`kira` feature)
## Compatibility
| 0.6 | 0.16 |
| 0.5 | 0.15 |
| 0.2 | 0.14 |
## Installation
### crates.io
```toml
[dependencies]
bevy_rustysynth = "0.6"
```
## Usage
In `main.rs`:
```rs
use bevy::prelude::*;
use bevy_rustysynth::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
RustySynthPlugin {
soundfont: // Bring your own soundfont or enable the "hl4mgm" feature to use a terrible 4MB default
}
))
.run();
}
```
Then you can load and play a MIDI like any other audio file:
### `bevy_audio` Example
```rs
let midi_handle = asset_server.load::<MidiAudio>("example.mid");
commands.spawn(AudioPlayer(midi_handle));
```
### `bevy_kira_audio` Example
```rs
let midi_handle = asset_server.load::<AudioSource>("example.mid");
audio.play(midi_handle);
```
## License
This crate is licensed under your choice of 0BSD, Apache-2.0, or MIT license.