3 releases
0.1.0-alpha.2 | Dec 18, 2023 |
---|---|
0.1.0-alpha.1 | Dec 16, 2023 |
0.1.0-alpha | Dec 13, 2023 |
#946 in Audio
Used in magma_api
105KB
137 lines
magma_audio
This is the audio crate of the Magma3D engine. It is an integration of the kira crate.
lib.rs
:
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();
Dependencies
~6–34MB
~575K SLoC