/// Update the delay buffers with a new size value.
Update the delay buffers with a new size value.
Update the delay buffers with a new size value .
fn resize(&mut self, n: f32) {
        let old_size = mem::replace(&mut self.size, n);
        for (i, buffer) in self.buffers.iter_mut().enumerate() {
            // Calculate the size difference between delays
            let old_delay = delay(i, old_size);
            let new_delay = delay(i, n);
            let diff = new_delay - old_delay;
            // Add empty samples if the delay was increased, remove if decreased
            if diff > 0 {
                for _ in 0..diff {
                    buffer.push_back((0.0, 0.0));
                }
            } else if diff < 0 {
                for _ in 0..-diff {
                    let _ = buffer.pop_front();
                }
            }
        }
    }
fn resize ( & mut self , n : f32 ) { let old_size = mem :: replace ( & mut self . size , n ) ; for ( i , buffer ) in self . buffers . iter_mut ( ) . enumerate ( ) { // Calculate the size difference between delays let old_delay = delay ( i , old_size ) ; let new_delay = delay ( i , n ) ; let diff = new_delay - old_delay ; // Add empty samples if the delay was increased, remove if decreased if diff > 0 { for _ in 0 .. diff { buffer . push_back ( ( 0.0 , 0.0 ) ) ; } } else if diff < 0 { for _ in 0 .. - diff { let _ = buffer . pop_front ( ) ; } } } }
Update the delay buffers with a new size value.
Update the delay buffers with a new size value .
&mut self
n
f32