[][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.

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.

hrtf

Head-Related Transfer Function (HRTF) module. Provides all needed types and methods for HRTF rendering.

listener

Listener module.

math
pool
renderer

Renderer module.

source

Sound source module.