Note: This library is now being maintained at https://github.com/jhasse/ears
ears is a simple library to play Sounds and Musics in Rust.
ears is build on the top of OpenAL and libsndfile.
- Provides an access to the OpenAL spatialization functionality in a simple way.
- Accepts a lot of audio formats, thanks to libsndfile.
extern crate ears;
use ears::Sound;
fn main() {
// Create a new Sound.
let snd = Sound::new("path/to/my/sound.ogg").unwrap();
// Play the Sound
snd.play();
// Wait until the end of the sound
while snd.is_playing() {}
}
ears provides two ways to play audio files.
- The Sound class, which represents light sounds who can share a buffer of samples with another Sound.
- The Music class, which is a bigger sound and who can't share sample buffer.
Like previously said, ears requires OpenAL and libsndfile. You need to install these two libraries on your system.
ears compiles against the last Rust compiler, so if it doesn't work on your computer you may need to update your compiler.
ears is built using make, so just type make
at the root of the ears repository, this command
builds ears, examples and the documentation.
You can build them separately too with the dedicated commands:
> make ears
> make examples
> make doc
then import stuff from ears in your project, you can import all the stuff:
#[feature(globs)];
extern crate ears;
use ears::*;
or a specific one:
extern crate ears;
use ears::Music;