diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-04-03 05:50:40 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-01-09 03:47:14 -0500 |
commit | 1d5042c9e265219dec8da7311879f12ef3ef698b (patch) | |
tree | 9456ab509bbcaf26cad8dca32dbe18a3cca9277d /servers/audio/effects/audio_effect_spectrum_analyzer.cpp | |
parent | 98ccaa1bad97bdb83b2afd6a4df6f7a392745592 (diff) | |
download | redot-engine-1d5042c9e265219dec8da7311879f12ef3ef698b.tar.gz |
Use Math_TAU and deg2rad/rad2deg in more places and optimize code
Diffstat (limited to 'servers/audio/effects/audio_effect_spectrum_analyzer.cpp')
-rw-r--r-- | servers/audio/effects/audio_effect_spectrum_analyzer.cpp | 3 |
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; |