mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
meter: extract to_log10, fix types of to_rms
This commit is contained in:
parent
7bc37e7659
commit
6db5df5210
2 changed files with 12 additions and 14 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue