Skip to content

Commit c5f6493

Browse files
committed
fix rms errors
1 parent 9b4fb65 commit c5f6493

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ where
235235
_has_update.store(false, Ordering::Release);
236236
};
237237

238-
let blocks_needed = data.len() / 2 / BLOCK_SIZE;
238+
let block_step = data.len() / channels;
239+
let blocks_needed = block_step / BLOCK_SIZE;
239240
let block_step = channels * BLOCK_SIZE;
240241
let mut rms: Vec<f32> = vec![0.0; channels];
241242
for current_block in 0..blocks_needed {
@@ -248,7 +249,7 @@ where
248249
}
249250
}
250251
}
251-
rms = rms.into_iter().map(|x| (x/512.0).sqrt() ).collect();
252+
rms = rms.into_iter().map(|x| (x / block_step as f32).sqrt() ).collect();
252253
// left rms[0] right rms[1]
253254

254255
let ptr_l = ringbuf_l.load(Ordering::SeqCst);

0 commit comments

Comments
 (0)