diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-19 07:45:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 07:45:27 +0100 |
commit | 5a9cab4fa4ba5e38e16065a23766e044f692b272 (patch) | |
tree | f3661c2462c6f970fe4a8e59a57d19780d0f4fe2 /servers/audio | |
parent | a23d7480d25c06bc8b995ab0406f7c2f1954945a (diff) | |
parent | b6b97b86ab7f29bd9e5f81c6c76819fd6b4dbf10 (diff) |
Merge pull request #46199 from ellenhp/fix_distortion_filter
Prevent distortion filter from introducing NaNs in the audio buffer
Diffstat (limited to 'servers/audio')
-rw-r--r-- | servers/audio/effects/audio_effect_distortion.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index b79434e7c2..06d51776a3 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -58,7 +58,8 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi switch (base->mode) { case AudioEffectDistortion::MODE_CLIP: { - a = powf(a, 1.0001 - drive_f); + float a_sign = a < 0 ? -1.0f : 1.0f; + a = powf(abs(a), 1.0001 - drive_f) * a_sign; if (a > 1.0) { a = 1.0; } else if (a < (-1.0)) { |