Giter Site home page Giter Site logo

ears's Introduction

ears Build Status Build status

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.

View documentation

Supports a wide variety of audio formats, including:

  • Ogg Vorbis
  • Microsoft WAV
  • RAW PCM
  • Lossless FLAC
  • AIFF

For a full list please see the documentation for libsndfile here: http://www.mega-nerd.com/libsndfile/

Before you start

You need to install OpenAL and libsndfile on your system.

Linux (Debian and Ubuntu):

sudo apt install libopenal-dev libsndfile1-dev

Linux (Fedora):

sudo dnf install openal-soft-devel libsndfile-devel

Mac:

brew install openal-soft libsndfile

Windows:

The easiest way to get up and running is using the GNU toolchain. So first check which toolchain is currently active:

rustup show

If the GNU toolchain is not active, you can either set it as the system wide default:

rustup default stable-gnu

Or set it per directory:

rustup override set stable-gnu

Then install MSYS2 according to the instructions. Be sure to use the default installation folder (i.e. C:\msys32 or C:\msys64), as currently ears is hard coded to link against libraries in that location.

Then, run the following in the MSYS2 shell:

pacman -S mingw-w64-x86_64-libsndfile mingw-w64-x86_64-openal

Usage

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() {};
}

Running examples

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

ears's People

Contributors

jeremyletang avatar nickbrowne avatar jhasse avatar linkmauve avatar rjdgtn avatar emberian avatar isomorpheme avatar cmpons avatar suhr avatar ysimonson avatar branarm avatar aochagavia avatar guillaumegomez avatar steveklabnik avatar acolley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.