use audio_core::{Channel, ChannelMut};
pub mod linear;
pub use self::linear::{LinearChannel, LinearChannelMut};
pub mod interleaved;
pub use self::interleaved::{InterleavedChannel, InterleavedChannelMut};
pub fn copy<I, O>(from: I, mut to: O)
where
I: Channel,
O: ChannelMut<Sample = I::Sample>,
I::Sample: Copy,
{
match (from.try_as_linear(), to.try_as_linear_mut()) {
(Some(from), Some(to)) => {
let len = usize::min(to.len(), from.len());
to[..len].copy_from_slice(&from[..len]);
}
_ => {
for (t, f) in to.iter_mut().zip(from.iter()) {
*t = f;
}
}
}
}
pub fn copy_iter<I, O>(from: I, mut to: O)
where
I: IntoIterator,
O: ChannelMut<Sample = I::Item>,
I::Item: Copy,
{
for (t, f) in to.iter_mut().zip(from) {
*t = f;
}
}