Crate ears [] [src]

ears

ears is a simple library for play Sounds and Musics in Rust.

ears is build on the top of OpenAL and libsndfile.

  • Provide anaccess to the OpenAL spatialization functionality in a simple way.
  • Accept a lot of audio formats thanks to libsndfile.

Example

extern crate ears;
use ears::{Sound, AudioController};

fn main() {
    // Create a new Sound.
    let mut 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() {}
}

Functionnality

ears provide two way for play audio files.

  • The Sound class, which represent 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.

Use ears

As said before, ears require OpenAL and libsndfile, you need to install these two libraries on your system. Then import stuff from ears in your project, you can import all the stuff:

extern crate ears;

use ears::*;

or a specific one:

extern crate ears;

use ears::Music;

Modules

listener

Module for manage the listener in the scene.

Structs

Music

Play Music easily.

RecordContext

The context needed to initialize a new Recorder

Recorder

Record audio

Sound

Play Sounds easily.

SoundData

Samples extracted from a file.

Tags

Structure containing the tags of a sound.

Enums

State

The differents states in which a sound can be.

Traits

AudioController

The functionnality that an Audio Source should provide.

AudioTags

AudioTags trait implemented by all struct who can provides audio.

Functions

init

Initialize the internal context

init_in

Initialize the input device context