[][src]Crate rg3d_sound

Sound library for games and interactive applications.

Features

  • Generic and spatial sounds.
  • WAV and OGG/Vorbis formats support.
  • Streaming.
  • Head-related transfer function support (HRTF).
  • Reverb effect.

Examples

Here is an example of how to play a sound using rg3d-sound:

use std::{
    thread,
    time::Duration
};
use rg3d_sound::{
    source::{
        generic::GenericSourceBuilder,
        SoundSource,
        Status
    },
    context::Context,
    buffer::{
        DataSource,
        SoundBuffer
    },
};

 let context = Context::new().unwrap();

 let sound_buffer = SoundBuffer::new_generic(DataSource::from_file("sound.wav").unwrap()).unwrap();

 let source = GenericSourceBuilder::new(sound_buffer)
    .with_status(Status::Playing)
    .build_source()
    .unwrap();

 context.lock()
    .unwrap()
    .add_source(source);

 thread::sleep(Duration::from_secs(3));

Other examples can be found in ./examples folder. Make sure you run them with --release flag.

Supported OS

Currently only Windows and Linux are supported.

HRTF

Library uses special HRIR Spheres which were composed from IRCAM HRIR database. Since HRTF is very specific to each person, you should try some of them to find best for you. They can be found here.

Re-exports

pub use hrtf;

Modules

buffer

This module provides all needed types and methods to create/load sound buffers from different sources.

context

Context module.

dsp

Digital signal processing module. Provides basic elements to process signal sample-by-sample.

effects

Effects module

error

Contains all possible errors that can occur in the engine.

listener

Listener module.

math
pool

Pool is contiguous block of memory with fixed-size entries, each entry can be either vacant or occupied. When you put an object into pool you get handle to that object. You can use that handle later on to borrow a reference to an object. Handle can point to some object or be invalid, this may look similar to raw pointers, but there is two major differences:

renderer

Renderer module.

source

Sound source module.