0
$\begingroup$

I'm interested in composing filters for realtime audio processing on an microcontroller (MCU). Ideal frequency response is unity as a default, with deviations up and down at specific freq-domain pointers according scalers, and some type of smooth transition between these points. This is conceptually similar to an equalizer.

For example, you might want to scale the 800Hz response by 1.2, and the 1600Hz response by 0.8. it would then taper to unity everywhere else.

Normally you could sort this out by designing a filter with proper parameters on a PC (eg Scipy), but I don't know if this is viable on an MCU. MCU libs are avail that process signals if you already have coefficients, but don't create coefficients. Could you compose coefficients from various pre-built coefficients?

I've had some success with averaging weighted coefficients, as well as convolving them. Adding seems to work better, but the response still isn't ideal. How would you approach this problem?

Perhaps this could be done by composing weighted overlapping bandpass FIR (or IIR?) kernels across the entire spectrum of interest. Convolve the kernels together, or perhaps add them. (IIR you convolve bandpass filters and add bandstop?)

$\endgroup$
10
  • $\begingroup$ audio? what's the expected sample rate? how many MIPS is your microcontroller? is it a floating-point processor or only integer processor? how many bits wide is the data bus? $\endgroup$ Nov 12, 2021 at 19:54
  • $\begingroup$ And Mitch McConnell is hardly cute. $\endgroup$ Nov 12, 2021 at 19:55
  • 1
    $\begingroup$ i doubt that the data bus is 24 bits wide, but if it's an FPU it's almost certainly 32 bits wide. first thing you wanna do upon receiving samples from the A/D converter (or whatever your input stream) is to convert to float and scale it from -1 to +1. You will have about 10,000 instructions per sample per channel. That's pretty good. I dunno shit about Scipy or python. Dunno the quality of compiled code. I would be doing this in C. Stay away from double-floats and you might need to worry about denomals and maybe about NaNs if you're processing data in floating point. $\endgroup$ Nov 12, 2021 at 20:23
  • 1
    $\begingroup$ The cookbook might be a good place to start with computing coefficients. Depending on what you expect your EQ to do, you might want to worry about the form of the structure. Direct Form 1 is easy, but might not be good for rapidly varying filter parameters. $\endgroup$ Nov 12, 2021 at 20:26
  • 1
    $\begingroup$ Solved using the approach above. Verified Scipy shows desirable freq response, and it works on the MCU as expected. $\endgroup$ Nov 12, 2021 at 22:12

1 Answer 1

2
$\begingroup$

One canonical solution is described by an old Motorola Application Note on how to design a 10-band equalizer for the 56000 DSP chip. Occasionally recomputing the IIR coefficients usually requires far fewer ops than running the filters.

$\endgroup$

Your Answer

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

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