Dsp_filters_biquads

Technical questions regarding the XTC tools and programming with XMOS.
tom3
Member++
Posts: 16
Joined: Mon Jun 19, 2023 9:32 pm

Dsp_filters_biquads

Post by tom3 »

Hello

I wanted to use the function dsp_filters_biquads. According to an input provided by the user, the function should implement the right cascaded filter.

Everything works fine excepts the filter_state. The size of filter_state should change according to the number of coeffs. First i wanted to dynamically change the size the array filter_state ( it works with the array for the coeffs), but it i didn't work

So i had to create multiples array that each have a differents size , so i could put them in a jagged array. It is a waste of memory , but other methods didn't work

I also tried to use one filter_state, but instead of changing it, i i tried to change the coeffs. For example with filter_state of size 16, i need an array of coeffs of size 20. But if i only have the need for 3 sections( so 15 coeffs) i would put the other b0= 1 and b1, b2,a1,a2=0 so it wouldn't influence the rest of the needed sections. This "trick" didn't work either, so i'm asking if there is something else that i can do to resolve the problem with the filter_state? As i said ,declarg many filter_state arrays with differents size works but wouldn't be efficient.


Thank you in advance

Regards


User avatar
CousinItt
Respected Member
Posts: 365
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

You can simply declare the coefficient and sample arrays for the largest filter that you need, and then, if you need a smaller filter, just set the appropriate number of coefficients to one or zero. [EDIT: I mean Qnn(1.0), Qnn(0) is zero in any integer format.]

You say you've tried that, but there must be some problem with your implementation if it doesn't work.

Note that whenever you change the coefficients you have to reset the filter state to zero.