aplay cant read from config .asoundrc - linux

I want aplay to read from .arecordrc file but it fails.
pi#raspberrypi:~ $ aplay numnuts.wav
ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
aplay: main:722: audio open error: No such device
When i provide the hardware in command line it works
pi#raspberrypi:~ $ aplay -D hw:0,0 numnuts.wav
Playing WAVE 'numnuts.wav' : Unsigned 8 bit, Rate 11025 Hz, Mono
my .asoundrc:
pi#raspberrypi:~ $ cat .asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0:0"
}
}
Can anyone suggest me what had to change in pcm. speaker
aplay -l output
pi#raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: 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 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0

Solved it, it was a typo mistake:
in pcm.speaker
replace pcm "hw:0:0"
to
pcm "hw:0,0"

Related

VLC Raspberry pi 4 how to send audio to HDMI 2 via command line?

I'm running Rasbian OS on a raspberry pi 4 with two HDMI ports and via terminal, I can run a video with audio working on HDMI 1 using sudo cvlc --alsa-audio-device default video.mp4 now the problem I'm facing is running a second video on HDMI 2 with audio, I can get the video running using this command DISPLAY=:0 cvlc --qt-fullscreen-screennumber=1 --alsa-audio-device hw:1,0 video.mp4 but I can't seem to get the audio working on HDMI 2.
I checked my audio outputs using aplay -l which gave me the following output.
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 3/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 1: b2 [bcm2835 HDMI 2], device 0: bcm2835 HDMI 2 [bcm2835 HDMI 2]
Subdevices: 2/2
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 2/2
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
The problem is I'm not really sure how to address the sound card 1 on --alsa-audio-device
This solved my problem, I can now send audio individually to each HDMI by selecting the specific hardware output via command line.
HDMI1
DISPLAY=:0 cvlc --alsa-audio-device hw:0,0 video.mp4
HDMI 2
DISPLAY=:0 cvlc --qt-fullscreen-screennumber=1 --alsa-audio-device hw:1,0 video.mp4
Your problem is that the pi thinks of them as hdmi 0 and hdmi 1, so hdmi 0 is acctually 1, and hdmi 1 is 2. You can see this on the labelling on the ports on the pi

Raspberry Pi 4 and Google Assistant with Bluetooth Mic and Speaker

I need some help to make it work...
I have a Raspberry Pi 4 on Raspbian and a JBL Go2 Bluetooth that is speaker and mic...
The assistant is working properly (voice commands are executed) but google has no voice...so no OUTPUT... (i cant
That means microphone working ok on console but no speaker...
pi#raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
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
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
Subdevices: 1/1
Subdevice #0: subdevice #0
also
with
speaker-test -t wav
i got no audio output...cant hear anything...but i get no errors or something like that
BUT on
pi#raspberrypi:~ $ aplay /home/pi/recording.wav
Playing WAVE '/home/pi/recording.wav' : Unsigned 8 bit, Rate 8000 Hz, Stereo
i can hear the recording i have done earlier properly on terminal enviroment...
I could like to make the assisant talking... :/
On next step could like to make it handsfree...
Thanks

Set up Raspberry Pi 3 USB mic ( creative sound blaster )

Can someone please help me in setting up my RPi 3. I'm tying to build a speech to text / speech recognition with my gaming headset (Creative Technology, Ltd Sound Blaster Tactic(3D) Sigma sound card). The speakers are now working but unfortunately I'm stuck in setting up the mic.
Before i tweaked the settings, I can record/create a wav file but whenever i play the wav file there's no sound. After changing some settings, i'm encountering new error below. Thanks in advance!
Error:
pi#raspberrypi:~ $ arecord -D plughw:0,0 test9.wav
Recording WAVE 'test9.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
^CAborted by signal Interrupt...
arecord: pcm_read:2031: read error: Interrupted system call
Configs:
~/.asoundrc
pcm.!default { type plug slave { pcm "hw:0,0" } }
ctl.!default { type hw card 0 }
/usr/share/alsa/alsa.conf
defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 0
defaults.pcm.subdevice -1
/lib/modprobe.d/aliases.conf
options snd-pcsp index=-2
options snd-usb-audio index=0
options snd_bcm2835 index=1
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
# Does the reordering.
options snd slots=snd-usb-audio,snd-bcm2835
aplay -l
pi#raspberrypi:~/Desktop $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Sigma [Sound Blaster Tactic(3D) Sigma], 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
arecord -l
pi#raspberrypi:~/Desktop $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Sigma [Sound Blaster Tactic(3D) Sigma], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Update
I have managed to fix the problem! It turns out that when I run alsamixer, the ~/.asoundrc config file automatically updates. My config were overwritten by the new settings.

arecord: set_params:1233: Sample format non available Available formats: - S16_LE

I have a USB microphone and speaker adapter connected to a Raspberry Pi 3. I have set up everything on alsamixer. I have also set the pcm.!default sysdefault:0 in file .asoundrc in the home directory which sets the USB audio adapter as the default audio card.
I have run: aplay -l and the output is:
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/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 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I then set the pcm.!default sysdefault:0 in file .asoundrc in the home directory.
When I run the command arecord -d 5 -r 48000 test.wav I receive this error:
arecord: set_params:1233: Sample format non available Available
formats: - S16_LE
The solution is to change .asoundrc to this:
pcm.!default {
type plug
slave {
pcm "hw:1,0"
}
}
ctl.!default {
type hw
card 1
}
A generic configuration that works would be:
$ sudo nano ~/.asoundrc
pcm.!default {
type asym
playback.pcm {
type plughw
slave.pcm "output"
}
capture.pcm {
type plughw
slave.pcm "input"
}
}
pcm.output{
type hw
card 1
}
ctl.!default {
type hw
card 1
}

aplay / alsaplayer - sound not working for normal user

I cannot use alsa as a normal user (resulting in me not having sound in chromium).
I am guessing it has something to do with permissions. Adding myself to group audio didn't help.
[zarac#towelie ~]$ grep audio /etc/group
audio:x:92:mpd,zarac
Testing sound as normal user:
[zarac#towelie ~]$ aplay /usr/share/sounds/alsa/Noise.wav
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4154:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4154:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4154:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4633:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:654: audio open error: No such file or directory
[zarac#towelie ~]$
and as root...
[root#towelie zarac]# aplay /usr/share/sounds/alsa/Noise.wav
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
[root#towelie zarac]#
Running the command 'aplay -l' as normal user:
[zarac#towelie ~]$ aplay -l
aplay: device_list:235: no soundcards found...
and as root...
[root#towelie zarac]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: XFi [Creative X-Fi], device 0: ctxfi [Front/WaveIn]
Subdevices: 6/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 0: XFi [Creative X-Fi], device 1: ctxfi [Surround]
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 0: XFi [Creative X-Fi], device 2: ctxfi [Center/LFE]
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 0: XFi [Creative X-Fi], device 3: ctxfi [Side]
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 0: XFi [Creative X-Fi], device 4: ctxfi [IEC958 Non-audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 0: ALC889A Analog [ALC889A Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 1: ALC889A Digital [ALC889A Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
Any clues to what might be causing this is appreciated. Perhaps something needs to be chmodded somwhere?
Try looking at the permission of /dev/dsp and /dev/snd/* . If you don't have read write permission on these files then no sound is possible.
I noticed in my instance of CentOS release 5.9 and installing VLC, I needed to add my user to the audio group in /etc/group to actually get sound. HTH
$ sudo /etc/init.d/alsa-utils reset

Resources