What does this audio define do?

Ok so I know what “#define FILTER_CUTOFF_FREQUENCY” does, but why is it paired with “#define FILTER_ORDER” and what does it do?

What does changing it from the default of 8 accomplish?

Short answer: FILTER_ORDER specifies how steep the frequency response curve is.

Long answer:

Wow, that’s alot. Unfortunately that Wiki entry isn’t very helpful for someone with my limited knowledge on the subject lol.

Can anyone break it down to an ELI5 level?

“Quick roll-off around the cutoff frequency, which improves with increasing order
Considerable overshoot and ringing in step response, which worsens with increasing order”

Does the default setting of 8 mean it’s an eighth order filter?

Yes.
A butteworth filter has a roll-off of -6dB per octave per order.
-6dB is half the volume.

So a first-order filter has a roll-off of -6db per octave. (half the volume)
A second-order filter has a roll-off of -12db per octave. (quarter the volume)
A third-order filter has a roll-off of -18db per octave. (eight of the volume)

An eight-order filter has a roll-off of -48db per octave. (1/256th of the volume)

Note that this roll-off is per octave. [1]
So if you set the cutoff frequency to 300Hz, and the filter order to 2, then a sound at 150Hz will have a quarter of the volume, while a sound at 75Hz will have one sixteenth of the volume.

The default is probably overkill, a fourth-order filter is probably good enough.

[1] For anybody who didn’t know: an octave means doubling or halving the frequency of the sound.

1 Like

That’s a lot more my level, thank you very much.

Now that I sorta kinda understand the concept, my brain needs to fiddle around with it and see/hear it in action to fully grasp it’s application.

It’s the slope of a low pass filter.

The higher the order the steeper the slope?

correct… unless i’m totally wrong

1 Like

@profezzorn
It just dawned on me that maybe we should have this be part of the font config.ini instead of a define in the config that’s globally setting this. A per-font basis makes more sense maybe, no?

1 Like

No. Filter is done to remove sounds from the font that the speaker can’t play. The speaker doesn’t change when you switch font, so why would you want to change the filtering from font to font?

Any filtering that is part of the design of the font itself, should be incorporated into the actual wav files.

Finally, the filter coefficients are curerntly calculated at compile time, which makes the filter much more efficient, both in terms of cpu time and in terms of flash memory used. If it was a part of the config file it would have to be done dynamically. In some sense that would be easier since there is lots of code available that does that, but it would take up more space and take more cpu time.

1 Like