@@ -121,7 +121,7 @@ namespace lsp
121121 pFftBuf = &pInBuf[buf_size];
122122
123123 // Clear buffers and reset pointers
124- windows::sqr_cosine (pWnd, buf_size);
124+ windows::cosine (pWnd, buf_size);
125125 dsp::fill_zero (pOutBuf, buf_size*4 ); // OutBuf + InBuf + Fft(x2)
126126 nOffset = buf_size * (fPhase * 0 .5f );
127127
@@ -161,19 +161,20 @@ namespace lsp
161161 if (pFunc != NULL )
162162 {
163163 // Perform FFT and processing
164- dsp::pcomplex_r2c (pFftBuf, pInBuf, buf_size); // Convert from real to packed complex
165- dsp::packed_direct_fft (pFftBuf, pFftBuf, nRank); // Perform direct FFT
166- pFunc (pObject, pSubject, pFftBuf, nRank); // Call the function
167- dsp::packed_reverse_fft (pFftBuf, pFftBuf, nRank); // Perform reverse FFT
168- dsp::pcomplex_c2r (pFftBuf, pFftBuf, buf_size); // Unpack complex numbers
164+ dsp::mul3 (&pFftBuf[buf_size], pInBuf, pWnd, buf_size); // Apply cosine window before transform
165+ dsp::pcomplex_r2c (pFftBuf, &pFftBuf[buf_size], buf_size); // Convert from real to packed complex
166+ dsp::packed_direct_fft (pFftBuf, pFftBuf, nRank); // Perform direct FFT
167+ pFunc (pObject, pSubject, pFftBuf, nRank); // Call the function
168+ dsp::packed_reverse_fft (pFftBuf, pFftBuf, nRank); // Perform reverse FFT
169+ dsp::pcomplex_c2r (pFftBuf, pFftBuf, buf_size); // Unpack complex numbers
169170 }
170171 else
171- dsp::move (pFftBuf, pInBuf, buf_size); // Copy data to FFT buffer
172+ dsp::mul3 (pFftBuf, pInBuf, pWnd, buf_size); // Copy data to FFT buffer
172173
173174 // Apply signal to buffer
174175 dsp::move (pOutBuf, &pOutBuf[frame_size], frame_size); // Shift output buffer
175176 dsp::fill_zero (&pOutBuf[frame_size], frame_size); // Fill tail of input buffer with zeros
176- dsp::fmadd3 (pOutBuf, pFftBuf, pWnd, buf_size); // Apply window and add to the output buffer
177+ dsp::fmadd3 (pOutBuf, pFftBuf, pWnd, buf_size); // Apply cosine window (-> squared cosine) and add to the output buffer
177178
178179 // Shift input buffer
179180 dsp::move (pInBuf, &pInBuf[frame_size], frame_size); // Shift input buffer
@@ -214,9 +215,10 @@ namespace lsp
214215 if (pFunc != NULL )
215216 {
216217 // Perform FFT and processing
217- dsp::pcomplex_r2c (pFftBuf, pInBuf, buf_size); // Convert from real to packed complex
218- dsp::packed_direct_fft (pFftBuf, pFftBuf, nRank); // Perform direct FFT
219- pFunc (pObject, pSubject, pFftBuf, nRank); // Call the function
218+ dsp::mul3 (&pFftBuf[buf_size], pInBuf, pWnd, buf_size); // Apply cosine window before transform
219+ dsp::pcomplex_r2c (pFftBuf, &pFftBuf[buf_size], buf_size); // Convert from real to packed complex
220+ dsp::packed_direct_fft (pFftBuf, pFftBuf, nRank); // Perform direct FFT
221+ pFunc (pObject, pSubject, pFftBuf, nRank); // Call the function
220222 }
221223
222224 // Apply signal to buffer
0 commit comments