Pyo server.boot() fails with pyolib._core.PyoServerStateException on Ubuntu 14.04

老子叫甜甜 提交于 2020-12-23 04:04:58

问题


I installed pyo on Ubuntu 14.04 without jack and running Python 2.7.I followed the Debian-based installing instructions written in pyo wiki. This was the code i used (it's in the pyo introduction page):

from pyo import *
s = Server().boot()
s.start()
a = Sine(mul=0.01).out()

And got as result:

pyo version 0.6.8 (uses single precision)
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
portaudio error in Pa_OpenStream: Invalid number of channels
Portaudio error: Invalid number of channels
Server not booted.
The Server must be booted!
Traceback (most recent call last):
  File "/host/Python/Synth/synther.py", line 4, in <module>
    a = Sine(mul=0.01).out()
  File "/usr/lib/python2.7/dist-packages/pyolib/generators.py", line 58, in __init__
    PyoObject.__init__(self, mul, add)
  File "/usr/lib/python2.7/dist-packages/pyolib/_core.py", line 376, in __init__
    PyoObjectBase.__init__(self)
  File "/usr/lib/python2.7/dist-packages/pyolib/_core.py", line 262, in __init__
    raise PyoServerStateException("The Server must be booted before creating any audio object.")
pyolib._core.PyoServerStateException: The Server must be booted before creating any audio object.

PS: Not interested to using jack, already got problems with it.


回答1:


Got it working on Ubuntu 20.04

After trying several things and a lot of frustration... the following worked:

sudo apt install python3-pyo

and the test:

#/usr/bin/env python3
from pyo import *
s = Server()
s.boot()
s.start()
a = Sine(freq=440, mul=0.5)
a.out()
time.sleep(2)
a.stop()
s.stop()

produces a 2 second 440Hz sine sound as desired. Maybe a reboot was needed.

If program is using the audio when you launch the test, e.g. Chromium playing an YouTube video or VLC playing music, then it fails with that exception, so make sure to pausing/close all such applications.

Another thing worth doing is:

sudo apt install python3-wxgtk4.0

otherwise pyo keeps warning about the missing wxWidgets every single time. I don't think it makes the run fail however.

The above sudo apt install python3-pyo install pyo 1.0.0, and all the binary dependencies it needs to work, the dependency given by:

apt-cache depends python3-pyo

is:

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

Now, I if I try to upgrade pyo with:

python -m pip instal --user pyo==1.0.X

which takes precedence over the distro provided 1.0.0, I get the following results:

  • 1.0.0: works

  • 1.0.1: works

  • 1.0.2: blows up with an error:

    ALSA lib conf.c:3558:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so (/usr/lib/alsa-lib/libasound_module_conf_pulse.so: libasound_module_conf_pulse.so: cannot open shared object file: No such file or directory)
    

    But then I locate libasound_module_conf_pulse.so on my system, and work around with:

    sudo ln -s /usr/lib/x86_64-linux-gnu/alsa-lib /usr/lib/alsa-lib
    

    and then it works.

    I also reported this at: https://github.com/belangeo/pyo/issues/200

  • 1.0.3: same

Another thing worth trying is from Playing sound in pyo and python:

from pyo import *
print("Default input device: %i" % pa_get_default_input())
print("Default output device: %i" % pa_get_default_output())
print("Audio host APIS:")
pa_list_host_apis()
pa_list_devices()

and then try to select a specific device with:

s = Server()
s.setOutputDevice(0)
s.boot()

But I didn't need to do that to get it working after installing python3-pyo.

https://github.com/belangeo/pyo/issues/200#issuecomment-734958205 explains how to get it all working with Jack.



来源:https://stackoverflow.com/questions/32445375/pyo-server-boot-fails-with-pyolib-core-pyoserverstateexception-on-ubuntu-14-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!