Function sampara::signal::from_samples [−][src]
pub fn from_samples<F, I, const N: usize>(
iter: I
) -> FromSamples<F, I::IntoIter, N> where
F: Frame<N, Sample = I::Item>,
I: IntoIterator,
I::Item: Sample,
Creates a new Signal
by wrapping an iterable that yields [Samples
]s.
These Sample
s are assumed to be interleaved, and in channel order.
The resulting Signal
will read these Sample
s into Frame
s of the
desired size, and yield them. Any trailing Sample
s that do not fully
complete a Frame
will be discarded.
use sampara::{signal, Signal}; fn main() { let samples = vec![1, 2, 3, 4, 5, 6, 7]; let mut signal = signal::from_samples(samples); assert_eq!(signal.next(), Some([1, 2])); assert_eq!(signal.next(), Some([3, 4])); assert_eq!(signal.next(), Some([5, 6])); // Not enough remaining samples for a full frame, so they are discarded. assert_eq!(signal.next(), None); }