diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-17 21:02:25 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-17 21:02:25 +0200 |
commit | 27dacd59e08512ef2aead37ee878a2c3de2d86c0 (patch) | |
tree | 1a5991dabab806f3b0fdd3d4949ce93d26d82fa8 | |
parent | ac789750eb2c8c73b56822421f27781eb403ef3a (diff) | |
parent | 8ebabf68f84ab5558eeb2d1c983e3ee95a023ae7 (diff) | |
download | redot-engine-27dacd59e08512ef2aead37ee878a2c3de2d86c0.tar.gz |
Merge pull request #97109 from pattlebass/pitch-shift-fix
AudioEffectPitchShift: Fix distortion when pitch is 1.0
-rw-r--r-- | servers/audio/effects/audio_effect_pitch_shift.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index beca503904..89273d744b 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -286,6 +286,11 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) /* clang-format on */ void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { + // Avoid distortion by skipping processing if pitch_scale is 1.0. + if (Math::is_equal_approx(base->pitch_scale, 1.0f)) { + return; + } + float sample_rate = AudioServer::get_singleton()->get_mix_rate(); float *in_l = (float *)p_src_frames; |