Only calculate peak meter while GUI is open
To show off this feature.
This commit is contained in:
parent
4260c5441c
commit
d9ac60ae85
|
@ -178,17 +178,21 @@ impl Plugin for Gain {
|
||||||
amplitude += *sample;
|
amplitude += *sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
amplitude = (amplitude / num_samples as f32).abs();
|
// To save resources, a plugin can (and probably should!) only perform expensive
|
||||||
let current_peak_meter = self.peak_meter.load(std::sync::atomic::Ordering::Relaxed);
|
// calculations that are only displayed on the GUI while the GUI is open
|
||||||
let new_peak_meter = if amplitude > current_peak_meter {
|
if self.editor_state.open() {
|
||||||
amplitude
|
amplitude = (amplitude / num_samples as f32).abs();
|
||||||
} else {
|
let current_peak_meter = self.peak_meter.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
current_peak_meter * self.peak_meter_decay_weight
|
let new_peak_meter = if amplitude > current_peak_meter {
|
||||||
+ amplitude * (1.0 - self.peak_meter_decay_weight)
|
amplitude
|
||||||
};
|
} else {
|
||||||
|
current_peak_meter * self.peak_meter_decay_weight
|
||||||
|
+ amplitude * (1.0 - self.peak_meter_decay_weight)
|
||||||
|
};
|
||||||
|
|
||||||
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