timbre/lib.rs
1//! An audio library designed for composing real-time effects.
2//!
3//! Timbre is designed to establish a common interface and a decent-sized
4//! library of effects and decoders for playing audio in real time. It is aimed
5//! at eventually providing most of the audio functionality needed for game
6//! programming, but should be flexible enough for other applications as well.
7//!
8//! # Example
9//!
10//! ```
11//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
12//! # std::env::set_var("SDL_AUDIODRIVER", "dummy");
13//! use std::time::Duration;
14//! use timbre::prelude::*;
15//!
16//! // SDL setup.
17//! let sdl = sdl2::init()?;
18//! let audio = sdl.audio()?;
19//!
20//! // Inputs
21//! let mut microphone = timbre::drivers::Sdl2Input::new(&audio)?;
22//! microphone.resume();
23//! let music = timbre::decoders::WavDecoder::from_file("./assets/music-stereo-f32.wav")?;
24//!
25//! // Apply effects
26//! let microphone = timbre::effects::Echo::new(microphone.source(),
27//! Duration::from_secs_f32(0.5), 0.6);
28//! let music = timbre::effects::LowPass::new(music.into_shared(), 200.0);
29//!
30//! // Mix them together
31//! let mut mixer = timbre::effects::BasicMixer::new();
32//! mixer.add_source(microphone.into_shared());
33//! mixer.add_source(music.into_shared());
34//!
35//! // Output
36//! let mut speaker = timbre::drivers::Sdl2Output::new(&audio)?;
37//! speaker.set_source(mixer.into_shared());
38//! speaker.resume();
39//!
40//! # Ok(())
41//! # }
42
43mod core;
44pub use crate::core::*;
45mod error;
46pub use crate::error::*;
47
48pub mod decoders;
49pub mod drivers;
50pub mod effects;
51pub mod generators;
52
53pub mod prelude;
54
55mod sdl_util;
56
57#[cfg(test)]
58mod tests {
59 #[test]
60 fn it_works() {
61 assert_eq!(2 + 2, 4);
62 }
63}