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> {
} }
} }
// Only process audio if the plugin is not currently bypassed
let result = if !wrapper.bypass_state.load(Ordering::Relaxed) {
let mut plugin = wrapper.plugin.write(); let mut plugin = wrapper.plugin.write();
let mut context = wrapper.make_process_context(transport); let mut context = wrapper.make_process_context(transport);
let result = plugin.process(&mut output_buffer, &mut context); let result = plugin.process(&mut output_buffer, &mut context);
wrapper.last_process_status.store(result); 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,6 +921,8 @@ 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);
// Only process audio if the plugin isn't bypassed
if !self.inner.bypass_state.load(Ordering::Relaxed) {
let result = plugin.process(&mut output_buffer, &mut context); let result = plugin.process(&mut output_buffer, &mut context);
self.inner.last_process_status.store(result); self.inner.last_process_status.store(result);
match result { match result {
@ -931,6 +933,10 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
} }
_ => kResultOk, _ => kResultOk,
} }
} else {
self.inner.last_process_status.store(ProcessStatus::Normal);
kResultOk
}
}; };
// If our block ends at the end of the buffer then that means there are no more // If our block ends at the end of the buffer then that means there are no more