Csound Csound-dev Csound-tekno Search About

[Csnd] python opcodes and table access

Date2011-06-07 14:20
Frompeiman khosravi
Subject[Csnd] python opcodes and table access
I am wondering if it is possible to access csound tables directly from 
within a python orchestra block. To, for instance, write table values 
from python arrays and so on.

Otherwise what is the best solution for this problem (?):

I would like to read a text-file that contains x, y pairs and use the 
values to fill csound tables (like GEN17). Naturally I cannot simply 
write the y values at x indexes because this leaves the intervening 
indexes unaltered. Any ideas are welcome.

Best,

Peiman


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2011-06-07 15:04
FromRory Walsh
SubjectRe: [Csnd] python opcodes and table access
There are some table functions in the API that might help?

PUBLIC MYFLT csoundTableGet ( CSOUND *,int  table, int index) 	
Returns the value of a slot in a function table. The table number and
index are assumed to be valid.

PUBLIC int csoundTableLength(CSOUND * ,int  	table	) 	
Returns the length of a function table (not including the guard
point), or -1 if the table does not exist.

PUBLIC void csoundTableSet( CSOUND *,int  table,int  index, MYFLT  value) 		
Sets the value of a slot in a function table. The table number and
index are assumed to be valid.

PUBLIC int csoundGetTable(CSOUND *, MYFLT ** tablePtr, int tableNum) 			
Stores pointer to function table 'tableNum' in *tablePtr, and returns
the table length (not including the guard point). If the table does
not exist, *tablePtr is set to NULL and -1 is returned.

Rory.


On 7 June 2011 14:20, peiman khosravi  wrote:
> I am wondering if it is possible to access csound tables directly from
> within a python orchestra block. To, for instance, write table values from
> python arrays and so on.
>
> Otherwise what is the best solution for this problem (?):
>
> I would like to read a text-file that contains x, y pairs and use the values
> to fill csound tables (like GEN17). Naturally I cannot simply write the y
> values at x indexes because this leaves the intervening indexes unaltered.
> Any ideas are welcome.
>
> Best,
>
> Peiman
>
>
> Send bugs reports to the Sourceforge bug tracker
>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2011-06-07 16:03
FromPINOT Francois
SubjectRe: [Csnd] python opcodes and table access
There are functions in the API to do that. Using the python ctypes 
module, it's easy to get a pointer to a csound table buffer. You can see 
a description of this in my Csound Journal article 
(http://www.csounds.com/journal/issue14/realtimeCsoundPython.html).

In the article, it's described from a python host program. To do this 
from within a python orchestra block, you'll need an opaque pointer to 
the current csound session. This pointer would allow you to call the 
python API functions from within the orchestra.

Actually there's no way to get this opaque pointer. A new python opcode 
could certainly do it. I'll investigate this as soon as I have some free 
time.

Francois


Le 07/06/2011 15:20, peiman khosravi a écrit :
> I am wondering if it is possible to access csound tables directly from 
> within a python orchestra block. To, for instance, write table values 
> from python arrays and so on.
>
> Otherwise what is the best solution for this problem (?):
>
> I would like to read a text-file that contains x, y pairs and use the 
> values to fill csound tables (like GEN17). Naturally I cannot simply 
> write the y values at x indexes because this leaves the intervening 
> indexes unaltered. Any ideas are welcome.
>
> Best,
>
> Peiman
>
>
> Send bugs reports to the Sourceforge bug tracker
> https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body 
> "unsubscribe csound"
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"