Csound Csound-dev Csound-tekno Search About

Re: varga csound5 python opcodes

Date2005-10-13 14:59
FromMichael Gogins
SubjectRe: varga csound5 python opcodes
Same thread.

Regards,
Mike

-----Original Message-----
From: Oeyvind Brandtsegg 
Sent: Oct 13, 2005 6:34 AM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] varga csound5 python opcodes

Yes, it would be very nice to be able to use the python opcodes independently of csoundVST. I'm currently experimenting with a new particle synthesis plugin written by Thom Johansen and Torgeir Strand Henriksen (to be released as soon as we decide on a final parameter input configuration). The plugin does for some reason segfault with the gogins binary, but works fine with the varga binary.

While I'm at it:
When I call a python function from csound, does csound wait for python to return from this function, or are the python function executed sort of in it's own thread.

Oeyvind




> From: Istvan Varga [istvan_v@fibermail.hu]
> Sent: 2005-10-13 10:51:56 CEST
> To: csound@lists.bath.ac.uk
> Subject: Re: [Csnd] varga csound5 python opcodes
> 
> Oeyvind Brandtsegg wrote:
> 
> > I notced that the python related opcodes does not appear to work with
>  > Istvan Varga's latest precompiled binary of csound5 (csound5-2005-08-27).
> > Is it possible to use the python related opcodes with this version ?
> 
> The python opcodes have dependencies on CsoundVST (no idea why),
> so I did not include them. I do have plans to change the opcodes
> to allow for building separately, and then the next release could
> include them. Until then, you may try using the Gogins release;
> it should be noted, though, that it is older and does not include
> any single precision binaries.
> 
> > And, will it be possible with the upcoming canonical release ?
> 
> Not sure about that, although it does not seem like any canonical
> release is going to happen this year. Maybe the next summer, but I
> would not bet on that either.
> -- 
> Send bugs reports to this list.
> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> 


Date2005-10-13 16:47
FromDave Phillips
SubjectCsoundVST problem
Greetings:

  I've successfully built and installed Cs5 from CVS sources on 
AGNULA/Demudi 1.2.1. GCC is 3.3.5, all other required packages are up to 
date and correctly installed.

  The csound binary works fine, realtime appears to be working perfectly 
in my very brief tests, but CsoundVST won't start. It complains :

    CsoundVST: error while loading shared libraries: _CsoundVST.so: 
cannot open shared object file: Error 40

  Any suggestions ? My PYTHONPATH includes /usr/local/lib, where the 
file resides.

Best,

dp


 

Date2005-10-13 17:24
FromOeyvind Brandtsegg
SubjectRe: varga csound5 python opcodes
Thanks. 
I'm wondering about the best place to put a clock for generating precise rhythms, when woring with Python and Csound in realtime.

I started implementing the clock in python, as some of my algorithms in python will generate rhythm data. But then I realized that python does not seem to have rock solid timing (understatement), maybe it's better with the pygame timer but I certainly could not use Python's time module.
Now, I've implemented a clock and rhythmic trigger in csound, calling python for data (data that e.g. determines the delta time until the next rhythm trigger should happen).
Since csound maybe will wait for python to return the value, I wonder if this is a bad way to design a stable clock for rhythm generation. Also, if the python process is complicated (takes a long time to compute), will this create discontinuities in Csound's audio output ?
If my current approach does not work well, the next thing I'd try is to just send a query (via OSC or otherwise) from the csound clock to a python function, asking for the next timing value. The return value would then be a "timestamp", hopefully returning to csound before it's activation time (or the event would have to be discarded).
If anyone has ideas on how to implement a stable clock for realtime algorithmic composition, or views on my approach as described above, I'm most grateful for input on this.

Oeyvind





> From: Michael Gogins [gogins@pipeline.com]
> 
> Same thread.
> 
> 
> -----Original Message-----
> From: Oeyvind Brandtsegg 
> 
> While I'm at it:
> When I call a python function from csound, does csound wait for python to return from this function, or are the python function executed sort of in it's own thread.
> 

Date2005-10-13 23:29
FromMartin Peach
SubjectRe: varga csound5 python opcodes
Oeyvind Brandtsegg wrote:

>Thanks. 
>I'm wondering about the best place to put a clock for generating precise rhythms, when woring with Python and Csound in realtime.
>
>I started implementing the clock in python, as some of my algorithms in python will generate rhythm data. But then I realized that python does not seem to have rock solid timing (understatement), maybe it's better with the pygame timer but I certainly could not use Python's time module.
>Now, I've implemented a clock and rhythmic trigger in csound, calling python for data (data that e.g. determines the delta time until the next rhythm trigger should happen).
>Since csound maybe will wait for python to return the value, I wonder if this is a bad way to design a stable clock for rhythm generation. Also, if the python process is complicated (takes a long time to compute), will this create discontinuities in Csound's audio output ?
>If my current approach does not work well, the next thing I'd try is to just send a query (via OSC or otherwise) from the csound clock to a python function, asking for the next timing value. The return value would then be a "timestamp", hopefully returning to csound before it's activation time (or the event would have to be discarded).
>If anyone has ideas on how to implement a stable clock for realtime algorithmic composition, or views on my approach as described above, I'm most grateful for input on this.
>  
>
Pure Data has both python and csound externals available. In pd you can 
build rock-steady timing objects that can trigger arbitrary events in 
csound or python.

Martin

Date2005-10-14 01:15
FromIain Duncan
SubjectRe: varga csound5 python opcodes
I think that should be really easy if you use a python host with csound 
embedded as the audio engine. You could call csound in csoundperforming 
loop and just check for the clock value. If you look at the example I 
posted of the C api, you can see multi threads with one holding csound. 
I think it would be easy to add a check on a clock value there, and 
trigger whatever you need in other parts of the program to run accordingly.

Iain

Oeyvind Brandtsegg wrote:
> Thanks. 
> I'm wondering about the best place to put a clock for generating precise rhythms, when woring with Python and Csound in realtime.
> 
> I started implementing the clock in python, as some of my algorithms in python will generate rhythm data. But then I realized that python does not seem to have rock solid timing (understatement), maybe it's better with the pygame timer but I certainly could not use Python's time module.
> Now, I've implemented a clock and rhythmic trigger in csound, calling python for data (data that e.g. determines the delta time until the next rhythm trigger should happen).
> Since csound maybe will wait for python to return the value, I wonder if this is a bad way to design a stable clock for rhythm generation. Also, if the python process is complicated (takes a long time to compute), will this create discontinuities in Csound's audio output ?
> If my current approach does not work well, the next thing I'd try is to just send a query (via OSC or otherwise) from the csound clock to a python function, asking for the next timing value. The return value would then be a "timestamp", hopefully returning to csound before it's activation time (or the event would have to be discarded).
> If anyone has ideas on how to implement a stable clock for realtime algorithmic composition, or views on my approach as described above, I'm most grateful for input on this.
> 
> Oeyvind
> 
> 
> 
> 
> 
> 
>>From: Michael Gogins [gogins@pipeline.com]
>>
>>Same thread.
>>
>>
>>-----Original Message-----
>>From: Oeyvind Brandtsegg 
>>
>>While I'm at it:
>>When I call a python function from csound, does csound wait for python to return from this function, or are the python function executed sort of in it's own thread.
>>

Date2005-10-14 15:57
FromOeyvind Brandtsegg
SubjectRe: timing, was: varga csound5 python opcodes
I would be very grateful if you could elaborate a bit on this approach, as I don't quite get it. Please do forgive if my programming knowledge if full of holes...
I am able to use python as a host for csound, with csound running in it's own thread, and multiple other threads running simultaneously in python. What worries me is that the python time module, and also the Timer subclass of Thread in python does not provide exact timing (stated in the python documentation). Do you suggest that I could poll csound's clock from python ? What happens if python is "busy doing something else" at the critical moment when the clock exceeds the specified time for an event to happen ? Since there are no thread priority (at least I can't find any) in python, I find it hard to ensure that the timing will be correct. I'm sure there must be a way to do it...
Oeyvind





> From: Iain Duncan [iainduncan@telus.net]
> Sent: 2005-10-14 02:15:16 CEST
> To: csound@lists.bath.ac.uk
> Subject: Re: [Csnd] varga csound5 python opcodes
> 
> I think that should be really easy if you use a python host with csound 
> embedded as the audio engine. You could call csound in csoundperforming 
> loop and just check for the clock value. If you look at the example I 
> posted of the C api, you can see multi threads with one holding csound. 
> I think it would be easy to add a check on a clock value there, and 
> trigger whatever you need in other parts of the program to run accordingly.
> 
> Iain
> 
> Oeyvind Brandtsegg wrote:
> > Thanks. 
> > I'm wondering about the best place to put a clock for generating precise rhythms, when woring with Python and Csound in realtime.
> > 
> > I started implementing the clock in python, as some of my algorithms in python will generate rhythm data. But then I realized that python does not seem to have rock solid timing (understatement), maybe it's better with the pygame timer but I certainly could not use Python's time module.
> > Now, I've implemented a clock and rhythmic trigger in csound, calling python for data (data that e.g. determines the delta time until the next rhythm trigger should happen).
> > Since csound maybe will wait for python to return the value, I wonder if this is a bad way to design a stable clock for rhythm generation. Also, if the python process is complicated (takes a long time to compute), will this create discontinuities in Csound's audio output ?
> > If my current approach does not work well, the next thing I'd try is to just send a query (via OSC or otherwise) from the csound clock to a python function, asking for the next timing value. The return value would then be a "timestamp", hopefully returning to csound before it's activation time (or the event would have to be discarded).
> > If anyone has ideas on how to implement a stable clock for realtime algorithmic composition, or views on my approach as described above, I'm most grateful for input on this.
> > 
> > Oeyvind
> > 
> > 
> > 
> > 
> > 
> > 
> >>From: Michael Gogins [gogins@pipeline.com]
> >>
> >>Same thread.
> >>
> >>
> >>-----Original Message-----
> >>From: Oeyvind Brandtsegg 
> >>
> >>While I'm at it:
> >>When I call a python function from csound, does csound wait for python to return from this function, or are the python function executed sort of in it's own thread.
> >>
> -- 
> Send bugs reports to this list.
> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> 

Date2005-10-14 18:48
Fromjlato@mail.utexas.edu
SubjectRe: timing, was: varga csound5 python opcodes
Were you using time.clock() for your timing function?  The python documentation
claims the accuracy is typically within a microsecond (on Windows, or dependent
on the C clock() function otherwise).  Does your experience indicate this is
incorrect?

Unfortunately, I'm not extremely knowledgable about scheduling, so I can't
clarify Iain's comments.
John Lato

Quoting Oeyvind Brandtsegg :

> I would be very grateful if you could elaborate a bit on this approach, as I
> don't quite get it. Please do forgive if my programming knowledge if full of
> holes...
> I am able to use python as a host for csound, with csound running in it's own
> thread, and multiple other threads running simultaneously in python. What
> worries me is that the python time module, and also the Timer subclass of
> Thread in python does not provide exact timing (stated in the python
> documentation). Do you suggest that I could poll csound's clock from python ?
> What happens if python is "busy doing something else" at the critical moment
> when the clock exceeds the specified time for an event to happen ? Since
> there are no thread priority (at least I can't find any) in python, I find it
> hard to ensure that the timing will be correct. I'm sure there must be a way
> to do it...
> Oeyvind
> 
> 
> 
> 
> 
> > From: Iain Duncan [iainduncan@telus.net]
> > Sent: 2005-10-14 02:15:16 CEST
> > To: csound@lists.bath.ac.uk
> > Subject: Re: [Csnd] varga csound5 python opcodes
> > 
> > I think that should be really easy if you use a python host with csound 
> > embedded as the audio engine. You could call csound in csoundperforming 
> > loop and just check for the clock value. If you look at the example I 
> > posted of the C api, you can see multi threads with one holding csound. 
> > I think it would be easy to add a check on a clock value there, and 
> > trigger whatever you need in other parts of the program to run
> accordingly.
> > 
> > Iain
> > 
> > Oeyvind Brandtsegg wrote:
> > > Thanks. 
> > > I'm wondering about the best place to put a clock for generating precise
> rhythms, when woring with Python and Csound in realtime.
> > > 
> > > I started implementing the clock in python, as some of my algorithms in
> python will generate rhythm data. But then I realized that python does not
> seem to have rock solid timing (understatement), maybe it's better with the
> pygame timer but I certainly could not use Python's time module.
> > > Now, I've implemented a clock and rhythmic trigger in csound, calling
> python for data (data that e.g. determines the delta time until the next
> rhythm trigger should happen).
> > > Since csound maybe will wait for python to return the value, I wonder if
> this is a bad way to design a stable clock for rhythm generation. Also, if
> the python process is complicated (takes a long time to compute), will this
> create discontinuities in Csound's audio output ?
> > > If my current approach does not work well, the next thing I'd try is to
> just send a query (via OSC or otherwise) from the csound clock to a python
> function, asking for the next timing value. The return value would then be a
> "timestamp", hopefully returning to csound before it's activation time (or
> the event would have to be discarded).
> > > If anyone has ideas on how to implement a stable clock for realtime
> algorithmic composition, or views on my approach as described above, I'm most
> grateful for input on this.
> > > 
> > > Oeyvind
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > >>From: Michael Gogins [gogins@pipeline.com]
> > >>
> > >>Same thread.
> > >>
> > >>
> > >>-----Original Message-----
> > >>From: Oeyvind Brandtsegg 
> > >>
> > >>While I'm at it:
> > >>When I call a python function from csound, does csound wait for python to
> return from this function, or are the python function executed sort of in
> it's own thread.
> > >>
> > -- 
> > Send bugs reports to this list.
> > To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> > 
> 


Date2005-10-14 19:36
FromIain Duncan
SubjectRe: timing, was: varga csound5 python opcodes
Oeyvind Brandtsegg wrote:
> I would be very grateful if you could elaborate a bit on this approach, as I don't quite get it. Please do forgive if my programming knowledge if full of holes...
> I am able to use python as a host for csound, with csound running in it's own thread, and multiple other threads running simultaneously in python. What worries me is that the python time module, and also the Timer subclass of Thread in python does not provide exact timing (stated in the python documentation). Do you suggest that I could poll csound's clock from python ? What happens if python is "busy doing something else" at the critical moment when the clock exceeds the specified time for an event to happen ? Since there are no thread priority (at least I can't find any) in python, I find it hard to ensure that the timing will be correct. I'm sure there must be a way to do it...
> Oeyvind

I dunno for python, but for C I would do the following:

Our timing doesn't have to be more accurate than krate, 'cause, well, 
it's the krate. Any krate controls are limited to that accuracy. So if 
in csound we generate a krate control clock, we can indicate a tick 
easily enough by writing a krate variable or writing to a table for one 
kpass, or spawning a note that holds a value for one kpass, etc. If in 
our host we a csound thread and then other threads doing other stuff we 
can use the loop in C:

while ( cs_performing )
{
     cs_performing = csoundPerformKsmps( csound );

     // do other api calls here, many api functions would do the job
     clock_tick = csoundTableGet( csound, clocktable, clockindx );

     if ( clock_tick )
     {
     // signal other threads somehow that we are on a clock tick
     // or do whatever needs to be done on a clock tick here
     }

     // do whatever else needs to be done with csound on a kpass here
}

If we *needed* higher than krate accuracy, the above could be redone 
with the arate audio processing api calls, but I haven't tackled those 
yet so I can't be much use in the way of examples.

Hope that helps,
Iain

Date2005-10-17 11:15
FromOeyvind Brandtsegg
SubjectRe: timing, was: varga csound5 python opcodes
I used time.sleep() at the time I tried it. When running multiple threads, time.sleep() allowed other threads to take over,  but I realize this in not the best way to do it as time.sleep() could take longer than the specified time because of other scheduled activity in the system.

Oeyvind




> From: jlato@mail.utexas.edu
> Sent: 2005-10-14 19:48:20 CEST
> To: csound@lists.bath.ac.uk
> Subject: Re: [Csnd] timing, was: varga csound5 python opcodes
> 
> Were you using time.clock() for your timing function?  The python documentation
> claims the accuracy is typically within a microsecond (on Windows, or dependent
> on the C clock() function otherwise).  Does your experience indicate this is
> incorrect?
> 
> Unfortunately, I'm not extremely knowledgable about scheduling, so I can't
> clarify Iain's comments.
> John Lato
> 
> Quoting Oeyvind Brandtsegg :
> 
> > I would be very grateful if you could elaborate a bit on this approach, as I
> > don't quite get it. Please do forgive if my programming knowledge if full of
> > holes...
> > I am able to use python as a host for csound, with csound running in it's own
> > thread, and multiple other threads running simultaneously in python. What
> > worries me is that the python time module, and also the Timer subclass of
> > Thread in python does not provide exact timing (stated in the python
> > documentation). Do you suggest that I could poll csound's clock from python ?
> > What happens if python is "busy doing something else" at the critical moment
> > when the clock exceeds the specified time for an event to happen ? Since
> > there are no thread priority (at least I can't find any) in python, I find it
> > hard to ensure that the timing will be correct. I'm sure there must be a way
> > to do it...
> > Oeyvind
> > 
> > 
> > 
> > 
> > 
> > > From: Iain Duncan [iainduncan@telus.net]
> > > Sent: 2005-10-14 02:15:16 CEST
> > > To: csound@lists.bath.ac.uk
> > > Subject: Re: [Csnd] varga csound5 python opcodes
> > > 
> > > I think that should be really easy if you use a python host with csound 
> > > embedded as the audio engine. You could call csound in csoundperforming 
> > > loop and just check for the clock value. If you look at the example I 
> > > posted of the C api, you can see multi threads with one holding csound. 
> > > I think it would be easy to add a check on a clock value there, and 
> > > trigger whatever you need in other parts of the program to run
> > accordingly.
> > > 
> > > Iain
> > > 
> > > Oeyvind Brandtsegg wrote:
> > > > Thanks. 
> > > > I'm wondering about the best place to put a clock for generating precise
> > rhythms, when woring with Python and Csound in realtime.
> > > > 
> > > > I started implementing the clock in python, as some of my algorithms in
> > python will generate rhythm data. But then I realized that python does not
> > seem to have rock solid timing (understatement), maybe it's better with the
> > pygame timer but I certainly could not use Python's time module.
> > > > Now, I've implemented a clock and rhythmic trigger in csound, calling
> > python for data (data that e.g. determines the delta time until the next
> > rhythm trigger should happen).
> > > > Since csound maybe will wait for python to return the value, I wonder if
> > this is a bad way to design a stable clock for rhythm generation. Also, if
> > the python process is complicated (takes a long time to compute), will this
> > create discontinuities in Csound's audio output ?
> > > > If my current approach does not work well, the next thing I'd try is to
> > just send a query (via OSC or otherwise) from the csound clock to a python
> > function, asking for the next timing value. The return value would then be a
> > "timestamp", hopefully returning to csound before it's activation time (or
> > the event would have to be discarded).
> > > > If anyone has ideas on how to implement a stable clock for realtime
> > algorithmic composition, or views on my approach as described above, I'm most
> > grateful for input on this.
> > > > 
> > > > Oeyvind
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > >>From: Michael Gogins [gogins@pipeline.com]
> > > >>
> > > >>Same thread.
> > > >>
> > > >>
> > > >>-----Original Message-----
> > > >>From: Oeyvind Brandtsegg 
> > > >>
> > > >>While I'm at it:
> > > >>When I call a python function from csound, does csound wait for python to
> > return from this function, or are the python function executed sort of in
> > it's own thread.
> > > >>
> > > -- 
> > > Send bugs reports to this list.
> > > To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> > > 
> > 
> 
> 
> 
> -- 
> Send bugs reports to this list.
> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
>