Skip to content

Commit

Permalink
Merge pull request #46199 from ellenhp/fix_distortion_filter
Browse files Browse the repository at this point in the history
Prevent distortion filter from introducing NaNs in the audio buffer
  • Loading branch information
akien-mga authored Feb 19, 2021
2 parents a23d748 + b6b97b8 commit 5a9cab4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion servers/audio/effects/audio_effect_distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 5a9cab4

Please sign in to comment.