Skip to content

Commit 8ebabf6

Browse files
committed
AudioEffectPitchShift: Fix distortion when pitch is 1.0
1 parent 99a7a9c commit 8ebabf6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

servers/audio/effects/audio_effect_pitch_shift.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
286286
/* clang-format on */
287287

288288
void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
289+
// Avoid distortion by skipping processing if pitch_scale is 1.0.
290+
if (Math::is_equal_approx(base->pitch_scale, 1.0f)) {
291+
return;
292+
}
293+
289294
float sample_rate = AudioServer::get_singleton()->get_mix_rate();
290295

291296
float *in_l = (float *)p_src_frames;

0 commit comments

Comments
 (0)