Crates.io | oml-audio |
lib.rs | oml-audio |
version | 0.8.8-alpha |
source | src |
created_at | 2022-01-04 18:17:05.457151 |
updated_at | 2024-03-16 18:38:02.834804 |
description | Very basic, and thin abstraction of audio handling meant for games. |
homepage | https://github.com/AndreasOM/oml-audio |
repository | https://github.com/AndreasOM/oml-audio |
max_upload_size | |
id | 507941 |
size | 4,352,923 |
Work in progress! API will change, but we'll obey semver rules. To be precise:
Pre 1.0.0
Post 1.0.0
0.y.z will potentially change a lot!
Very thin wrapper for playing music, and audio in rust based games.
Features:
Play .mp3 music (with hardware acceleration) on macOS
Play .wav & .caf sound on macOS
Play .ogg music on windows
Play .wav sound on windows
Play .ogg music on linux
Play .wav sound on linux
Future:
Newer versions allow compiling in multiple backends and selecting them at runtime.
This has the downside of a breaking API change :(
Audio::new
, or rather Audio::create_default
or Audio::create
now return a Box<dyn AudioBackend>
which might mean you have to change your storage.
AudioBackend is also now generic over FileLoader
.
use oml_audio::Audio;
use oml_audio::fileloader::FileLoaderDisk;
pub fn main() {
let mut fileloader = FileLoaderDisk::new( "./data" ); // 'data' is the base directory for all other files/paths
fileloader.enable_debug();
// OLD: let mut audio = Audio::new();
let mut audio: Box<dyn AudioBackend<FileLoaderDisk>> = Audio::create_default(); // explicit type for verbosity only
audio.load_sound_bank( &mut fileloader, "test.omsb" );
audio.play_sound( "SOUND_ID" );
loop {
let _timestep = audio.update();
// update
// render
// (maybe) yield/sleep
}
}