meter: extract to_log10, fix types of to_rms

This commit is contained in:
🪞👃🪞 2025-05-11 00:45:48 +03:00
parent 7bc37e7659
commit 6db5df5210
2 changed files with 12 additions and 14 deletions

View file

@ -41,9 +41,7 @@ impl Sampler {
for ((input, meter), channel) in samples_with_meters {
let slice = input.port().as_slice(scope);
length = length.max(slice.len());
let total: f32 = slice.iter().map(|x|x.abs()).sum();
let count = slice.len() as f32;
*meter = 10. * (total / count).log10();
*meter = to_log10(slice);
channel.extend_from_slice(slice);
}
sample.end += length;
@ -53,9 +51,7 @@ impl Sampler {
fn update_input_meters (&mut self, scope: &ProcessScope) {
for (input, meter) in self.audio_ins.iter().zip(self.input_meters.iter_mut()) {
let slice = input.port().as_slice(scope);
let total: f32 = slice.iter().map(|x|x.abs()).sum();
let count = slice.len() as f32;
*meter = 10. * (total / count).log10();
*meter = to_log10(slice);
}
}