rodio/examples/reverb.rs
2024-11-20 00:58:05 +04:00

18 lines
546 B
Rust

use rodio::Source;
use std::error::Error;
use std::io::BufReader;
use std::time::Duration;
fn main() -> Result<(), Box<dyn Error>> {
let stream_handle = rodio::OutputStreamBuilder::try_default_stream()?;
let sink = rodio::Sink::connect_new(&stream_handle.mixer());
let file = std::fs::File::open("assets/music.ogg")?;
let source = rodio::Decoder::new(BufReader::new(file))?;
let with_reverb = source.buffered().reverb(Duration::from_millis(40), 0.7);
sink.append(with_reverb);
sink.sleep_until_end();
Ok(())
}