浏览代码

Prevent distortion filter from introducing NaNs in the audio buffer.

Ellen Poe 4 年之前
父节点
当前提交
b6b97b86ab
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      servers/audio/effects/audio_effect_distortion.cpp

+ 2 - 1
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)) {