summaryrefslogtreecommitdiffstats
path: root/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/audio/effects/audio_effect_spectrum_analyzer.cpp')
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
index 7f73f2e880..3f7ab74a74 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
@@ -110,10 +110,11 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames
while (p_frame_count) {
int to_fill = fft_size * 2 - temporal_fft_pos;
to_fill = MIN(to_fill, p_frame_count);
+ const double to_fill_step = Math_TAU / (double)fft_size;
float *fftw = temporal_fft.ptrw();
for (int i = 0; i < to_fill; i++) { //left and right buffers
- float window = -0.5 * Math::cos(2.0 * Math_PI * (double)temporal_fft_pos / (double)fft_size) + 0.5;
+ float window = -0.5 * Math::cos(to_fill_step * (double)temporal_fft_pos) + 0.5;
fftw[temporal_fft_pos * 2] = window * p_src_frames->l;
fftw[temporal_fft_pos * 2 + 1] = 0;
fftw[(temporal_fft_pos + fft_size * 2) * 2] = window * p_src_frames->r;