Crate magma_audio
source ·Expand description
This crate is an integration of the kira
crate for the Magma3D engine.
Usage example:
use magma_audio::kira::{
manager::AudioManager,
sound::static_sound::{StaticSoundData, StaticSoundSettings},
};
use magma_app::App;
use magma_audio::{sounds::Sounds, AudioModule};
// create app
let mut app = App::new();
app.add_module(AudioModule);
// get sounds resource
let sounds = app.world.get_resource_mut::<Sounds>().unwrap();
// load an audio file into the sounds resource
sounds
.push(StaticSoundData::from_file("sound.ogg", StaticSoundSettings::default()).unwrap());
// get the sound from the sounds resource
let sound = app.world.get_resource::<Sounds>().unwrap()[0].clone();
// play the sound on the AudioManager resource
app.world
.get_resource_mut::<AudioManager>()
.unwrap()
.play(sound)
.unwrap();
Re-exports
pub use kira;
Modules
- Sounds resource
Structs
- Can be added to an
App
for audio support