[Csnd] getting fgens via API

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] getting fgens via API

Francesco Porta
Hello All,
i'm trying to write a Lua program for display all tables created in a csd.
Until now i was able to read the ftables in the score section but how can i
read table in the orchestra section i.e. when the GENs are named gens?
How can i retrieve the table number from table name?
And is there a way to reading all tables before executing the csd?

Thanks,
ciao,
francesco.

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

rorywalsh
Tables can be retrieved using csoundGetTable whether they are created in the score or orchestra. You can also work with named channels by using one of the utilities methods presented here:

On 11 September 2017 at 09:21, Francesco Porta <[hidden email]> wrote:
Hello All,
i'm trying to write a Lua program for display all tables created in a csd.
Until now i was able to read the ftables in the score section but how can i
read table in the orchestra section i.e. when the GENs are named gens?
How can i retrieve the table number from table name?
And is there a way to reading all tables before executing the csd?

Thanks,
ciao,
francesco.

Csound mailing list
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

Francesco Porta
In reply to this post by Francesco Porta
Thanks Rory,
but i do not understand (as usual :)).
I am doing this:
1 retrieve the fgen number reading a csd as text
2 retrieve length and values using

    cs:TableLength(numeroTavola)
    for i=1, length do
        value = cs:TableGet(numeroTavola, i)
    end

this is working ok. But what if i have an orchestra ftgen with automatic number assigned,
i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
How can i retreive the assigned number?

Thanks again,
ciao,
francesco,

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

jpff
As far as I can tell you could search in a loop as GetTable returns -1 for a
nonexistent table, or you could use a channel to transmit gisine.  It might be
nice to know maxfnum (largest table number) but I think it is not available

On Mon, 11 Sep 2017, Francesco Porta wrote:

> Thanks Rory,
> but i do not understand (as usual :)).
> I am doing this:
> 1 retrieve the fgen number reading a csd as text
> 2 retrieve length and values using
>
>    cs:TableLength(numeroTavola)
>    for i=1, length do
> value = cs:TableGet(numeroTavola, i)
>    end
>
> this is working ok. But what if i have an orchestra ftgen with automatic number assigned,
> i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
> How can i retreive the assigned number?
>

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

rorywalsh
To get around this issue I've simply set the table number. But I agree, it would be nice to be able to use these tables. It doesn't work with Cabbage either. It can be done via the API, but it's a hack. You can parse the Csd for the global table variables. When you have their name you can run Csound in debug mode for a single cycle and grab the value of the global variables. Their order of appearance in the header section plus 100 will give you the table number. I always thought it would be nice to have an API function to query the value of any variable at any given time, but I don't think it's possible without serious restructuring. Perhaps this is why use channels instead!   

On 11 September 2017 at 19:58, jpff <[hidden email]> wrote:
As far as I can tell you could search in a loop as GetTable returns -1 for a nonexistent table, or you could use a channel to transmit gisine.  It might be nice to know maxfnum (largest table number) but I think it is not available

On Mon, 11 Sep 2017, Francesco Porta wrote:

Thanks Rory,
but i do not understand (as usual :)).
I am doing this:
1 retrieve the fgen number reading a csd as text
2 retrieve length and values using

   cs:TableLength(numeroTavola)
   for i=1, length do
        value = cs:TableGet(numeroTavola, i)
   end

this is working ok. But what if i have an orchestra ftgen with automatic number assigned,
i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
How can i retreive the assigned number?


Csound mailing list
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

jpff
Not entirely true. It allocates from 100 but skips already existing used table numbers.  Basically you say I do not care about the number when you ask for some value and it may change how it is done.

⁣Sent from TypeApp ​

On Sep 11, 2017, 23:58, at 23:58, Rory Walsh <[hidden email]> wrote:

>To get around this issue I've simply set the table number. But I agree,
>it
>would be nice to be able to use these tables. It doesn't work with
>Cabbage
>either. It can be done via the API, but it's a hack. You can parse the
>Csd
>for the global table variables. When you have their name you can run
>Csound
>in debug mode for a single cycle and grab the value of the global
>variables. Their order of appearance in the header section plus 100
>will
>give you the table number. I always thought it would be nice to have an
>API
>function to query the value of any variable at any given time, but I
>don't
>think it's possible without serious restructuring. Perhaps this is why
>use
>channels instead!
>
>On 11 September 2017 at 19:58, jpff <[hidden email]> wrote:
>
>> As far as I can tell you could search in a loop as GetTable returns
>-1 for
>> a nonexistent table, or you could use a channel to transmit gisine.
>It
>> might be nice to know maxfnum (largest table number) but I think it
>is not
>> available
>>
>> On Mon, 11 Sep 2017, Francesco Porta wrote:
>>
>> Thanks Rory,
>>> but i do not understand (as usual :)).
>>> I am doing this:
>>> 1 retrieve the fgen number reading a csd as text
>>> 2 retrieve length and values using
>>>
>>>    cs:TableLength(numeroTavola)
>>>    for i=1, length do
>>>         value = cs:TableGet(numeroTavola, i)
>>>    end
>>>
>>> this is working ok. But what if i have an orchestra ftgen with
>automatic
>>> number assigned,
>>> i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
>>> How can i retreive the assigned number?
>>>
>>>
>> Csound mailing list
>> [hidden email]
>> 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
>[hidden email]
>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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

Victor Lazzarini-2
In reply to this post by rorywalsh
We should have this discussion in the developers’ list, but anyway, here’s the situation regarding access to “any variable”,
as I see it.

1. Steven’s type system would allow us to expose access to variables, that is not the main issue.
2. Local variables are allocated in an instrument variable pool, and they exist per-instance
3. Globals are in a global pool.
4. To access a variable in an instrument we need to have an instance handle of some kind. So a mechanism to
manipulate instance handles needs to be added to the API.
5. Accessing the global pool should be easier since it does not depend on any given instance.

So we need to design an API to access the type system, and we should do this in a way that is complete
and without hacks. If it is agreed that we should do this, we can put that on the 7.00 list.
========================
Prof. 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 11 Sep 2017, at 23:57, Rory Walsh <[hidden email]> wrote:
>
> To get around this issue I've simply set the table number. But I agree, it would be nice to be able to use these tables. It doesn't work with Cabbage either. It can be done via the API, but it's a hack. You can parse the Csd for the global table variables. When you have their name you can run Csound in debug mode for a single cycle and grab the value of the global variables. Their order of appearance in the header section plus 100 will give you the table number. I always thought it would be nice to have an API function to query the value of any variable at any given time, but I don't think it's possible without serious restructuring. Perhaps this is why use channels instead!  
>
> On 11 September 2017 at 19:58, jpff <[hidden email]> wrote:
> As far as I can tell you could search in a loop as GetTable returns -1 for a nonexistent table, or you could use a channel to transmit gisine.  It might be nice to know maxfnum (largest table number) but I think it is not available
>
> On Mon, 11 Sep 2017, Francesco Porta wrote:
>
> Thanks Rory,
> but i do not understand (as usual :)).
> I am doing this:
> 1 retrieve the fgen number reading a csd as text
> 2 retrieve length and values using
>
>    cs:TableLength(numeroTavola)
>    for i=1, length do
>         value = cs:TableGet(numeroTavola, i)
>    end
>
> this is working ok. But what if i have an orchestra ftgen with automatic number assigned,
> i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
> How can i retreive the assigned number?
>
>
> Csound mailing list
> [hidden email]
> 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 [hidden email] 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] getting fgens via API

rorywalsh
I think it would be very useful. Definitely worth further discussion. But I don't think we should to be able to directly modify variables from the API. I think that might just lead to abuse. 

On 12 September 2017 at 10:02, Victor Lazzarini <[hidden email]> wrote:
We should have this discussion in the developers’ list, but anyway, here’s the situation regarding access to “any variable”,
as I see it.

1. Steven’s type system would allow us to expose access to variables, that is not the main issue.
2. Local variables are allocated in an instrument variable pool, and they exist per-instance
3. Globals are in a global pool.
4. To access a variable in an instrument we need to have an instance handle of some kind. So a mechanism to
manipulate instance handles needs to be added to the API.
5. Accessing the global pool should be easier since it does not depend on any given instance.

So we need to design an API to access the type system, and we should do this in a way that is complete
and without hacks. If it is agreed that we should do this, we can put that on the 7.00 list.
========================
Prof. 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 11 Sep 2017, at 23:57, Rory Walsh <[hidden email]> wrote:
>
> To get around this issue I've simply set the table number. But I agree, it would be nice to be able to use these tables. It doesn't work with Cabbage either. It can be done via the API, but it's a hack. You can parse the Csd for the global table variables. When you have their name you can run Csound in debug mode for a single cycle and grab the value of the global variables. Their order of appearance in the header section plus 100 will give you the table number. I always thought it would be nice to have an API function to query the value of any variable at any given time, but I don't think it's possible without serious restructuring. Perhaps this is why use channels instead!
>
> On 11 September 2017 at 19:58, jpff <[hidden email]> wrote:
> As far as I can tell you could search in a loop as GetTable returns -1 for a nonexistent table, or you could use a channel to transmit gisine.  It might be nice to know maxfnum (largest table number) but I think it is not available
>
> On Mon, 11 Sep 2017, Francesco Porta wrote:
>
> Thanks Rory,
> but i do not understand (as usual :)).
> I am doing this:
> 1 retrieve the fgen number reading a csd as text
> 2 retrieve length and values using
>
>    cs:TableLength(numeroTavola)
>    for i=1, length do
>         value = cs:TableGet(numeroTavola, i)
>    end
>
> this is working ok. But what if i have an orchestra ftgen with automatic number assigned,
> i.e. something like gisine ftgen 0, 0, 1024, 10, 1?
> How can i retreive the assigned number?
>
>
> Csound mailing list
> [hidden email]
> 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 [hidden email] 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
[hidden email]
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 [hidden email] 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