1
0
Fork 0

Only calculate peak meter while GUI is open

To show off this feature.
This commit is contained in:
Robbert van der Helm 2022-02-08 20:28:40 +01:00
parent 4260c5441c
commit d9ac60ae85

View file

@ -178,6 +178,9 @@ impl Plugin for Gain {
amplitude += *sample; amplitude += *sample;
} }
// To save resources, a plugin can (and probably should!) only perform expensive
// calculations that are only displayed on the GUI while the GUI is open
if self.editor_state.open() {
amplitude = (amplitude / num_samples as f32).abs(); amplitude = (amplitude / num_samples as f32).abs();
let current_peak_meter = self.peak_meter.load(std::sync::atomic::Ordering::Relaxed); let current_peak_meter = self.peak_meter.load(std::sync::atomic::Ordering::Relaxed);
let new_peak_meter = if amplitude > current_peak_meter { let new_peak_meter = if amplitude > current_peak_meter {
@ -190,6 +193,7 @@ impl Plugin for Gain {
self.peak_meter self.peak_meter
.store(new_peak_meter, std::sync::atomic::Ordering::Relaxed) .store(new_peak_meter, std::sync::atomic::Ordering::Relaxed)
} }
}
ProcessStatus::Normal ProcessStatus::Normal
} }