change magnitude calculation
All checks were successful
Build legacy Nix package on Ubuntu / build (push) Successful in 4m34s
All checks were successful
Build legacy Nix package on Ubuntu / build (push) Successful in 4m34s
This commit is contained in:
parent
5f374a9bc9
commit
6936abe2ab
@ -227,14 +227,12 @@ impl AudioSyncPacket {
|
|||||||
.unwrap_or(1.0)
|
.unwrap_or(1.0)
|
||||||
.max(1.0);
|
.max(1.0);
|
||||||
let magnitude = fft_max.max(*previous_magnitude * 0.99);
|
let magnitude = fft_max.max(*previous_magnitude * 0.99);
|
||||||
|
info!("magnitude: {magnitude}");
|
||||||
*previous_magnitude = magnitude;
|
*previous_magnitude = magnitude;
|
||||||
for i in 0..fft_values.len() {
|
for i in 0..fft_values.len() {
|
||||||
fft_values_u8[i] = (fft_values[i] * f32::from(u8::MAX) / magnitude).saturating_as();
|
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);
|
let sample_smth = 0.8f32.mul_add(*previous_sample_smth, 0.2 * raw_level);
|
||||||
*previous_sample_smth = sample_smth;
|
*previous_sample_smth = sample_smth;
|
||||||
|
|
||||||
@ -243,7 +241,7 @@ impl AudioSyncPacket {
|
|||||||
sample_smth,
|
sample_smth,
|
||||||
peak_level,
|
peak_level,
|
||||||
fft_values_u8,
|
fft_values_u8,
|
||||||
fft_magnitude_sum,
|
magnitude,
|
||||||
peak_frequency,
|
peak_frequency,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user