Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Filter2 and zfilter

Date2018-04-12 18:15
Fromjcroson
Subject[Csnd-dev] Filter2 and zfilter
Greetings Csound Developers,

I've been learning about designing filters in octave/matlab. I am wondering about the opcodes filter2 and zfilter2. Three issues:

1: Is there any reason to have a limit of 50 for the number of A or B coefficients? One article I read on waveguide strings uses a filter with 300 poles!

2: Could we include code to not initialize when the note is tied (iskip)?

3: It seems to me they operate slightly non-intuitively. M is the number of B-coefficients - fine. N is the number of A-coefficients, but the initial coefficient (always "1", I think) is assumed (that is, supplied by the code for the opcode), so the user has to paste in A-coefficients, leaving out the "1", and supply N = number of user-supplied A-coefficients, which means N does not equal the number of actual A-coefficients.

I think it would be more beautiful if it worked like biquad, where the user supplies all the A-coefficients, including the initial "1". At least a note in the manual page might save someone having to figure it out.

To avoid breaking the opcode for existing scores, maybe something (ugly) like:
   if (A_coefficient1 == 1) then
     use the rest of the given coefficients, and
     N = N-1;
   endif
   
Many thanks, and thanks for what you do for Csound,

Date2018-04-12 18:41
Fromjpff
SubjectRe: [Csnd-dev] Filter2 and zfilter
I have had doubts about these two opcodes for a very long time.  If the 
poles are near the unt curcle then there is real problems with floting 
point rounding, at least tere was when I last tried.

Regarding the change of definituons of A valus wghat if A_1 is supposed to 
be 1?  I think it would need a new opcode for that change; anyway it is 
just a scaling issue methinks.

OTOH it might be easy to raise the 50 liit with little effort or cost -- 
but am about to splot for today.


On Thu, 12 Apr 2018, jcroson wrote:

> Greetings Csound Developers,
>
> I've been learning about designing filters in octave/matlab. I am wondering about the opcodes filter2 and zfilter2. Three issues:
>
> 1: Is there any reason to have a limit of 50 for the number of A or B coefficients? One article I read on waveguide strings uses a filter with 300 poles!
>
> 2: Could we include code to not initialize when the note is tied (iskip)?
>
> 3: It seems to me they operate slightly non-intuitively. M is the number of B-coefficients - fine. N is the number of A-coefficients, but the initial coefficient (always "1", I think) is assumed (that is, supplied by the code for the opcode), so the user has to paste in A-coefficients, leaving out the "1", and supply N = number of user-supplied A-coefficients, which means N does not equal the number of actual A-coefficients.
>
> I think it would be more beautiful if it worked like biquad, where the user supplies all the A-coefficients, including the initial "1". At least a note in the manual page might save someone having to figure it out.
>
> To avoid breaking the opcode for existing scores, maybe something (ugly) like:
>   if (A_coefficient1 == 1) then
>     use the rest of the given coefficients, and
>     N = N-1;
>   endif
>
> Many thanks, and thanks for what you do for Csound,
>