Create a filter (quickly) with list of frequencies and dB

Rodrigo's icon

I'm working on a patch that does onset and descriptor analysis and produces a filter shape in frequencies and decibels.

I'm then creating an impulse response for it (using the HISSTools) and applying that to a sample.

Here's a little video demo-ing the idea.
https://www.youtube.com/watch?v=qvMxNJLiopE

This is working at the moment, and sounds really good. BUT the problem is that creating an IR 'on the fly' like this is a bit slow. By "slow" I mean it can take anywhere between 4-20ms, which isn't very slow, but in the context of sharp attacks and sample playback, it makes the difference between being audible and being masked by the initial attack.

So I want to see if it's possible to create the required filter without having to create an IR.

The part of the patch that creates the analysis generates a list of 20 frequencies and corresponding dBs. Here are a couple examples:

221.833218 -33.6 362.220601 -36.893817 523.987791 -40.530337 710.390753 -43.361263 925.181305 -44.610198 1172.682637 -45.796093 1457.876324 -46.420653 1786.50259 -49.265432 2165.17585 -45.506487 2601.517837 -44.333595 3104.311008 -46.474693 3683.675316 -47.684246 4351.271895 -49.680367 5120.537773 -49.981456 6006.95632 -50.487615 7028.368896 -47.975821 8205.333946 -49.788011 9561.540794 -51.071733 11124.286444 -49.155568 12925.025005 -49.777985

221.833218 -47.567153 362.220601 -45.287216 523.987791 -39.264205 710.390753 -25.401317 925.181305 -18.077634 1172.682637 -21.708286 1457.876324 -31.175341 1786.50259 -32.382667 2165.17585 -32.84 2601.517837 -36.17214 3104.311008 -35.166051 3683.675316 -37.49658 4351.271895 -37.9 5120.537773 -38.04486 6006.95632 -37.585687 7028.368896 -36.502354 8205.333946 -37.013693 9561.540794 -40.354406 11124.286444 -39.163458 12925.025005 -35.990496

Is there a way to quickly turn these into filter coefficients which I can feed into a cascade~ or something similar?

Or is there a faster way to create something along what I need here?

testcase's icon

I have some ideas but not sure if they would prove suitable. You could use the fffb~ object and give it your list of freqs and dB (would have to convert to linear amp). You could use mc.reson~ in a similar way but the control would be different. mc.filtercoeff~ to mc.biquads~ could work as well.

Rodrigo's icon

Interesting! I haven't ever used (or really seen) fffb~. That might be ideal. Will mock something up and test.

Rodrigo's icon

Ok, this seems promising. I'm running into some issues where the filter being produced is waaay to quiet, and then I realized that part of the process I'm doing with the HISSTools is compensating for the gain of the final IR, so I need to find a way to do that in Max-land.

Trying some crude normalization of the linear amplitude version of the filters, but I'm not sure that's the correct approach.