1
0
Fork 0

Implement the reset function everywhere

This commit is contained in:
Robbert van der Helm 2022-03-08 00:42:58 +01:00
parent 70d3b5d557
commit fd8bd025c8
5 changed files with 27 additions and 16 deletions

View file

@ -252,13 +252,16 @@ impl Plugin for Diopser {
buffer_config: &BufferConfig, buffer_config: &BufferConfig,
_context: &mut impl ProcessContext, _context: &mut impl ProcessContext,
) -> bool { ) -> bool {
// Initialize the filters on the first process call
self.sample_rate = buffer_config.sample_rate; self.sample_rate = buffer_config.sample_rate;
self.should_update_filters.store(true, Ordering::Release);
true 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( fn process(
&mut self, &mut self,
buffer: &mut Buffer, buffer: &mut Buffer,

View file

@ -115,17 +115,10 @@ impl Plugin for Gain {
config.num_input_channels == config.num_output_channels && config.num_input_channels > 0 config.num_input_channels == config.num_output_channels && config.num_input_channels > 0
} }
fn initialize( // This plugin doesn't need any special initialization, but if you need to do anything expensive
&mut self, // then this would be the place. State is kept around while when the host reconfigures the
_bus_config: &BusConfig, // plugin. If we did need special initialization, we could implement the `initialize()` and/or
_buffer_config: &BufferConfig, // `reset()` methods
_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
}
fn process( fn process(
&mut self, &mut self,

View file

@ -125,6 +125,12 @@ impl Plugin for Sine {
true 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 { fn process(&mut self, buffer: &mut Buffer, context: &mut impl ProcessContext) -> ProcessStatus {
let mut next_event = context.next_midi_event(); let mut next_event = context.next_midi_event();
for (sample_id, channel_samples) in buffer.iter_mut().enumerate() { for (sample_id, channel_samples) in buffer.iter_mut().enumerate() {

View file

@ -116,14 +116,18 @@ impl Plugin for Stft {
_buffer_config: &BufferConfig, _buffer_config: &BufferConfig,
context: &mut impl ProcessContext, context: &mut impl ProcessContext,
) -> bool { ) -> 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()); context.set_latency_samples(self.stft.latency_samples());
true 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( fn process(
&mut self, &mut self,
buffer: &mut Buffer, buffer: &mut Buffer,

View file

@ -175,6 +175,11 @@ impl Plugin for PubertySimulator {
true 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 { 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 // Compensate for the window function, the overlap, and the extra gain introduced by the
// IDFT operation // IDFT operation