Csound Csound-dev Csound-tekno Search About

Python api [was Re: [Csnd] Re: CPU Resources Question]

Date2012-08-19 20:57
Frompeiman khosravi
SubjectPython api [was Re: [Csnd] Re: CPU Resources Question]
OK so I managed to solve that issue by running it from inside winXound. No idea why that works and not running from the terminal.

BUT I now get this error:

new alloc for instr 100:
Tcl_ServiceModeHook: Notifier not initialized
Csound tidy up: Abort trap
------- Compiler Ended -------


Shouldn't this stuff be running straight out of the box? ;-)
 
cheers,
Peiman

On 19 August 2012 20:44, peiman khosravi <peimankhosravi@gmail.com> wrote:
I see. Shouldn't that be installed by default when installing csound?

Maybe I'm using the wrong version of python?

P

On 19 August 2012 20:42, zappfinger <zappfinger@gmail.com> wrote:
Ok, I see it now. Yes, you do need the csnd library, that is your link to the
API.
I think it came with my version of Csound (5.14)

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/CPU-Resources-Question-tp5714969p5715006.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"




Date2012-08-19 21:27
Fromzappfinger
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
it has to do with versions of Python and Csound. I have been struggeling with
this for a while.
My csnd.py is in site-packages of python2.7.
I am on OS X 10.5.8, which means I cannot use it with a Csound version
higher than 5.14.

BTW, does any of the samples work, like shapes.py? 

Maybe there should be a compatibility matrix for versions of Csound, OS's,
Python, etc.



Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715011.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-08-19 21:46
Frompeiman khosravi
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]


On 19 August 2012 21:27, zappfinger <zappfinger@gmail.com> wrote:
it has to do with versions of Python and Csound. I have been struggeling with
this for a while.
My csnd.py is in site-packages of python2.7.
I am on OS X 10.5.8, which means I cannot use it with a Csound version
higher than 5.14.

I tried both python 2.6 and 2.7 to no avail. But it works from inside winXound. Can't say why. 
 
BTW, does any of the samples work, like shapes.py?

I haven't got time now but I will try these and let you know. 

Maybe there should be a compatibility matrix for versions of Csound, OS's,
Python, etc.

yes! A test script or something would be very helpful.

Best,
Peiman


Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715011.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"



Date2012-08-20 10:00
Frompeiman khosravi
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi Richard,

BTW you've converted me to python GUI!! Thanks for this example. Seems like the way forward.

Best,
Peiman

On 19 August 2012 21:46, peiman khosravi <peimankhosravi@gmail.com> wrote:


On 19 August 2012 21:27, zappfinger <zappfinger@gmail.com> wrote:
it has to do with versions of Python and Csound. I have been struggeling with
this for a while.
My csnd.py is in site-packages of python2.7.
I am on OS X 10.5.8, which means I cannot use it with a Csound version
higher than 5.14.

I tried both python 2.6 and 2.7 to no avail. But it works from inside winXound. Can't say why. 
 
BTW, does any of the samples work, like shapes.py?

I haven't got time now but I will try these and let you know. 

Maybe there should be a compatibility matrix for versions of Csound, OS's,
Python, etc.

yes! A test script or something would be very helpful.

Best,
Peiman


Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715011.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"




Date2012-08-20 10:27
Fromzappfinger
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi Peiman,

Nice to hear!

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-08-20 14:13
Frompeiman khosravi
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Do you know if there is a method for overwriting table indices in python?

One could easily make a loop to overwrite a whole table at run time. Would be very powerful indeed.

Best,
Peiman

On 20 August 2012 10:27, zappfinger <zappfinger@gmail.com> wrote:
Hi Peiman,

Nice to hear!

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"



Date2012-08-20 16:38
FromPINOT Francois
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi Peiman,

if you mean overwriting values into a function table that was created within csound,  you can do it this way:

tbl = csnd.CsoundMYFLTArray()        # create an empty CsoundMYFLTArray object
tblSize = cs.GetTable(tbl.GetPtr(), n)   # make our object point to ftable n data
                                                            #  and return ftable n size
tblArray = csnd.doubleArray_frompointer(tbl.GetPtr(0)) # create a python array
                                                                                         # pointing to ftable n data

(or tblArray = csnd.floatArray_frompointer(tbl.GetPtr(0)) if you're using a float version of Csound).

Then you can use tblArray with bracket indices for reading and for writing as well.

You can even do some more sophisticated manipulations (slicing, matrix algebra, ...) using the numpy module, as described in my Csound Journal paper:

http://www.csounds.com/journal/issue14/realtimeCsoundPython.html

Regards

Francois


Le 20/08/2012 15:13, peiman khosravi a écrit :
Do you know if there is a method for overwriting table indices in python?

One could easily make a loop to overwrite a whole table at run time. Would be very powerful indeed.

Best,
Peiman

On 20 August 2012 10:27, zappfinger <zappfinger@gmail.com> wrote:
Hi Peiman,

Nice to hear!

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"




Date2012-08-20 17:48
FromAndres Cabrera
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi,

You just have to be careful not to do this from a separate thread, as
these operations are not thread safe. You will usually do them between
calls to csoundPerform.

Cheers,
Andrés

On 8/20/12, PINOT Francois  wrote:
> Hi Peiman,
>
> if you mean overwriting values into a function table that was created
> within csound,  you can do it this way:
>
> tbl = csnd.CsoundMYFLTArray()        # create an empty CsoundMYFLTArray
> object
> tblSize = cs.GetTable(tbl.GetPtr(), n)   # make our object point to
> ftable n data
>                                                              #  and
> return ftable n size
> tblArray = csnd.doubleArray_frompointer(tbl.GetPtr(0)) # create a python
> array
>                       # pointing to ftable n data
>
> (or tblArray = csnd.floatArray_frompointer(tbl.GetPtr(0)) if you're
> using a float version of Csound).
>
> Then you can use tblArray with bracket indices for reading and for
> writing as well.
>
> You can even do some more sophisticated manipulations (slicing, matrix
> algebra, ...) using the numpy module, as described in my Csound Journal
> paper:
>
> http://www.csounds.com/journal/issue14/realtimeCsoundPython.html
>
> Regards
>
> Francois
>
>
> Le 20/08/2012 15:13, peiman khosravi a écrit :
>> Do you know if there is a method for overwriting table indices in python?
>>
>> One could easily make a loop to overwrite a whole table at run time.
>> Would be very powerful indeed.
>>
>> Best,
>> Peiman
>>
>> On 20 August 2012 10:27, zappfinger > > wrote:
>>
>>     Hi Peiman,
>>
>>     Nice to hear!
>>
>>     Richard
>>
>>
>>
>>     --
>>     View this message in context:
>>
>> http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
>>     Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>>     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"
>
>


-- 


Andrés


Date2012-08-20 18:26
Frompeiman khosravi
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi Francois,

Very nice indeed. Soon I'll be able to make my own python interfaces (and not only GUI). Thanks very much.

Best,
Peiman

On 20 August 2012 16:38, PINOT Francois <fggpinot@gmail.com> wrote:
Hi Peiman,

if you mean overwriting values into a function table that was created within csound,  you can do it this way:

tbl = csnd.CsoundMYFLTArray()        # create an empty CsoundMYFLTArray object
tblSize = cs.GetTable(tbl.GetPtr(), n)   # make our object point to ftable n data
                                                            #  and return ftable n size
tblArray = csnd.doubleArray_frompointer(tbl.GetPtr(0)) # create a python array
                                                                                         # pointing to ftable n data

(or tblArray = csnd.floatArray_frompointer(tbl.GetPtr(0)) if you're using a float version of Csound).

Then you can use tblArray with bracket indices for reading and for writing as well.

You can even do some more sophisticated manipulations (slicing, matrix algebra, ...) using the numpy module, as described in my Csound Journal paper:

http://www.csounds.com/journal/issue14/realtimeCsoundPython.html

Regards

Francois


Le 20/08/2012 15:13, peiman khosravi a écrit :
Do you know if there is a method for overwriting table indices in python?

One could easily make a loop to overwrite a whole table at run time. Would be very powerful indeed.

Best,
Peiman

On 20 August 2012 10:27, zappfinger <zappfinger@gmail.com> wrote:
Hi Peiman,

Nice to hear!

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"





Date2012-08-20 18:30
Frompeiman khosravi
SubjectRe: Python api [was Re: [Csnd] Re: CPU Resources Question]
Hi Andrés,

Thanks for the warning. I've never tried the api inside python so I don't even really know how to create a thread and so on yet! I'm sure your suggestion will become clear to me once I get into it. I must say, having started to learn python, I absolutely love it. Certainly better than SC!

Best,
Peiman 


On 20 August 2012 17:48, Andres Cabrera <mantaraya36@gmail.com> wrote:
Hi,

You just have to be careful not to do this from a separate thread, as
these operations are not thread safe. You will usually do them between
calls to csoundPerform.

Cheers,
Andrés

On 8/20/12, PINOT Francois <fggpinot@gmail.com> wrote:
> Hi Peiman,
>
> if you mean overwriting values into a function table that was created
> within csound,  you can do it this way:
>
> tbl = csnd.CsoundMYFLTArray()        # create an empty CsoundMYFLTArray
> object
> tblSize = cs.GetTable(tbl.GetPtr(), n)   # make our object point to
> ftable n data
>                                                              #  and
> return ftable n size
> tblArray = csnd.doubleArray_frompointer(tbl.GetPtr(0)) # create a python
> array
>                       # pointing to ftable n data
>
> (or tblArray = csnd.floatArray_frompointer(tbl.GetPtr(0)) if you're
> using a float version of Csound).
>
> Then you can use tblArray with bracket indices for reading and for
> writing as well.
>
> You can even do some more sophisticated manipulations (slicing, matrix
> algebra, ...) using the numpy module, as described in my Csound Journal
> paper:
>
> http://www.csounds.com/journal/issue14/realtimeCsoundPython.html
>
> Regards
>
> Francois
>
>
> Le 20/08/2012 15:13, peiman khosravi a écrit :
>> Do you know if there is a method for overwriting table indices in python?
>>
>> One could easily make a loop to overwrite a whole table at run time.
>> Would be very powerful indeed.
>>
>> Best,
>> Peiman
>>
>> On 20 August 2012 10:27, zappfinger <zappfinger@gmail.com
>> <mailto:zappfinger@gmail.com>> wrote:
>>
>>     Hi Peiman,
>>
>>     Nice to hear!
>>
>>     Richard
>>
>>
>>
>>     --
>>     View this message in context:
>>
>> http://csound.1045644.n5.nabble.com/Python-api-was-Re-Csnd-Re-CPU-Resources-Question-tp5715008p5715018.html
>>     Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>>     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
>>     <mailto: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"
>
>


--


Andrés


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"