Only calculate peak meter while GUI is open
To show off this feature.
This commit is contained in:
parent
4260c5441c
commit
d9ac60ae85
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue