mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
cellMic: fix division by zero
This commit is contained in:
parent
cb539579b5
commit
5e6aef5dfd
1 changed files with 2 additions and 2 deletions
|
@ -590,8 +590,8 @@ f32 microphone_device::calculate_energy_level()
|
|||
sum_squares += normalized_sample * normalized_sample;
|
||||
}
|
||||
|
||||
const f32 rms = std::sqrt(sum_squares / num_samples);
|
||||
const f32 decibels_max = 90.0f;
|
||||
const f32 rms = num_samples > 0 ? std::sqrt(sum_squares / num_samples) : 0.0f;
|
||||
constexpr f32 decibels_max = 90.0f;
|
||||
const f32 decibels_relative = 20.0f * std::log10(std::max(rms, 0.00001f));
|
||||
const f32 decibels = decibels_max + (decibels_relative * 0.5f);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue