Csound Csound-dev Csound-tekno Search About

How to read parameter from table

Date2016-07-19 05:46
From"K. Meesawat"
SubjectHow to read parameter from table
Hi,
I would like to create a filter using filter2 opcode. Its manual (http://www.csounds.com/manual/html/filter2.html) says that one could read the filter parameters from GEN01 as follows.

"At initialization the number of zeros and poles of the filter are specified along with the corresponding zero and pole coefficients. The coefficients must be obtained by an external filter-design application such as Matlab and specified directly or loaded into a table via GEN01."

How do one load the filter coefficients from a table via GEN01? (or GEN23).

What I would like to do is to read the filter coefficients from a text file so that I do not have to type them in the csd file and keep the code clean. Could you please show me an example or a direction to the document?

Thank you in advance for your kindly help.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-19 15:58
FromSteven Yi
SubjectRe: How to read parameter from table
That's a good question.  I don't see any particular support for ftable
reading within the C code for filter2, so that part of the
documentation doesn't make much sense to me, and probably should be
revised. I tried doing a hack using #include but it did not work out
very well.  Perhaps someone else has an idea.

On Tue, Jul 19, 2016 at 12:46 AM, K. Meesawat  wrote:
> Hi,
> I would like to create a filter using filter2 opcode. Its manual (http://www.csounds.com/manual/html/filter2.html) says that one could read the filter parameters from GEN01 as follows.
>
> "At initialization the number of zeros and poles of the filter are specified along with the corresponding zero and pole coefficients. The coefficients must be obtained by an external filter-design application such as Matlab and specified directly or loaded into a table via GEN01."
>
> How do one load the filter coefficients from a table via GEN01? (or GEN23).
>
> What I would like to do is to read the filter coefficients from a text file so that I do not have to type them in the csd file and keep the code clean. Could you please show me an example or a direction to the document?
>
> Thank you in advance for your kindly help.
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-19 16:06
Fromjpff
SubjectRe: How to read parameter from table
Some thougts

1: these days I would use an array rather than an f-tble

2: last time I looked (ICMC Ann Arbor) zfilter2 was rather unstable.  I 
canged it to use doubles internally and that improved it.  For larger n in 
particular rounding error seemed to dominate

3:  a  version of filter2 using arrays might be a good thing

4: cascadining biquads if probably safer

But I am not a real dsp person -- more of an computer algebraist, 
astronomer, hacker.....

==John

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-19 16:08
Fromjpff
SubjectRe: How to read parameter from table
sorry should ave added use ftable-array, and ten a nastry call with many 
array accesses sould give theflexibility

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-19 16:09
Fromluis jure
SubjectRe: How to read parameter from table
el 2016-07-19 a las 05:46 K. Meesawat escribió:

> I would like to create a filter using filter2 opcode. Its manual
> (http://www.csounds.com/manual/html/filter2.html) says that one could
> read the filter parameters from GEN01 as follows.

i never used the filter myself, so i might be completely wrong, but i
guess it should say load the coefficients in a table using GEN02, not
GEN01, and then just retrieve each coefficient with the table opcode. that
would allow you to store different sets of coefficients and call them form
the score with a p-field. otherwise i don't see that it makes any sense.
don't forget to use -2, otherwise the values of the coefficients would be
normalized. anyway, i think the whole manual page for this opcode could
benefit from a major rewrite...

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-19 16:25
FromVictor Lazzarini
SubjectRe: How to read parameter from table
loading from GEN01 would only make sense if this were an FIR (and thus the table would contain the impulse response, cf. dconv).
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 19 Jul 2016, at 15:58, Steven Yi  wrote:
> 
> That's a good question.  I don't see any particular support for ftable
> reading within the C code for filter2, so that part of the
> documentation doesn't make much sense to me, and probably should be
> revised. I tried doing a hack using #include but it did not work out
> very well.  Perhaps someone else has an idea.
> 
> On Tue, Jul 19, 2016 at 12:46 AM, K. Meesawat  wrote:
>> Hi,
>> I would like to create a filter using filter2 opcode. Its manual (http://www.csounds.com/manual/html/filter2.html) says that one could read the filter parameters from GEN01 as follows.
>> 
>> "At initialization the number of zeros and poles of the filter are specified along with the corresponding zero and pole coefficients. The coefficients must be obtained by an external filter-design application such as Matlab and specified directly or loaded into a table via GEN01."
>> 
>> How do one load the filter coefficients from a table via GEN01? (or GEN23).
>> 
>> What I would like to do is to read the filter coefficients from a text file so that I do not have to type them in the csd file and keep the code clean. Could you please show me an example or a direction to the document?
>> 
>> Thank you in advance for your kindly help.
>> 
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here