Audio Overlay
Overlay audio samples from one array onto another. You can optionally expand the destination array.
The overlay function can be used for i8, i16, i32, i64, and f32.
Example
See: mix.rs
use rodio::{OutputStream, Sink};
use rodio::buffer::SamplesBuffer;
use hound;
use audio_overlay::overlay;
fn main()
{
let framerate: u32 = 44100;
let src: Vec<i16> = hound::WavReader::open("src.wav").unwrap().samples::<i16>().map(|s| s.unwrap()).collect::<Vec<i16>>();
let mut dst: Vec<i16> = hound::WavReader::open("dst.wav").unwrap().samples::<i16>().map(|s| s.unwrap()).collect::<Vec<i16>>();
overlay(src.as_slice(), &mut dst, 1.0, framerate, true);
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let source = SamplesBuffer::new(1, framerate, dst);
let sink = Sink::try_new(&stream_handle).unwrap();
sink.append(source);
sink.sleep_until_end();
}