Pass audio samples untouched for pitch_scale around 1.0f

(cherry picked from commit c02e979dbf)
This commit is contained in:
Bartłomiej T. Listwon 2022-02-11 20:21:26 +01:00 committed by Rémi Verschelde
parent 5ca3a360d1
commit 6471d0a57a
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -292,6 +292,14 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
float sample_rate = AudioServer::get_singleton()->get_mix_rate(); float sample_rate = AudioServer::get_singleton()->get_mix_rate();
// For pitch_scale 1.0 it's cheaper to just pass samples without processing them.
if (Math::is_equal_approx(base->pitch_scale, 1.0f)) {
for (int i = 0; i < p_frame_count; i++) {
p_dst_frames[i] = p_src_frames[i];
}
return;
}
float *in_l = (float *)p_src_frames; float *in_l = (float *)p_src_frames;
float *in_r = in_l + 1; float *in_r = in_l + 1;