Crates.io | ears |
lib.rs | ears |
version | 0.8.0 |
source | src |
created_at | 2016-01-22 12:12:27.359756 |
updated_at | 2020-02-12 13:46:01.257423 |
description | Easy Rust API to play audio using OpenAL |
homepage | |
repository | https://github.com/nickbrowne/ears |
max_upload_size | |
id | 3953 |
size | 228,248 |
Ears aims to be a convenient and easy to understand Rust interface over OpenAL.
It's designed first and foremost for game development, giving you easy access to complex functionality like HRTF, spatialization, and environmental effects with almost no configuration required.
Supports a wide variety of audio formats, including:
For a full list please see the documentation for libsndfile here: http://www.mega-nerd.com/libsndfile/
You need to install OpenAL and libsndfile on your system.
sudo apt install libopenal-dev libsndfile1-dev
sudo dnf install openal-soft-devel libsndfile-devel
brew install openal-soft libsndfile
Install MSYS2 according to the instructions. Be sure to
use the default installation folder (i.e. C:\msys32
or C:\msys64
), otherwise
compiling won't work. Then, run the following in the MSYS2 shell:
pacman -S mingw-w64-x86_64-libsndfile mingw-w64-x86_64-openal
Include ears
in your Cargo.toml
dependencies.
[dependencies]
ears = "0.8.0"
Playing a sound effect while simultaneously streaming music off disk is as simple as it gets.
extern crate ears;
use ears::{Music, Sound, AudioController};
fn main() {
let mut music = Music::new("your-music.ogg").unwrap();
music.play();
let mut sound = Sound::new("your-sound-effect.wav").unwrap();
sound.play();
while music.is_playing() || sound.is_playing() {};
}
cargo run --example basic
cargo run --example advanced
cargo run --example music
cargo run --example record
cargo run --example simple_player
cargo run --example threads
cargo run --example direct_channel