Nixos default audio device - audio

I'm trying to configure the default audio device on a NixOS host.
My alsa devices are thus:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC1220 Analog [ALC1220 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC1220 Digital [ALC1220 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
I don't have HDMI or digitaul audio devices; I just want to use the regular ALC1220 Analog device.
I currently have AUDIODEV=hw:1,0 set in my environment (for sox), and alsa-audio-device=sysdefault:CARD=Generic in my vlcrc. That works, but it is obviously user- and app- specific, and is a pain for declaritiveness (declarity?).
It seems that it should be something I can set at the host level, e.g., by setting
sound.extraConfig =
''
pcm.!default {
type hw
card Generic
}
'';
in my configuration.nix, or possibly configuring pulseaudio.
I have sought help in the NixOS Wiki (ALSA, Pulse), on other sites such as ArchLinux, Pulse documentation, and other sites like StackOverflow (e.g., stackexchange), but I can find nothing that actually works.
I have tried the above, and variants thereof; and also tried with & without Pulse; but I have found nothing that works.
Simply being able to sound audio to all the devices on that card would be jolly good, too.
As always, any pointers gratefully recieved.
Update: here is my /etc/asound.conf
pcm_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_pcm_pulse.so ;
}
pcm.!default {
type pulse
hint.description "Default Audio Device (via PulseAudio)"
}
ctl_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so ;
}
ctl.!default {
type pulse
}
(and that module is real):
$ ls -l /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so
-r-xr-xr-x 1 root root 33512 Jan 1 1970 /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so

This problem is most likely due to pulseaudio comandeering the default device, despite listing it in ~/.asoundrc.
The best solution to override pulse's comandeering of the default device with an alsa hook. To do this, edit your ~/.asoundrc with the following contents at the top :
#hooks [
{
func load
files [
"~/.asoundrc"
]
errors false
}
]
You can then add you default device as required, probably something like the following in your case :
pcm.!default {
type hw
card "Generic"
}
ctl.!default {
type hw
card "Generic"
}

Related

usb sound card no detected in raspberry pi zero w

I have raspberry pi zero W, running raspbian lite.
I'm trying to connect USB sound card.
the usb card is recognised by "dmesg" command but not added as sound card:
dmesg:
[ 67.941583] usb 1-1.1: new full-speed USB device number 7 using dwc_otg
[ 69.059664] usb 1-1.1: New USB device found, idVendor=0bda, idProduct=48f0,
bcdDevice= 0.03
[ 69.059715] usb 1-1.1: New USB device strings: Mfr=3, Product=1, SerialNumber=0
[ 69.059743] usb 1-1.1: Product: USB Audio
[ 69.059765] usb 1-1.1: Manufacturer: Generic
[ 69.080726] input: Generic USB Audio as /devices/platform/soc/20980000.usb/usb1/1-
1/1-1.1/1-1.1:1.0/0003:0BDA:48F0.0006/input/input10
[ 69.142959] hid-generic 0003:0BDA:48F0.0006: input,hidraw0: USB HID v1.11 Device
[Generic USB Audio] on usb-20980000.usb-1.1/input0
lsusb:
Bus 001 Device 007: ID 0bda:48f0 Realtek Semiconductor Corp.
play -l: - no usb sound card
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
I was having the exact problem on RPi4. Once I blacklisted the built-in sound card, following these instructions: https://www.instructables.com/Disable-the-Built-in-Sound-Card-of-Raspberry-Pi/
the usb sound card was recognized and it worked.

ubuntu 18.04 no sound

No sound on ubuntu 18.04 dell Inspiron 13. I'm not sure this pc require ALSA driver, maybe needs snd_soc_skl driver, Have someone try it? can you write how to change the kernel module in use in this Linux version?
Some details Inspiron-13-7368:~$ aplay -l
**** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC3253 Analog [ALC3253 Analog] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4] Subdevices: 1/1 Subdevice #0: subdevice #0
Inspiron-13-7368:~$ lspci -v
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21) (prog-if 80) Subsystem: Dell Sunrise Point-LP HD Audio Flags: bus master, fast devsel, latency 32, IRQ 152 Memory at d1128000 (64-bit, non-prefetchable) [size=16K] Memory at d1100000 (64-bit, non-prefetchable) [size=64K] Capabilities: Kernel driver in use: snd_hda_intel Kernel modules: snd_hda_intel, snd_soc_skl
What I found was to remove the "timidity-deamon":
sudo apt purge timidity-daemon
Thanks to Aaro Alhainen for his post.
You can read about timidity-deamon package.

How to fix: device_list:270: no soundcard found (Ubuntu server 18.04)?

I was trying to capture some audio using a usb microphone and I got the error message mentioned in the title.
here is the output some (hopefully relevant) commands:
arecord -l
arecord: device_list:270: no soundcards found...
ls /cat/asound*
ls: cannot access '/cat/asound*': No such file or directory
lspci -v
00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04)
Subsystem: Hewlett-Packard Company 7 Series/C216 Chipset Family High Definition Audio Controller
Flags: bus master, fast devsel, latency 0, IRQ 29
Memory at f7c30000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
I've tried to remove and install alsa again and when I run
sudo arecord -l
The output is:
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC221 Alt Analog [ALC221 Alt Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
I guess meaning Ubuntu is recognising my sound card. The ALSA Info script can be found here.
Any help would be greatly appreciated.
I had aplay: device_list:268: No sound card found... after using aplay l. Following the Ubuntu troubleshooting guide below, I installed apt install linux-generic and after reboot it found my soundcard from VirtualBox in Ubuntu Server 20.04 from ova.
https://help.ubuntu.com/community/SoundTroubleshooting

Raspberry Pi - uv4l WebRTC no audio

I've setup up my Raspberry Pi 2 running Wheezy to stream video via uv4l / uv4l-server. I have both a Pi Camera and a USB Microsoft LifeCam HD-5000. I launched uv4l with each driver for each camera and the streaming works fine except for the audio. I'm trying to use my USB webcam as the microphone to stream audio. I read on the uv4l documentation that it picks up the first audio device from "arecord -l" has the audio input and mine prints:
**** List of CAPTURE Hardware Devices ****
card 0: HD5000 [Microsoft LifeCam HD-5000], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I changed my /etc/modprobe.d/alsa-base.conf to match the one on this page: http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
I can record audio and play it back by doing:
arecord -D plughw:0,0 -d5 test.wav
aplay -D plughw:1,0 test.wav
Can someone please point me what I'm missing to be able to stream video and audio via uv4l?
Thank you!
Have you tried with or without PulseAudio? Try to uninstall it first.

Errors using pyAudio

I'm trying to use the pyaudio examples provided on https://people.csail.mit.edu/hubert/pyaudio/#examples.
I have two Raspberry Pis, both of them have the pyAudio installed. One of them can run the examples wihtout any issues, however the other one spits the following error messages when trying to record audio for example:
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
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: 1438
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2742
Traceback (most recent call last):
File "audioRecord.py", line 17, in <module>
frames_per_buffer=CHUNK)
File "/usr/local/lib/python3.2/dist-packages/pyaudio.py", line 747, in open
stream = Stream(self, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/pyaudio.py", line 442, in __init__
self._stream = pa.open(**arguments)
IOError: [Errno Invalid number of channels] -9998
I have the following audio configs:
$ cat /proc/asound/modules
0 snd_usb_audio
1 snd_bcm2835
$ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bda:8178 Realtek Semiconductor Corp. RTL8192CU 802.11n WLAN Adapter
Bus 001 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 001 Device 006: ID 046d:c077 Logitech, Inc.
Bus 001 Device 007: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
Could you please advise, what can be missing on this second device?
The solution was to make the sound device 0 as default.

Resources