Closed cirosantilli closed 3 years ago
Hello @cirosantilli , I recently switched to Ubuntu 20.04 and I am also experiencing troubles getting sound out of Pyo.
First, if you haven't already, install wxPython with pip or pip3 (I also had to install SDL2 on my system).
Next, you can use something like this to find a working output device:
import time
from pyo import *
devices = pa_count_devices()
for i in range(devices):
s = Server()
s.setOutputDevice(i)
try:
s.boot().start()
print("Trying device #" + str(i))
a = Sine(freq = 440, mul = 0.5)
a.out()
time.sleep(2)
a.stop()
s.stop()
except:
pass
Unfortunately, it appears that Pyo won't produce any sound as soon as another sound emitting program is running, which bothers me as I have to have speechd open.
I have not yet been able to output stereo either.
@belangeo Are you doing something special with ALSA, or is it broken on Ubuntu 20.04?
Apart from that, yes Pyo can be used to manually compose music pieces, that's what I was trying to do on Windows (where the setup was simpler).
Not sure why you would need to symlink alsa-lib... Maybe Ubuntu moved it in 20.04 (on debian, it's still /usr/lib/x86_64-linux-gnu/alsa-lib. I'll have to install ubuntu to sort it out.
As for the multi-client, your best shot is clearly Jack!
@DataTriny @belangeo thanks for your suggestions.
Just to clarify, I'm a complete audio newbie, and was just having a look at a bunch of possibilities to have some fun with algorithmic composition, and since Python's my favorite scripting language, I naturally Googled into this. As a result, I might be doing very stupid things :-) I have also tried several things, so maybe system state changed.
Anyways, at last, I was able to get some sound out of pyo on Ubuntu 20.04.
First, without the symlink sudo ln -s /usr/lib/x86_64-linux-gnu/alsa-lib /usr/lib/alsa-lib
(note that this creates /usr/lib/alsa-lib
, /usr/lib/x86_64-linux-gnu/alsa-lib
is the default one present), the following worked:
sudo apt install python3-pyo
and:
from pyo import *
s = Server().boot()
s.start()
a = Sine(freq = 440, mul = 0.5)
a.out()
time.sleep(2)
a.stop()
s.stop()
Part of the problem is that the first example from http://ajaxsoundstudio.com/pyodoc/gettingstarted.html does not have the sleep
and I was not sure if that was needed or not (thanks to DataTriny for pointing that out), and highly recommend patching it in that example, including one on the README.md maybe (and remove the >>>
from the code blocks so that people can just copy paste those ;-)).
Now, sudo apt install python3-pyo
installs pyo 1.0.0, and some dependencies without which things blow up, dep list is:
apt-cache depends python3-pyo
python3-pyo
Depends: libc6
|Depends: libjack-jackd2-0
Depends: <libjack-0.125>
libjack-jackd2-0
libjack0
Depends: liblo7
Depends: libportaudio2
Depends: libportmidi0
Depends: libsndfile1
Depends: python3
Depends: python3
Depends: <python3:any>
python3:i386
python3
Recommends: python3-tk
Recommends: jackd2
OK, with that still installed, I then also installed with:
pip install --user pyo==1.0.X
to see if there was a problem with newer versions, and the results are as follows:
(@DataTriny BTW, when I tried your approach under certain configurations, it pyo segfaulted due to some C assert, so the loop stops before going through all devices. Gotta do a shell while loop instead I guess :-) But once I fixed the above things, the default device started working, so I don't have to worry about that for the moment)
Hello @cirosantilli ,
Glad you made some progress. Please note that:
your_server.gui(locals())
(using time.sleep
was just more practical in that particular case),I ended up installing jack and it works great! Here's what I did:
sudo apt-get install jackd pavucontrol qjackctl pulseaudio-module-jack
,pactl load-module module-jack-sink && pactl load-module module-jack-source && pactl set-default-sink jack_out && pacmd set-default-source jack_in && pacmd list-sink-inputs | grep index | sed 's/ *index: *//g' | xargs -I{} pacmd move-sink-input "{}" jack_out
,pacmd suspend false
,Now when you create a Pyo server object, initialize it like so:
s = Server(audio = "jack")
s.boot().start()
And you should be good to go!
Don't forget to uninstall python-pyo with apt.
Hope it helps.
Regards.
Fixed in version 1.0.4.
pyo 1.0.3 installed with pip3 install, I try to run the hello world from http://ajaxsoundstudio.com/pyodoc/gettingstarted.html
So first that was failing with:
One thing that solved that was:
but although the exception is gone, I still have no sound played, logs:
Any clues?
My goal is to compose some music for fun manually note by note from a script, hopefully with a few instruments/beats. Is this the right software, or do you know anything that would make that easier? :-)