Function dsp::slice::from_boxed_sample_slice [] [src]

pub fn from_boxed_sample_slice<T, S>(slice: Box<[S]>) -> Option<T> where S: Sample, T: FromBoxedSampleSlice<S>

Converts the given boxed slice of Samples into some slice T.

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

This is a convenience function that wraps the FromBoxedSampleSlice trait.

Examples

extern crate sample;

fn main() {
    let foo = vec![0.0, 0.5, 0.0, -0.5].into_boxed_slice();
    let bar: Box<[[f32; 2]]> = sample::slice::from_boxed_sample_slice(foo).unwrap();
    assert_eq!(bar.into_vec(), vec![[0.0, 0.5], [0.0, -0.5]]);
}