Olivier (pyo's dev) responded offlist while I was busy writing a reply. I'm posting what he has to say here for the benefit of the list.
For those interested (and to avoid hijacking pd-land), there is a pyo mailing list here: http://groups.google.com/group/pyo-discuss
Pyo radio will be back up and running today for those who wondered.
Cheers, jm
------Olivier's answer-----------
Hi Yvan,
Thanks for trying the pyo example!
2011/11/1 yvan volochine yvan.pd@gmail.com
On 11/01/2011 04:23 AM, Jean-Michel Dumas wrote:
It's great to see pyo make an appearance in this discussion. For completion's sake, here's the "128 sine waves with random freq mixed down to stereo" example written in pyo. I find it much more readable than either SC or cSound, but that's only a matter of taste i guess.
Sine([random.uniform(20,20000) for i in range(128)]).mix(2)
A Csound example would use 128 lines or some simili-loop opcode. The best way should be to script Csound from python or lua...!
indeed, pyo looks really cool, kudos ;)
a couple of remarks with your example though. my sc example description was not 100% accurate: the random freqs have exponential distribution (ExpRand) and Splay does the stereo mix down but with a level compensation (equal power) so you don't blow up your ears/pa like in the above pyo example :p
That's the cool thing with a pure python module, you can use any function in the random module... To be more like you SC example, the line should be:
a = Sine([100 * random.expovariate(0.5) for i in range(128)], mul=1./128).mix(2).out()
also, running this pyo line uses 25% of my Core Duo 1.83 while sc example uses 15% (and I'm not running excellent Tim Blechmann's multicore-aware sound server supernova, just default scsynth)
No doubt, SC is the best audio engine regarding CPU usage... With pyo, there is an overhead to deal with the Python Global Interpreter Lock (GIL). It makes python very safe but take some times to acquire and release before and after the audio callback. In the case of playing a bunch of oscillators, I would probably use OscBank which can compute hundreds of oscillators in a single loop, very efficient!
BTW, (getting a bit OT here) I have some questions about pyo. is there a way to use double precision ?
from pyo64 import *
$ >>> from pyo import * $ pyo version 0.5.0 (uses single precision)
for the Server to boot properly, I have to start jackd, then Server().boot() gives me an Error with PortAudio incorrect channels number (???), stop jackd, and then Server boots fine.. it seems also that it segfaults easily.. no time right now but I'll make more tests some time...
jack and portaudio don't really like each other! Portaudio won't initialize if jack is started. You can use pyo with jack by setting the Server's host:
s = Server(host="jack").boot()
Cheers,
Olivier
cheers, _y
-- yvan.volochine@gmail.com http://yvanvolochine.com