Crate fyrox_sound

Crate fyrox_sound 

Source
Expand description

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 fyrox-sound:

use std::{
    thread,
    time::Duration
};
use fyrox_sound::{
    source::{
        SoundSourceBuilder,
        SoundSource,
        Status
    },
    context::SoundContext,
    buffer::{
        DataSource,
        SoundBufferResource
    },
};
use fyrox_sound::buffer::SoundBufferResourceExtension;
use fyrox_resource::io::FsResourceIo;

 let context = SoundContext::new();

 let sound_buffer = SoundBufferResource::new_generic(fyrox_sound::futures::executor::block_on(DataSource::from_file("sound.wav", &FsResourceIo)).unwrap()).unwrap();

 let source = SoundSourceBuilder::new()
    .with_buffer(sound_buffer)
    .with_status(Status::Playing)
    .build()
    .unwrap();

 context.state()
    .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

  • Windows (DirectSound)
  • Linux (alsa)
  • macOS (CoreAudio)
  • WebAssembly (WebAudio)
  • Android (AAudio, API Level 26+)

§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 fyrox_core::algebra;
pub use fyrox_core::futures;
pub use hrtf;

Modules§

buffer
This module provides all needed types and methods to create/load sound buffers from different sources.
bus
Everything related to audio buses and audio bus graphs. See docs of AudioBus and AudioBusGraph for more info and examples
context
Context module.
dsp
Digital signal processing module. Provides basic elements to process signal sample-by-sample.
effects
Contins everything related to audio effects that can be applied to an audio bus.
engine
Sound engine module
error
Contains all possible errors that can occur in the engine.
listener
Listener module.
math
pool
A generational arena - a contiguous growable array type which allows removing from the middle without shifting and therefore without invalidating other indices.
renderer
Renderer module.
source
Generic sound source.