summaryrefslogtreecommitdiff
path: root/servers/audio
diff options
context:
space:
mode:
authorBartłomiej T. Listwon <blistwon@gmail.com>2022-02-11 20:21:26 +0100
committerBartłomiej T. Listwon <blistwon@gmail.com>2022-02-11 20:21:26 +0100
commitc02e979dbf6587e847b401b1b19702e2bc937d5a (patch)
tree827d05c439311e6ba177a605013fe4e7d61eb006 /servers/audio
parentcf13f8af648c075282e596744e48d60c25fae283 (diff)
Pass audio samples untouched for pitch_scale around 1.0f
Diffstat (limited to 'servers/audio')
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
index 3c53887931..32223f47f6 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.cpp
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -288,6 +288,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) {
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_r = in_l + 1;