diff --git a/assets/voice24khz.mp3 b/assets/voice24khz.mp3 new file mode 100644 index 00000000..13107ec4 Binary files /dev/null and b/assets/voice24khz.mp3 differ diff --git a/examples/resample.rs b/examples/resample.rs new file mode 100644 index 00000000..44baea6b --- /dev/null +++ b/examples/resample.rs @@ -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>, i16> = + rodio::source::UniformSourceIterator::new(source, channels, new_sr); + + sink.append(resample); + sink.sleep_until_end(); +}