Open traversaro opened 1 month ago
Actually in this setup also alsamixer
fails, so I guess there is something not working at the WSL level (even if play
works fine):
root@DESKTOP-T0NQNLN:~# alsamixer
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib control.c:1570:(snd_ctl_open_noupdate) Invalid CTL default
cannot open mixer: No such file or directory
Actually I think this output are kind of expected. On WSLg, audio support is implemented at the PulseAudio level, not at at the kernel/ALSA level (see https://github.com/microsoft/WSL/issues/5816#issuecomment-2085650686 and the really nice https://github.com/microsoft/wslg/blob/main/README.md#wslg-architecture-overview, search for PulseAudio there). YARP uses PortAudio, and the build of portaudio on conda-forge (and also on apt, actually) do not compile the pulseaudio backend of portaudio, only the alsa backend (the apt version also the jack backend).
Actually I think this output are kind of expected. On WSLg, audio support is implemented at the PulseAudio level, not at at the kernel/ALSA level (see microsoft/WSL#5816 (comment) and the really nice https://github.com/microsoft/wslg/blob/main/README.md#wslg-architecture-overview, search for PulseAudio there). YARP uses PortAudio, and the build of portaudio on conda-forge (and also on apt, actually) do not compile the pulseaudio backend of portaudio, only the alsa backend (the apt version also the jack backend).
This is true, but it is important to understand a few things:
alsa
project mantains both the sound-related kernel drivers, and a userspace library called libasound
pulseaudio
project interacts with the alsa kernel driver, not with the userspace library libasound
alsa-plugins
package, it is contained a package that permits to use libasound
to actually access audio via pulseaudio
, instead of accessing directly the alsa
kernel modulesSo, in a nutshell, if the pulseaudio backend of libasound
worked correctly, we should be able to use programs that use libasound
(as yarp does via portaudio
) as long as libasound
actually uses pulseaudio
under the hood (even without enabling any pulseaudio backend of libportaudio
, that indeed is not enable in the apt packaging.
Related issues:
This README explains quite well how the pulse backend for libasound
works: https://github.com/alsa-project/alsa-plugins/blob/v1.2.12/doc/README-pulse .
Indeed, even in WSL2 if I run:
alsamixer -Dpulse
works fine, while simple alsamixer
is failing, see:
root@DESKTOP-T0NQNLN:~# alsamixer
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib control.c:1570:(snd_ctl_open_noupdate) Invalid CTL default
cannot open mixer: No such file or directory
Adding in ~/.asoundrc
a file with content:
pcm.pulse {
type pulse
fallback "sysdefault"
}
ctl.pulse {
type pulse
fallback "sysdefault"
}
pcm.!default "pulse"
ctl.!default "pulse"
now amixer
and alsamixer
work out of the box.
And after adding that file, now yarpdev --device AudioPlayerWrapper --subdevice portaudioPlayer --name /icub/speakers --playback_network_buffer_size 0.5 --start --AUDIO_BASE::samples 4000 --AUDIO_BASE::channels 1 --dev_id 0 --AUDIO_BASE::rate 48000
starts without segfaulting, but I still need to try if it works (as there are a few errors):
(yarp) root@DESKTOP-T0NQNLN:~# yarpdev --device AudioPlayerWrapper --subdevice portaudioPlayer --name /icub/speakers --playback_network_buffer_size 0.5 --start --AUDIO_BASE::samples 4000 --AUDIO_BASE::channels 1 --dev_id 0 --AUDIO_BASE::rate 48000
[DEBUG] |yarp.dev.PolyDriver|AudioPlayerWrapper| Parameters are (AUDIO_BASE (samples 4000) (channels 1) (rate 48000)) (dev_id 0) (device AudioPlayerWrapper) (name "/icub/speakers") (playback_network_buffer_size 0.5) (single_threaded 1) (start) (subdevice portaudioPlayer)
[INFO] |yarp.os.Port|/icub/speakers/audio:i| Port /icub/speakers/audio:i active at tcp://172.28.148.122:10002/
[INFO] |yarp.os.Port|/icub/speakers/status:o| Port /icub/speakers/status:o active at tcp://172.28.148.122:10003/
[INFO] |yarp.os.Port|/icub/speakers/rpc:i| Port /icub/speakers/rpc:i active at tcp://172.28.148.122:10004/
[INFO] |yarp.device.AudioPlayerWrapper| Using a 'playback_network_buffer_size' of 0.5 s
[INFO] |yarp.device.AudioPlayerWrapper| Increase this value to robustify the real-time audio stream (it will increase latency too)
[DEBUG] |yarp.dev.PolyDriver|portaudioPlayer| Parameters are (AUDIO_BASE (samples 4000) (channels 1) (rate 48000)) (dev_id 0) (device portaudioPlayer) (name "/icub/speakers") (playback_network_buffer_size 0.5) (single_threaded 1) (start) (subdevice portaudioPlayer)
[INFO] |yarp.devices.AudioPlayerDeviceBase| Device configured with the following options:
[INFO] |yarp.devices.AudioPlayerDeviceBase| Frequency: 48000
[INFO] |yarp.devices.AudioPlayerDeviceBase| Samples (buffer size): 4000
[INFO] |yarp.devices.AudioPlayerDeviceBase| Channels: 1
[INFO] |yarp.devices.AudioPlayerDeviceBase| BytesForSample: 2
[INFO] |yarp.devices.AudioPlayerDeviceBase| HW gain: 1
[INFO] |yarp.devices.AudioPlayerDeviceBase| SW gain: 1
[INFO] |yarp.devices.AudioPlayerDeviceBase| Render mode: append
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
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
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
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
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:404:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:404:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_a52.c:1036:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib conf.c:5694:(snd_config_expand) Unknown parameters {AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0}
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0}
ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_speex.so (/root/miniforge3/envs/yarp/lib/yarp/.././alsa-lib/libasound_module_pcm_speex.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_speex.so (/root/miniforge3/envs/yarp/lib/yarp/.././alsa-lib/libasound_module_pcm_speex.so: cannot open shared object file: No such file or directory)
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:481:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:481:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_id returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) Unknown PCM dmix
[INFO] |yarp.dev.PolyDriver|portaudioPlayer| Created device <portaudioPlayer>. See C++ class PortAudioPlayerDeviceDriver for documentation.
[INFO] |yarp.devices.AudioPlayerDeviceBase| Playback started
[INFO] |yarp.devices.portaudioPlayer| started playback
[INFO] |yarp.dev.PolyDriver|AudioPlayerWrapper| Created wrapper <AudioPlayerWrapper>. See C++ class AudioPlayerWrapper for documentation.
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| ===============================================================
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| == Options checked by device:
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| ==
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| device=AudioPlayerWrapper
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| id [AudioPlayerWrapper]
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| Id assigned to this device
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| ==
[DEBUG] |yarp.dev.Drivers|AudioPlayerWrapper| ===============================================================
[INFO] |yarp.os.Port|/icub/speakers/quit| Port /icub/speakers/quit active at tcp://172.28.148.122:10005/
[INFO] |yarp.dev.Drivers|AudioPlayerWrapper| device active in background...
I tested by playing a sound with:
yarpdev --device AudioRecorderWrapper --subdevice audioFromFileDevice --name /icub-virtualizer/microphone --min_samples_over_network 100 --max_samples_over_network 1000 --AUDIO_BASE::rate 16000 --AUDIO_BASE::samples 4000 --AUDIO_BASE::channels 1 --file_name file_example_WAV_1MG.wav
then:
yarp connect /icub-virtualizer/microphone/audio:o /icub/speakers/audio:i
and
yarp rpc /icub-virtualizer/microphone/rpc
> start
and not all the sound is actually playing, but something is played.
Solution to issue cannot be found in the documentation.
Issue
On Ubuntu 24.04 on wSL2 (I tested that the audio plays well with
play examplesound.mp3
:Installed packages
Environment info