#midi-file #bevy #sound-font #default #kira #rustysynth

bevy_rustysynth

A plugin which adds MIDI file and soundfont audio support to the bevy engine via rustysynth

7 unstable releases (3 breaking)

new 0.4.0 Mar 9, 2025
0.3.0 Dec 9, 2024
0.2.1 Sep 20, 2024
0.1.2 Sep 10, 2024

#243 in Audio

21 downloads per month

0BSD OR MIT OR Apache-2.0

4MB
272 lines

bevy_rustysynth

Crates License Tag Build

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 (kira feature)

Compatibility

Crate Version Bevy Version
0.3-0.4 0.15
0.1-0.2 0.14

Installation

crates.io

[dependencies]
bevy_rustysynth = "0.4"

Using git URL in Cargo.toml

[dependencies.bevy_rustysynth]
git = "https://git.soaos.dev/bevy_rustysynth.git"

Usage

In main.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

let midi_handle = asset_server.load::<MidiAudioSource>("example.mid");

commands.spawn(AudioSourceBundle {
    source: midi_handle,
    ..Default::default()
});

bevy_kira_audio Example

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.

Dependencies

~27–57MB
~1M SLoC