Expand description
An audio library designed for composing real-time effects.
Timbre is designed to establish a common interface and a decent-sized library of effects and decoders for playing audio in real time. It is aimed at eventually providing most of the audio functionality needed for game programming, but should be flexible enough for other applications as well.
§Example
use std::time::Duration;
use timbre::prelude::*;
// SDL setup.
let sdl = sdl2::init()?;
let audio = sdl.audio()?;
// Inputs
let mut microphone = timbre::drivers::Sdl2Input::new(&audio)?;
microphone.resume();
let music = timbre::decoders::WavDecoder::from_file("./assets/music-stereo-f32.wav")?;
// Apply effects
let microphone = timbre::effects::Echo::new(microphone.source(),
Duration::from_secs_f32(0.5), 0.6);
let music = timbre::effects::LowPass::new(music.into_shared(), 200.0);
// Mix them together
let mut mixer = timbre::effects::BasicMixer::new();
mixer.add_source(microphone.into_shared());
mixer.add_source(music.into_shared());
// Output
let mut speaker = timbre::drivers::Sdl2Output::new(&audio)?;
speaker.set_source(mixer.into_shared());
speaker.resume();
Modules§
- decoders
AudioSourceimplementations that read common audio codecs.- drivers
- Sources and sinks that connect to hardware.
- effects
- Effects that transform or combine
AudioSources. - generators
AudioSourceimplementations that generate their own sounds.- prelude
- Exports commonly-used traits.
Structs§
- Audio
Buffer - Bundles an
AudioFormatwith a buffer containing audio data in that format. - Audio
Format - Used to know how to interpret audio data.
- Read
Result - Indicates the amount of data read and the status of an
AudioSource.
Enums§
- Error
- Unified error type.
- Stream
State - Indicates the state of an
AudioSource.
Traits§
- Audio
Source - Trait implemented to provide audio data to consumers.
- Into
Shared - Helpful extension to move
AudioSourceimplementations into anArc<Mutex<...>>.