From c95af5f83e9d8fde942d7768732c4285bf45774c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 25 May 2022 00:06:32 +0200 Subject: [PATCH] Don't engage Safety Limiter while bouncing --- plugins/safety_limiter/src/lib.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/safety_limiter/src/lib.rs b/plugins/safety_limiter/src/lib.rs index 901d1800..13c06805 100644 --- a/plugins/safety_limiter/src/lib.rs +++ b/plugins/safety_limiter/src/lib.rs @@ -19,6 +19,8 @@ use std::sync::Arc; struct SafetyLimiter { params: Arc, + + buffer_config: BufferConfig, } #[derive(Params)] @@ -55,6 +57,12 @@ impl Default for SafetyLimiter { fn default() -> Self { SafetyLimiter { params: Arc::new(SafetyLimiterParams::default()), + buffer_config: BufferConfig { + sample_rate: 1, + min_buffer_size: 0, + max_buffer_size: 0, + process_mode: ProcessMode::Realtime, + }, } } } @@ -78,6 +86,17 @@ impl Plugin for SafetyLimiter { config.num_input_channels == config.num_output_channels } + fn initialize( + &mut self, + bus_config: &BusConfig, + buffer_config: &BufferConfig, + context: &mut impl ProcessContext, + ) -> bool { + self.buffer_config = *buffer_config; + + true + } + fn reset(&mut self) { // TODO: Reset counters } @@ -87,7 +106,10 @@ impl Plugin for SafetyLimiter { buffer: &mut Buffer, _context: &mut impl ProcessContext, ) -> ProcessStatus { - // TODO: Dew it + // Don't do anything when bouncing + if self.buffer_config.process_mode == ProcessMode::Offline { + return ProcessStatus::Normal; + } ProcessStatus::Normal }