diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/embedded_assets/hl4mgm.sf2 | bin | 0 -> 4191990 bytes | |||
-rw-r--r-- | src/lib.rs | 16 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/embedded_assets/hl4mgm.sf2 b/src/embedded_assets/hl4mgm.sf2 Binary files differnew file mode 100644 index 0000000..2e88994 --- /dev/null +++ b/src/embedded_assets/hl4mgm.sf2 @@ -5,22 +5,32 @@ use bevy::{audio::AddAudioSource, prelude::*}; use rustysynth::SoundFont; use std::{ - io::Read, + io::{Cursor, Read}, sync::{Arc, OnceLock}, }; mod assets; pub use assets::*; +#[cfg(feature = "hl4mgm")] +pub (crate) static HL4MGM: &[u8] = include_bytes!("./embedded_assets/hl4mgm.sf2"); + pub(crate) static SOUNDFONT: OnceLock<Arc<SoundFont>> = OnceLock::new(); /// This plugin configures the soundfont used for playback and registers MIDI assets. -#[derive(Default, Debug)] +#[derive(Debug)] pub struct RustySynthPlugin<R: Read + Send + Sync + Clone + 'static> { - /// Reader for soundfont data. A default is not provided since soundfonts can be quite large. + /// Reader for soundfont data. pub soundfont: R, } +#[cfg(feature = "hl4mgm")] +impl Default for RustySynthPlugin<Cursor<&[u8]>> { + fn default() -> Self { + Self { soundfont: Cursor::new(HL4MGM) } + } +} + impl<R: Read + Send + Sync + Clone + 'static> Plugin for RustySynthPlugin<R> { fn build(&self, app: &mut App) { let _ = SOUNDFONT.set(Arc::new( |