Function dsp::slice::to_frame_slice [] [src]

pub fn to_frame_slice<'a, T, F>(slice: T) -> Option<&'a [F]> where F: Frame, T: ToFrameSlice<'a, F>

Converts the given slice into a slice of Frames.

Returns None if the number of channels in a single frame F is not a multiple of the number of samples in the given slice.

This is a convenience function that wraps the ToFrameSlice trait.

Examples

extern crate sample;

fn main() {
    let foo = &[0.0, 0.5, 0.0, -0.5][..];
    let bar = sample::slice::to_frame_slice(foo);
    assert_eq!(bar, Some(&[[0.0, 0.5], [0.0, -0.5]][..]));

    let foo = &[0.0, 0.5, 0.0][..];
    let bar = sample::slice::to_frame_slice(foo);
    assert_eq!(bar, None::<&[[f32; 2]]>);
}