fn decode_mp3<T>(path: T) -> (i32, Vec<i16>)
where
    T: AsRef<Path>,
{
    let mut decoder = Decoder::new(File::open(path).unwrap());

    let mut frames = Vec::new();

    let stream_sample_rate = if let Ok(frame) = decoder.next_frame() {
        frames.append(&mut frame.data.clone());
        frame.sample_rate
    } else {
        0
    };

    while let Ok(frame) = decoder.next_frame() {
        frames.append(&mut frame.data.clone());
    }
    (stream_sample_rate, frames)
}
//Known issue: the last frame seems to be dropped from the end of the file
Known issue: the last frame seems to be dropped from the end of the file
Known issue : the last frame seems to be dropped from the end of the file
fn decode_mp3<T>(path: T) -> (i32, Vec<i16>)
where
    T: AsRef<Path>,
{
    let mut decoder = Decoder::new(File::open(path).unwrap());
    let mut frames = Vec::new();
    let stream_sample_rate = if let Ok(frame) = decoder.next_frame() {
        frames.append(&mut frame.data.clone());
        frame.sample_rate
    } else {
        0
    };
    while let Ok(frame) = decoder.next_frame() {
        frames.append(&mut frame.data.clone());
    }
    (stream_sample_rate, frames)
}
fn decode_mp3 < T > ( path : T ) -> ( i32 , Vec < i16 > ) where T : AsRef < Path > , { let mut decoder = Decoder :: new ( File :: open ( path ) . unwrap ( ) ) ; let mut frames = Vec :: new ( ) ; let stream_sample_rate = if let Ok ( frame ) = decoder . next_frame ( ) { frames . append ( & mut frame . data . clone ( ) ) ; frame . sample_rate } else { 0 } ; while let Ok ( frame ) = decoder . next_frame ( ) { frames . append ( & mut frame . data . clone ( ) ) ; } ( stream_sample_rate , frames ) }
Known issue: the last frame seems to be dropped from the end of the file
Known issue : the last frame seems to be dropped from the end of the file
path
T
path
T