1
0
Fork 0

Don't process audio for bypassed plugins

This commit is contained in:
Robbert van der Helm 2022-03-23 15:49:34 +01:00
parent c6a34a63c4
commit 0cb26b5b4c
2 changed files with 24 additions and 11 deletions

View file

@ -1170,10 +1170,17 @@ impl<P: ClapPlugin> Wrapper<P> {
} }
} }
let mut plugin = wrapper.plugin.write(); // Only process audio if the plugin is not currently bypassed
let mut context = wrapper.make_process_context(transport); let result = if !wrapper.bypass_state.load(Ordering::Relaxed) {
let result = plugin.process(&mut output_buffer, &mut context); let mut plugin = wrapper.plugin.write();
wrapper.last_process_status.store(result); let mut context = wrapper.make_process_context(transport);
let result = plugin.process(&mut output_buffer, &mut context);
wrapper.last_process_status.store(result);
result
} else {
wrapper.last_process_status.store(ProcessStatus::Normal);
ProcessStatus::Normal
};
let clap_result = match result { let clap_result = match result {
ProcessStatus::Error(err) => { ProcessStatus::Error(err) => {

View file

@ -921,15 +921,21 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
let mut plugin = self.inner.plugin.write(); let mut plugin = self.inner.plugin.write();
let mut context = self.inner.make_process_context(transport); let mut context = self.inner.make_process_context(transport);
let result = plugin.process(&mut output_buffer, &mut context); // Only process audio if the plugin isn't bypassed
self.inner.last_process_status.store(result); if !self.inner.bypass_state.load(Ordering::Relaxed) {
match result { let result = plugin.process(&mut output_buffer, &mut context);
ProcessStatus::Error(err) => { self.inner.last_process_status.store(result);
nih_debug_assert_failure!("Process error: {}", err); match result {
ProcessStatus::Error(err) => {
nih_debug_assert_failure!("Process error: {}", err);
return kResultFalse; return kResultFalse;
}
_ => kResultOk,
} }
_ => kResultOk, } else {
self.inner.last_process_status.store(ProcessStatus::Normal);
kResultOk
} }
}; };