Add nicer adapter for repeating channel iteration
This commit is contained in:
parent
fb382520af
commit
2c394aabd5
|
@ -198,11 +198,7 @@ impl Plugin for Diopser {
|
|||
for filter_idx in 0..self.params.filter_stages.value as usize {
|
||||
// Because of this filter_idx outer loop we can't directly iterate over
|
||||
// `channel_samples` as the iterator would be empty after the first loop
|
||||
for (channel_idx, filters) in
|
||||
(0..channel_samples.len()).zip(self.filters.iter_mut())
|
||||
{
|
||||
// SAFETY: The bounds have already been checked here
|
||||
let sample = unsafe { channel_samples.get_unchecked_mut(channel_idx) };
|
||||
for (sample, filters) in channel_samples.reset_iter().zip(self.filters.iter_mut()) {
|
||||
*sample = filters[filter_idx].process(*sample);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,12 @@ impl<'outer, 'inner> Iterator for Channels<'outer, 'inner> {
|
|||
impl<'outer, 'inner> ExactSizeIterator for Channels<'outer, 'inner> {}
|
||||
|
||||
impl<'outer, 'inner> Channels<'outer, 'inner> {
|
||||
/// A resetting iterator. This lets you iterate over the same channels multiple times.
|
||||
pub fn reset_iter(&mut self) -> &mut Self {
|
||||
self.current_channel = 0;
|
||||
self
|
||||
}
|
||||
|
||||
/// Access a sample by index. Useful when you would otehrwise iterate over this 'Channels'
|
||||
/// iterator multiple times.
|
||||
#[inline]
|
||||
|
|
Loading…
Reference in a new issue