@@ -150,8 +150,8 @@ namespace lsp
150150 if (bUpdate)
151151 update_settings ();
152152
153- size_t buf_size = 1 << nRank;
154- size_t frame_size = 1 << (nRank - 1 );
153+ const size_t buf_size = 1 << nRank;
154+ const size_t frame_size = 1 << (nRank - 1 );
155155
156156 while (count > 0 )
157157 {
@@ -183,7 +183,7 @@ namespace lsp
183183 }
184184
185185 // Estimate number of samples to process
186- size_t to_process = lsp_min (frame_size - nOffset, count);
186+ const size_t to_process = lsp_min (frame_size - nOffset, count);
187187
188188 // Copy data
189189 dsp::copy (&pInBuf[frame_size + nOffset], src, to_process);
@@ -197,6 +197,58 @@ namespace lsp
197197 }
198198 }
199199
200+ void SpectralProcessor::process (const float *src, size_t count)
201+ {
202+ // Check if we need to commit new settings
203+ if (bUpdate)
204+ update_settings ();
205+
206+ const size_t buf_size = 1 << nRank;
207+ const size_t frame_size = 1 << (nRank - 1 );
208+
209+ while (count > 0 )
210+ {
211+ // Need to perform transformations?
212+ if (nOffset >= frame_size)
213+ {
214+ if (pFunc != NULL )
215+ {
216+ // 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
220+ }
221+
222+ // Apply signal to buffer
223+ dsp::move (pOutBuf, &pOutBuf[frame_size], frame_size); // Shift output buffer
224+ dsp::fill_zero (&pOutBuf[frame_size], frame_size); // Fill tail of input buffer with zeros
225+
226+ // Shift input buffer
227+ dsp::move (pInBuf, &pInBuf[frame_size], frame_size); // Shift input buffer
228+
229+ // Reset read/write offset
230+ nOffset = 0 ;
231+ }
232+
233+ // Estimate number of samples to process
234+ const size_t to_process = lsp_min (frame_size - nOffset, count);
235+
236+ // Copy data
237+ dsp::copy (&pInBuf[frame_size + nOffset], src, to_process);
238+
239+ // Update pointers
240+ nOffset += to_process;
241+ count -= to_process;
242+ src += to_process;
243+ }
244+ }
245+
246+ size_t SpectralProcessor::remaining () const
247+ {
248+ const size_t frame_size = 1 << (nRank - 1 );
249+ return frame_size - nOffset;
250+ }
251+
200252 void SpectralProcessor::reset ()
201253 {
202254 if (bUpdate) // update_settings() will automaticaly clear the buffer
0 commit comments