use std; extern crate hound; type FileReader = std::io::BufReader; pub fn float_sample_iterator<'a>(reader: &'a mut hound::WavReader) -> Box + 'a> { match reader.spec().sample_format { hound::SampleFormat::Float => Box::new(reader.samples::().map(|x| x.unwrap())), hound::SampleFormat::Int => match reader.spec().bits_per_sample { 8 => Box::new(reader.samples::().map(|x| (x.unwrap() as f32) / (i16::max_value() as f32))), 16 => Box::new(reader.samples::().map(|x| (x.unwrap() as f32) / (i16::max_value() as f32))), 32 => Box::new(reader.samples::().map(|x| (x.unwrap() as f32) / (i32::max_value() as f32))), _ => panic!("Unsupported sample rate") } } }