[Math] [DSP] Low frequency filter at high sample rate - Page 1
Forum section: electronics / projects

author: blueskull
author_rank: Unknown
timestamp: September 02, 2017, 11:08:18 pm
content: Don't know if I should post it here or in MCU section, but since it's more a math issue rather than the actual MCU/DSP implementation, I decided to post it here.Is there a good way to implement a band pass equalizer at high sample rate? My goal is to have at least 50Hz frequency resolution at 192ksps sample rate.The brutal way is to use delta F=50Hz, then taps=3.1*192000/50=12k, and I will need 12k MACs per sample to do this, or 2.3GMACs/s, which is silly. With supporting DSP architecture, I can probably reduce it to 1.25GMACs/s with folded structure.Even with FFT convolution, let sample size=16k, padded to 32k, and filter size=12k, padded to 32k, then 2 32k FFTs and 1 32k IFFT need to be performed, ignoring the 32k dot product.This calls for k*3*15*32768 MACs per 16k sample, or at 192ksps, that's 17.7M butterfly operations per second. Assuming k=3, then that's 53MMACs/s, or >100MMACs/s for stereo.Is there a smarter way to do low frequency equalization on high sample rate? My target is 50MMACs/s max for stereo. The target is BlackFin+ running at 396MHz.*: Resampling is not an option. 192k is a must. Linear phase or at least minimum phase is a must.

author: cdev
author_rank: Super Contributor
timestamp: September 02, 2017, 11:53:59 pm
content: You might be able to glean something from Linrad, the SDR app's code... It is able to get very high resolution FFT out of a 192 khz window (sound card used for sampling)http://sm5bsz.comhttp://sm5bsz.com/linuxdsp/linrad.htm

author: bson
author_rank: Unknown
timestamp: September 03, 2017, 12:48:59 am
content: I would just decimate the sample data to some reasonable rate, say 4-5x the signal of interest up front. Using a boxcar filter, moving average, or whatever is easy to implement. It doesn't terribly matter. If you get 200kS/s for a 50Hz signal just collect groups 1000 samples, average them, and use that as a 200S/s acquisition, then low- or bandpass that for 50Hz.

author: ruairi
author_rank: Frequent Contributor
timestamp: September 03, 2017, 03:14:07 am
content: Quote from: blueskull on September 02, 2017, 11:08:18 pmEven without knowing the application I can that you absolutely do not want to be using a Linear Phase filter on audio at 50Hz, it will sound horrific.

author: BrianHG
author_rank: Super Contributor
timestamp: September 03, 2017, 03:34:22 am
content: 1 dirty trick to simplify this one out if you don't need such a narrow band FIR/FFT grade response.Think about feeding your sample through a simulated RLC filter. You'll cut your processing power and ram down to nothing but a few words...Though, if you want to mix a + or - % the results with your source audio, like making a bass adjustment knob, you will need to resolve the optimum group delay, and the ram requirements will go up but processing will be nil compared to all those multiply adds in a full filter.Depending on the app, IE eliminate DC from the source audio, or a POP filter, this can be effective. Creating a multi band EQ with a bunch of these might not be so refined going above 3-5 channels.You will of course not get the perfect quality of a true FIR filter.Another dirty trick, as for ultra-sonic filter, a simple 2 or 4 +/- multiply add on the digital audio with 88.2Khz and above source will remove any sound above 22Khz, or 24Khz for the 96Khz variants.

author: BrianHG
author_rank: Super Contributor
timestamp: September 03, 2017, 04:08:36 am
content: If you are using such a filter as a bottom shelf filter. IE, going from approx 50hz down to 0hz, it shouldn't be too bad. If you want a band centered at 50hz, +/- 20hz, it wont be good. A simple RC simulated filter should meet audiophile spec as it doesn't bend phase of your source signals at different frequencies. But, it has a really low Q, a wide smooth slope. RLC has a much better Q factor, but, we know how that one can shift the phase of different frequencies fed in messing up the quality of the final output waveform.I wonder what the response would be like to feed multiple RC filters in series? Does it sharpen the response slope, improving the Q?

author: ruairi
author_rank: Frequent Contributor
timestamp: September 03, 2017, 05:07:07 am
content: Quote from: blueskull on September 03, 2017, 03:50:04 amThere's so much I could write on this topic.Do you ever travel to Los Angeles?

author: jahonen
author_rank: Super Contributor
timestamp: September 03, 2017, 09:51:32 am
content: I would consider if the phase-linear equalizer even makes sense or is desirable.I think for audio applications, minimum-phase type (which is just old plain IIR biquad) would be more appropriate, since a minimum-phase system can be used to transform a minimum-phase system into another minimum-phase system (e.g. equalizer zeros cancel the original system poles and introduce new desired poles). This is the case for example for the "Linkwitz transform". Using linear phase makes no sense at all for that kind of application.I know, linear phase sounds nice but it is not always better than computationally much cheaper system.Regards,Janne

author: ruairi
author_rank: Frequent Contributor
timestamp: September 03, 2017, 04:21:44 pm
content: Quote from: blueskull on September 03, 2017, 05:26:36 amPlease don't take my questioning of your ideas as a critique of your engineering abilities. I've been here a little while and know what you are capable of.I've been a mastering engineer for 16 years and I spend all day every day listening and comparing. I have set up thousands of speakers, and listened to most every high end audio DAC available in the pro space. EQ is my most fundamental tool in the studio and again I've heard most every topology and implementation.The pre-ringing of the filters in linear phase EQs is a huge problem at lower and mid frequencies. Further, as Jahonen alluded to below most of the real world problems that we are trying to fix with EQ are minimum phase problems and need minimum phase corrections. The issues that aren't minimum phase cannot be correct by any eq and are typically caused by room acoustics summation issues.This start of this video will give you a quick example of how pre-ringing can damage our perception of music -

author: Kalvin
author_rank: Super Contributor
timestamp: September 03, 2017, 04:37:22 pm
content: Sounds like something requiring multirate processing and filtering. Decimate by 2 for each stage for octave band processing and you can use same filter coefficients for the filters across bands, use FIR or IIR filters for the equalizers. Interpolate back to the original sample rate. Adjust for the delay introduced by decimation and interpolation. Simulate using Octave/Matlab. Use at least 24-bit samples and coefficients.Book "Digital Audio Signal Processing" by Udo Zölzer is quite good text about the subject containing a section about Equalizers and multirate processing.

author: MasterT
author_rank: Frequent Contributor
timestamp: September 04, 2017, 03:14:21 am
content: Simpy, you can't. The most efficient way would be to run 2 FFT and 2 iFFT with 50% overlapping.FIR absolutely out of scope, to have 50 Hz resolution with such high sampling rate the size of the filter kernel (number of coeff.) should go well above 1k. That means 1000 MAC x 12 000 filters for Each sample.FFT is always linear, you can't have log frequency scale.So, this boils down instead of 12 k linearly spaced, to create just 5-7 FIR filters in parametric mode, when you can adjust freq. response, and tune each filter to exact freq. of interests. I can't imagine audio content, that demands more than that for freq. equalization.

author: ruairi
author_rank: Frequent Contributor
timestamp: September 04, 2017, 05:35:02 am
content: Can you tell us the feature set you are aiming for? From a control point of view as the end user would experience it?

author: KE5FX
author_rank: Super Contributor
timestamp: September 04, 2017, 05:49:32 am
content: Quote from: MasterT on September 04, 2017, 03:14:21 amSurprisingly enough there are some exceptions to that. There exists a Logarithmic Fourier Transform (see Jason H.'s answer athttps://stackoverflow.com/questions/1120422/is-there-an-fft-that-uses-a-logarithmic-division-of-frequencyfor a .PDF link), along with various wavelet techniques.Not sure what to expect in terms of sound quality, since I've barely heard of this transform myself.

author: BrianHG
author_rank: Super Contributor
timestamp: September 04, 2017, 07:22:31 am
content: Quote from: blueskull on September 04, 2017, 04:34:42 amThis can be compensated for by just using the appropriate delay factor when summing your filtered signal with the source audio, so long as your filter doesn't have any positive amplified gain within it. Post mixing a +/-% of the filter's output with the delayed source audio doesn't count. However, such a 50hz filter will not be narrow band. If you want anything with FIR performance, your stuck with 3.84k bins.Simple sum-averaging the source audio into a 3.84k buffer, mixing a % of that result with the center sample in the buffer at the 1.92k point will give you an in-phase audiophile grade 0-50hz bin which you can add or subtract basically what you would call very low bass.Within that 3.84k buffer, keep track of the center 1.92k samples as well making a second average would give you a 0-100hz bin. Subtract out the 0-50hz bin from 0-100hz bin, and you will have a 100hz +/- 50hz bin. This is an all integer equalizer which can be done in a small DSPIC with ease.With this, you now have the processing power to create a 25hz filter as well as any other odd low frequency like 35hz, 36hz, 37hz, ect. You are no longer tied to exact multiple of your sample rate except for higher frequencies...Sort of like the opposite problem to a FIR filter...Now, when averaging, remember that 3840 * 2^16bit fits within a 32 bit integer.Now, when averaging, remember that 3840 * 2^24 is more than a 32 bit integer.Processing these averages in floating point solves this issue but introduces floating rounding errors.This is how to make a super low processing power EQ, but, be warned that when applying a +%, you don't exceed the upper and lower sample limits of your variables bit depth.Also, applying too much negative % (IE, lowering the BASS), you will go past lowering the bass to inverting the bass, then negatively amplifying it at -180 degrees to a n out of control level.If you are creating a high pass filter, EG - DC removal/correction, you don't need the delay, but tune your filter for VLF.

author: ruairi
author_rank: Frequent Contributor
timestamp: September 04, 2017, 08:16:04 am
content: Quote from: blueskull on September 04, 2017, 06:18:25 amThanks for the breakdown.

author: MasterT
author_rank: Frequent Contributor
timestamp: September 04, 2017, 09:50:17 am
content: Quote from: KE5FX on September 04, 2017, 05:49:32 amIt would not be surprise to me, to find a few links on google, that says a square wheel was invented. Sorry, not going to waste my time to read such nonsense, same apply to wavelets or log FFT.

author: chris_leyson
author_rank: Super Contributor
timestamp: September 04, 2017, 10:22:06 am
content: You might want to look at "Multirate Signal Processing" by Fred Harris

author: MasterT
author_rank: Frequent Contributor
timestamp: September 04, 2017, 10:38:54 am
content: Quote from: blueskull on September 04, 2017, 04:34:42 amYour math is a mystery, my understanding 3.84k is 192000/ 50, but where did you get 12k?Running FFT approach with size 4096, gets 192 000 /4096 = 46.875 Hz resolution per bin. DSP processing requirements close to: 2 (stereo) x 2 (forward) x 2(reverse) x 2 MAC/ sample (butterfly) = 16 MAC/ sample, or 192 000 x 16 = 3072 000 MAC / second. 3 Mega, not 17 or 50M or 2.3 G

author: MasterT
author_rank: Frequent Contributor
timestamp: September 04, 2017, 04:44:53 pm
content: Quote from: blueskull on September 04, 2017, 03:22:34 pmStill can't get how windowing function comes in perspective, it doesn't use accumulate, only multiply 1 sample by 1 coeff. Factor 1 perhaps? There is some overhead, but less than 10% of the main processing subroutine.No, I didn't forget log(N), because it's rough approximation. Real value of the last term in formula (MAC/ sample) may vary depends on the kind of FFT, as low as 2.2-2.3 for Split-Radix-9, and 2.5-3 for Radix-4. I've being measuring this "bottle neck" operation for ARM cortex-3 uCPU for a long time, since hardware doesn't have DSP support and floating point co-processor.