change magnitude calculation
All checks were successful
Build legacy Nix package on Ubuntu / build (push) Successful in 4m34s

This commit is contained in:
Max Känner 2025-01-14 10:50:14 +01:00
parent 5f374a9bc9
commit 6936abe2ab

View File

@ -227,14 +227,12 @@ impl AudioSyncPacket {
.unwrap_or(1.0)
.max(1.0);
let magnitude = fft_max.max(*previous_magnitude * 0.99);
info!("magnitude: {magnitude}");
*previous_magnitude = magnitude;
for i in 0..fft_values.len() {
fft_values_u8[i] = (fft_values[i] * f32::from(u8::MAX) / magnitude).saturating_as();
}
// calculate fft magnitude sum
let fft_magnitude_sum = real_fft_output.iter().sum::<f32>();
let sample_smth = 0.8f32.mul_add(*previous_sample_smth, 0.2 * raw_level);
*previous_sample_smth = sample_smth;
@ -243,7 +241,7 @@ impl AudioSyncPacket {
sample_smth,
peak_level,
fft_values_u8,
fft_magnitude_sum,
magnitude,
peak_frequency,
))
}