Merge pull request #46199 from ellenhp/fix_distortion_filter

Prevent distortion filter from introducing NaNs in the audio buffer
This commit is contained in:
Rémi Verschelde 2021-02-19 07:45:27 +01:00 committed by GitHub
commit 5a9cab4fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)) {