2
$\begingroup$

For a digital music synthesizer I am developing, I have a stream of incoming samples $x_i$ and would like to downsample by $M$ to obtain a stream of samples $y_{Mi}$. I am currently bandpassing the signal with an FIR which is a brick-wall filter windowed by Blackman-Harris, and it sounds great to my ears. But I have to compute $y_{Mi} = \sum_{j=0}^{N-1} x_{Mi-j} h_j$ for every outgoing sample. $N$ is usually 64 to 256, and $M$ is usually 8 or 16, so an FFT convolution doesn't seem worth it for performance.

If there a better method than naive FIR for integer decimation of audio at these scales? Can I make some reasonable tradeoffs in quality to achieve better performance? For example, polyphase decimation is a nice trick, but since RAM/cache is not an issue, I believe they should run in the same speed since they involve an equal number of multiplications.

$\endgroup$
  • 2
    $\begingroup$ Very good question! Which architecture are you working in? Software, hardware, firmware? What about paralellizations? A polyphase filter would be faster when properly implemented... $\endgroup$ – Fat32 Jun 12 '17 at 2:24
  • $\begingroup$ Sure! This software is for desktop operating systems (x86_64 with at least SSE2) using float32s but I'm also interested in answers for ARM Cortex M7 chips like STM32F7s, since I work in that area as well. In both cases, the algorithms will be single threaded. I will look more into polyphase filters to make sure I'm implementing them correctly (I'm probably not.) $\endgroup$ – Vortico Jun 12 '17 at 2:33
  • $\begingroup$ @Fat32 what kind of polyphase filter? $\endgroup$ – Olli Niemitalo Jun 12 '17 at 8:32
  • 1
    $\begingroup$ @OlliNiemitalo the kind? I don't know its kind, but given an FIR impulse response of length L used in a standard decimation by M scheme, you can decompose h[n] into its M polyphase components that're running in parallel form. When implemented within parallel hardware (multicore cpu or better the GPU) it will be faster, in contrast to OP's statement in his last paragraph... A single-threaded software implementation, however, is not achieving that benefit. $\endgroup$ – Fat32 Jun 12 '17 at 10:59
  • 1
    $\begingroup$ @Fat32 FIRs are also parallelizable in the same way the polyphase filters are, because you can just do a sum reduction. But in my application, this algorithm is one of thousands occurring on a system to produce the final audio stream, and I already parallelize on a higher level, so I don't do algorithm parallelization. $\endgroup$ – Vortico Jun 12 '17 at 11:08
1
$\begingroup$

Another way to design a FIR filter involves matching the impulse response to an analog prototype's impulse response. The idea being that an IIR can often be truncated to FIR. The FIR will not be symmetric and not have linear phase but the group delay can be much smaller. I believe that Friedlander has a paper on how to do the approximation. There was a Matlab Signal Processing Toolkit function that did this but I haven't had much cause to use it. Comet also can do nonsymetric FIR designs.

I also suggest that you try using Parks Mclelan if it can give you a shorter filter than using the window method

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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