Applying cascade~ with poly~ to filter data at a lower sample rate
Hi everyone,
I have biquad~ filter coefficients that model a transfer function, using data sampled at 3 kHz ( this was done in MATLAB).
I now want to build an application that can filter whatever signals I generate in max, using those filter coefficients.
I currently have a poly~ object that downsamples from 48 kHz to 3 kHz, and in the poly~ subpatcher, I use a cascade~ object that is fed with the filter coefficients I got from MATLAB. I use dspstate~ to check the sample rate in the main patcher and the poly~ patcher, and they are showing up as 48 kHz and 3 kHz respectively.
But when activate the DSP, I just get a constant output into my speaker, without any signal being passed into the dac~. What could be the problem. I also have 4 onepole~ 1000 Hz filters before and after the poly~ stage, and I've tried with and without them. Any help would be really awesome~
does the filter otherwise works as expected? in max you dont need to sign (-) the b coefficients.
Thanks for your reply Roman... In MATLAB the coefficients seem to work - at least visually, when I apply the filter. Will double check when I'm back at my desk tomorrow.
When you say you don't need to sign the b coefficients, do you mean the feedback coefficients (I noticed MATLAB and max have b and a interchanged).. and do you mean I can use the absolute values
i am not sure what the "right" order would be, but max uses a0 a1 a2 b1 b2, which is already different from e.g. PD and a few other apps.
yes, you use positive/absolute values for feedback and it should still work.
Thanks again Roman.. So I've implemented the same thing in MATLAB and it works as expected, so I think I can say the filter works as expected - in MATLAB.
As for the max implementation, I've tried both absolute and original coefficient values - also double checked the order, just be sure. It still does something weird... I realized that the filter is probably blowing up - when I send a 'clear' message to cascade~ everything settles down. When I run a tuned oscillator (cycle~) through the filter, at some specific frequencies, the filter blows up. So I am not sure why this is happening, but I'm wondering if it
maybe has something to do with the poly~ object.
Maybe correct me if I'm wrong:
1. If I downsample the poly~ patcher [poly~ down_filt 1 down 16], everything inside it runs at the lower sampling rate?
2. Whatever comes out of poly~ into the main patcher is automatically up sampled back to the host patch's rate (i.e. 48k)?
Thought I'd post my patch to make it clearer: