aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-09-09 19:10:03 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-09-09 19:10:03 -0400
commit644732b04d873a96dfe9e778febdd5fd5f56ebc2 (patch)
tree68b566abe4e6616df6b97333879b54bd4356ff53 /src/lib.rs
parent1e80d0684ddbcd3d995a05e572fafb181263758c (diff)
Add default soundfontv0.1.0
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2906d61..a15f3b8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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(