Csound Csound-dev Csound-tekno Search About

[Cs-dev] table reading api function question

Date2005-10-08 08:47
FromIain Duncan
Subject[Cs-dev] table reading api function question
Can the api functions that to table reading and writing use csound table 
names made by an ftgen call? ie csoundgi_mytable

Thanks


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-10-08 10:21
FromIstvan Varga
SubjectRe: [Cs-dev] table reading api function question
Iain Duncan wrote:

> Can the api functions that to table reading and writing use csound table 
> names made by an ftgen call? ie csoundgi_mytable

Do you mean getting the table number of automatically allocated tables
like this one ?

gi_mytable  ftgen 0, 0, 16384, 10, 1

Currently, one possible solution is to "export" the variable so that
it can be accessed by the host as a channel of the bus, by adding
this to the orchestra header:

gi_mytable  chnexport "MyTableNumber", 2

The host can now call the following function after csoundCompile()
to get a pointer to gi_mytable:

MYFLT *gi_mytable;
csoundGetChannelPtr(csound, &gi_mytable, "MyTableNumber",
                     CSOUND_CONTROL_CHANNEL | CSOUND_OUTPUT_CHANNEL);

Then, assuming that there was no error, gi_mytable will point to the
actual orchestra variable, and its value can be read:

int   tablenum = (int) *gi_mytable;
MYFLT *tableptr;
int   table_length;
tableptr = csoundGetTable(csound, tablenum, &table_length);
printf("ftable[%d][0] = %f\n", tablenum, tableptr[0]);
printf("ftable[%d][1] = %f\n", tablenum, tableptr[1]);

Of course, any other global variable of type i, k, a, or S can be
exported this way, not just table numbers, for direct access by the
host.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net