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

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

Modules§

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