From e6c43e35d373c5e1676b1ed7b30ead8086fddfc9 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 9 Nov 2022 19:46:42 +0100 Subject: [PATCH] Fix copying tail to playback buffer I noticed the effect wasn't deterministic, when I saw this. Oops. --- plugins/buffr_glitch/src/buffer.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/buffr_glitch/src/buffer.rs b/plugins/buffr_glitch/src/buffer.rs index ce852968..80b62f37 100644 --- a/plugins/buffr_glitch/src/buffer.rs +++ b/plugins/buffr_glitch/src/buffer.rs @@ -118,8 +118,9 @@ impl RingBuffer { let copy_num_from_end = note_period_samples - copy_num_from_start; playback_buffer[0..copy_num_from_end] .copy_from_slice(&recording_buffer[recording_buffer.len() - copy_num_from_end..]); - playback_buffer[copy_num_from_end..] - .copy_from_slice(&recording_buffer[..copy_num_from_start]); + playback_buffer[copy_num_from_end..].copy_from_slice( + &recording_buffer[self.next_write_pos - copy_num_from_start..self.next_write_pos], + ); } // The playback buffer is normalized as necessary. This prevents small grains from being