Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Directing computer audio output to LedFx example for Linux #34

Closed
janjagusch opened this issue Jan 16, 2021 · 5 comments · Fixed by #36
Closed

Documentation: Directing computer audio output to LedFx example for Linux #34

janjagusch opened this issue Jan 16, 2021 · 5 comments · Fixed by #36
Labels
documentation Improvements or additions to documentation

Comments

@janjagusch
Copy link
Contributor

janjagusch commented Jan 16, 2021

Hi, thanks for maintaining this package!

I've installed LedFx on my machine running Ubuntu 20.10 and have connected it to a ESP8266 mircocontroller running WLED. Selecting the default audio input (the laptop's builtin microphone), everything works correctly.

Now I'm trying to direct the laptop's audio to LedFX, as instructed in step 3 in the readme. Since there is no example for how to get this to work in Ubuntu, I experimented with this StackExchange answer for piping audio output to mic input using pavucontrol and audacity. However, when trying to start LedFX now, it fails with an error related to pyaudio. Under "Settings" there are now no audio devices listed. The error looks like this:

$ ledfx
Loading configuration file from /home/jan/.ledfx
Started webinterface at http://0.0.0.0:8888
ALSA lib conf.c:3723:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so (libasound_module_conf_pulse.so: libasound_module_conf_pulse.so: cannot open shared object file: No such file or directory)
ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0
ALSA lib pcm_dsnoop.c:642:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_jack.so (libasound_module_pcm_jack.so: libasound_module_pcm_jack.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_jack.so (libasound_module_pcm_jack.so: libasound_module_pcm_jack.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_oss.so (libasound_module_pcm_oss.so: libasound_module_pcm_oss.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_oss.so (libasound_module_pcm_oss.so: libasound_module_pcm_oss.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (libasound_module_pcm_pulse.so: libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (libasound_module_pcm_pulse.so: libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_upmix.so (libasound_module_pcm_upmix.so: libasound_module_pcm_upmix.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_upmix.so (libasound_module_pcm_upmix.so: libasound_module_pcm_upmix.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_vdownmix.so (libasound_module_pcm_vdownmix.so: libasound_module_pcm_vdownmix.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_vdownmix.so (libasound_module_pcm_vdownmix.so: libasound_module_pcm_vdownmix.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_usb_stream.so (libasound_module_pcm_usb_stream.so: libasound_module_pcm_usb_stream.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:340:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_usb_stream.so (libasound_module_pcm_usb_stream.so: libasound_module_pcm_usb_stream.so: cannot open shared object file: No such file or directory)
ALSA lib pcm_dsnoop.c:642:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2813
[2021-01-17 00:18:28] ERROR:ledfx.core:Exception in core event loop: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/core.py", line 97, in async_start
    self.devices.create_from_config(self.config['devices'])
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/devices/__init__.py", line 182, in create_from_config
    self._ledfx.devices.get_device(device['id']).set_effect(effect)
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/devices/__init__.py", line 49, in set_effect
    self._active_effect.activate(self.pixel_count)
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/effects/audio.py", line 496, in activate
    self._ledfx.audio.subscribe(self._audio_data_updated)
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/effects/audio.py", line 126, in subscribe
    self.activate()
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/ledfx/effects/audio.py", line 108, in activate
    stream_callback = self._audio_sample_callback)
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/home/jan/miniconda3/envs/ledfx/lib/python3.7/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9998] Invalid number of channels

There exist several issues, where people suggest to create a virtual line in:

In a related repository, they recommend using jackaudio for creating a virtual audio device. However, nobody really tells you how to do it.

I believe adding more documentation to the readme, explaining how to do it or just pointing you somewhere else would be a huge help for most Linux users here.

I'd be glad to provide any information that's necessary and help in whatever way I can.

Update: Found a "How do I route audio to/from generic ALSA-using applications?" document here. Working through it now.


Here an overview about all installed dependencies:

# packages in environment at /home/jan/miniconda3/envs/ledfx:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
aiohttp                   3.3.2                    pypi_0    pypi
aiohttp-jinja2            1.0.0                    pypi_0    pypi
alsa-lib                  1.2.3                h516909a_0    conda-forge
async-timeout             3.0.1                    pypi_0    pypi
attrs                     20.3.0                   pypi_0    pypi
aubio                     0.4.9            py37h06622b3_5    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2020.12.5            ha878542_0    conda-forge
certifi                   2020.12.5        py37h89c1867_1    conda-forge
chardet                   3.0.4                    pypi_0    pypi
ffmpeg                    4.3.1                hca11adc_2    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gnutls                    3.6.13               h85f3911_1    conda-forge
idna                      2.10                     pypi_0    pypi
jinja2                    2.11.2                   pypi_0    pypi
lame                      3.100             h7f98852_1001    conda-forge
ld_impl_linux-64          2.35.1               hea4e1c9_1    conda-forge
ledfx                     0.7                      pypi_0    pypi
libblas                   3.9.0                7_openblas    conda-forge
libcblas                  3.9.0                7_openblas    conda-forge
libffi                    3.3                  h58526e2_2    conda-forge
libgcc-ng                 9.3.0               h2828fa1_18    conda-forge
libgfortran-ng            9.3.0               hff62375_18    conda-forge
libgfortran5              9.3.0               hff62375_18    conda-forge
libgomp                   9.3.0               h2828fa1_18    conda-forge
liblapack                 3.9.0                7_openblas    conda-forge
libopenblas               0.3.12          pthreads_h4812303_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libstdcxx-ng              9.3.0               h6de172a_18    conda-forge
markupsafe                1.1.1                    pypi_0    pypi
multidict                 4.7.6                    pypi_0    pypi
ncurses                   6.2                  h58526e2_4    conda-forge
nettle                    3.6                  he412f7d_0    conda-forge
numpy                     1.19.5           py37haa41c4c_1    conda-forge
openh264                  2.1.1                h780b84a_0    conda-forge
openssl                   1.1.1i               h7f98852_0    conda-forge
pip                       20.3.3             pyhd8ed1ab_0    conda-forge
portaudio                 19.6.0               h1398938_3    conda-forge
pyaudio                   0.2.11                   pypi_0    pypi
python                    3.7.9           hffdb5ce_0_cpython    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
pyyaml                    5.3.1                    pypi_0    pypi
readline                  8.0                  he28a2e2_2    conda-forge
requests                  2.25.1                   pypi_0    pypi
sacn                      1.3                      pypi_0    pypi
setuptools                49.6.0           py37h89c1867_3    conda-forge
sqlite                    3.34.0               h74cdb3f_0    conda-forge
tk                        8.6.10               h21135ba_1    conda-forge
typing-extensions         3.7.4.3                  pypi_0    pypi
urllib3                   1.26.2                   pypi_0    pypi
voluptuous                0.11.1                   pypi_0    pypi
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
x264                      1!161.3030           h7f98852_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
yarl                      1.6.3                    pypi_0    pypi
zlib                      1.2.11            h516909a_1010    conda-forge
$ pulseaudio --version
pulseaudio 13.99.2

$ audacity --version
Trying to route ALSA through PulseAudio...
Audacity v2.4.2

$ pavucontrol --version
pavucontrol 4.0
@janjagusch janjagusch changed the title Directing computer audio output to LedFx example for Ubuntu Documentation: Directing computer audio output to LedFx example for Ubuntu Jan 17, 2021
@zewelor
Copy link

zewelor commented Jan 17, 2021

One thing to test: use pulse as recording device in ledfx, then in recording tab, it should be possible to set "monitor of ..." as record soruce, for ledfx. Maybe it will be possible to change shown devices filter, in down right corner.

@THATDONFC
Copy link
Contributor

Hey @janjagusch did you use our Linux install script to install LedFx? I noticed you have a conda environment for LedFx. We no longer recommend conda as it ends up creating more issues than it solves. I would start with a fresh install of LedFx using the install script found here.

@janjagusch
Copy link
Contributor Author

Hey @janjagusch did you use our Linux install script to install LedFx? I noticed you have a conda environment for LedFx. We no longer recommend conda as it ends up creating more issues than it solves. I would start with a fresh install of LedFx using the install script found here.

Good point, @THATDONFC! I think I used the installer script first and encountered some issues with adding WLED devices through e131. I assumed that was because the installer uses the development branch, so I decided to go for the latest release instead. I've deleted my conda env and am now using the install script again. I might create a separate issue about not being able to add devices through e131 (at least not on the first try).

@janjagusch
Copy link
Contributor Author

One thing to test: use pulse as recording device in ledfx, then in recording tab, it should be possible to set "monitor of ..." as record soruce, for ledfx. Maybe it will be possible to change shown devices filter, in down right corner.

@zewelor, thanks for the idea - this is working for me! Once you figure it out, it's quite easy. You don't even require Audacity or any additional software besides pavucontrol.

  1. In the LedFx UI, set the current audio input to "pulse".
  2. In pavucontrol -> Recording, find the recording device (in my case it's called "ALSA plug-in [python3.8]") and set "Capture from" to the audio you want to capture (in my case "Monitor of Built-in Audio Analog Stereo").

I believe it would be cool to add this to the documentation. I'd be glad to follow up with a PR, if any of the maintainers would like to see this included. :)

@janjagusch janjagusch changed the title Documentation: Directing computer audio output to LedFx example for Ubuntu Documentation: Directing computer audio output to LedFx example for Linux Jan 17, 2021
@shauneccles
Copy link
Member

I believe it would be cool to add this to the documentation. I'd be glad to follow up with a PR, if any of the maintainers would like to see this included. :)

We would love a PR!

@shauneccles shauneccles added the documentation Improvements or additions to documentation label Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants