Skip to content

Commit

Permalink
Add resample example
Browse files Browse the repository at this point in the history
  • Loading branch information
wiccy46 committed Aug 15, 2023
1 parent eda5934 commit a334269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Binary file added assets/voice24khz.mp3
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/resample.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::fs::File;
use std::io::BufReader;

fn main() {
let new_sr = 44100;
let channels = 2;
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
let sink = rodio::Sink::try_new(&handle).unwrap();

let file = File::open("assets/voice24khz.mp3").unwrap();
let source = rodio::Decoder::new(BufReader::new(file)).unwrap();
let resample: rodio::source::UniformSourceIterator<rodio::Decoder<BufReader<File>>, i16> =
rodio::source::UniformSourceIterator::new(source, channels, new_sr);

sink.append(resample);
sink.sleep_until_end();
}

0 comments on commit a334269

Please sign in to comment.