0
$\begingroup$

Im simulating a system in code, the real system uses a 3Mhz sample rate on PDM, trying to simulate the feedback response, in the feedback path there is a system, this system has a impulse response of ~512k coeficients, currently processing the feedback in a time domain basis, meaning, once a sample is received, then a full convolution is done. Trying to benchmark a frequency domain solution to see if it will be quicker, is it possible to do sample by sample?

My implementation in time domain has all H coefficients in memory and there is a buffer filled with the current sample, and all previous samples, the hard part is to calculate the position in which to overlap H with the signal and then H is flipped, and a dot product is done. ie. first input signal is received, this sample is multiplied by the last H coefficient (H(n)), second sample arrived, then first sample is multiplied by the H(n-1) coef, and second sample against H(n), then they are all added.

As you may imagine this process is very slow, when the input samples reach 512k samples, we have a full signal to H convolution, this takes around 3 seconds.

is it possible to have the operations done in frequency domain? probably will need to do FFT at every sample of the full buffer or at least H size right? FFT is pretty optimized so could I shave some milliseconds off?

$\endgroup$
1
  • $\begingroup$ this might be of interest to you. $\endgroup$
    – Jdip
    Aug 29, 2023 at 7:11

1 Answer 1

1
$\begingroup$

The standard way of implementing an FIR filter in the frequency domain is the overlap-add (or overlap save). See for example: https://en.wikipedia.org/wiki/Overlap%E2%80%93add_method

In your case this would be indeed substantially faster than the direct time domain convolution. However, it does incurs significant latency. It's not "sample-by-sample" but "frame-by-frame" where the frame length is the length of the impulse response. You can only start processing a frame once you have accumulated a full frame.

In most feedback systems that type of latency is a show stopper, but that depends on your specific application. You can get a lower latency using hybrids of direct convolution and frequency overlap add. For example you could break down the 512 samples into 4 sections of 128: Implement the first one with direct convolution and the other 3 using a "block convolver" which are three sections of overlap-add that share the same FFT stage (for efficiency)

$\endgroup$
2
  • $\begingroup$ yeah when I first starter approaching this issue I tried doing it time domain in a block fashion (faster overall), but the latency and sudden change on the feedback signal made the system unstable, so now I need to do it sample by sample, so it means that its not possible to do it sample by sample on a freq domain? $\endgroup$ Aug 29, 2023 at 21:33
  • $\begingroup$ Yes, it's possible. You can cascade a time domain low-latency FIR filter with a higher latency (but more efficient) frame based frequency domain filter (OLA). The FIR does the early samples of the impulse response and the OLA does the rest $\endgroup$
    – Hilmar
    Aug 30, 2023 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.