diff --git a/plugins/diopser/src/lib.rs b/plugins/diopser/src/lib.rs index 178a8e9c..0c5dc485 100644 --- a/plugins/diopser/src/lib.rs +++ b/plugins/diopser/src/lib.rs @@ -252,13 +252,16 @@ impl Plugin for Diopser { buffer_config: &BufferConfig, _context: &mut impl ProcessContext, ) -> bool { - // Initialize the filters on the first process call self.sample_rate = buffer_config.sample_rate; - self.should_update_filters.store(true, Ordering::Release); true } + fn reset(&mut self) { + // Initialize and/or reset the filters on the next process call + self.should_update_filters.store(true, Ordering::Release); + } + fn process( &mut self, buffer: &mut Buffer, diff --git a/plugins/examples/gain/src/lib.rs b/plugins/examples/gain/src/lib.rs index 20594e9b..d55518c5 100644 --- a/plugins/examples/gain/src/lib.rs +++ b/plugins/examples/gain/src/lib.rs @@ -115,17 +115,10 @@ impl Plugin for Gain { config.num_input_channels == config.num_output_channels && config.num_input_channels > 0 } - fn initialize( - &mut self, - _bus_config: &BusConfig, - _buffer_config: &BufferConfig, - _context: &mut impl ProcessContext, - ) -> bool { - // This plugin doesn't need any special initialization, but if you need to do anything - // expensive then this would be the place. State is kept around while when the host - // reconfigures the plugin. - true - } + // This plugin doesn't need any special initialization, but if you need to do anything expensive + // then this would be the place. State is kept around while when the host reconfigures the + // plugin. If we did need special initialization, we could implement the `initialize()` and/or + // `reset()` methods fn process( &mut self, diff --git a/plugins/examples/sine/src/lib.rs b/plugins/examples/sine/src/lib.rs index 5f866604..57b4ec5d 100644 --- a/plugins/examples/sine/src/lib.rs +++ b/plugins/examples/sine/src/lib.rs @@ -125,6 +125,12 @@ impl Plugin for Sine { true } + fn reset(&mut self) { + self.phase = 0.0; + self.midi_note_freq = 1.0; + self.midi_note_gain.reset(0.0); + } + fn process(&mut self, buffer: &mut Buffer, context: &mut impl ProcessContext) -> ProcessStatus { let mut next_event = context.next_midi_event(); for (sample_id, channel_samples) in buffer.iter_mut().enumerate() { diff --git a/plugins/examples/stft/src/lib.rs b/plugins/examples/stft/src/lib.rs index fd3ef693..68146912 100644 --- a/plugins/examples/stft/src/lib.rs +++ b/plugins/examples/stft/src/lib.rs @@ -116,14 +116,18 @@ impl Plugin for Stft { _buffer_config: &BufferConfig, context: &mut impl ProcessContext, ) -> bool { - // Normally we'd also initialize the STFT helper for the correct channel count here, but we - // only do stereo so that's not necessary - self.stft.set_block_size(WINDOW_SIZE); context.set_latency_samples(self.stft.latency_samples()); true } + fn reset(&mut self) { + // Normally we'd also initialize the STFT helper for the correct channel count here, but we + // only do stereo so that's not necessary. Setting the block size also zeroes out the + // buffers. + self.stft.set_block_size(WINDOW_SIZE); + } + fn process( &mut self, buffer: &mut Buffer, diff --git a/plugins/puberty_simulator/src/lib.rs b/plugins/puberty_simulator/src/lib.rs index 61d65437..cad3195b 100644 --- a/plugins/puberty_simulator/src/lib.rs +++ b/plugins/puberty_simulator/src/lib.rs @@ -175,6 +175,11 @@ impl Plugin for PubertySimulator { true } + fn reset(&mut self) { + // This zeroes out the buffers + self.stft.set_block_size(self.window_size()); + } + fn process(&mut self, buffer: &mut Buffer, context: &mut impl ProcessContext) -> ProcessStatus { // Compensate for the window function, the overlap, and the extra gain introduced by the // IDFT operation