aplay/arecord选择声卡

aplay/arecord选择声卡

Linux命令行中使用aplay和arecord时如何指定声卡呢:

首先可使用以下指令查看声卡设备和PCM设备,具体如下:

root@newboard_project:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ADAU1761 [ZED ADAU1761], device 0: 43c00000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ADAU1761_1 [ZED ADAU1761], device 0: 43c10000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: ADAU1761_2 [ZED ADAU1761], device 0: 43c20000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
root@newboard_project:/# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: ADAU1761 [ZED ADAU1761], device 0: 43c00000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ADAU1761_1 [ZED ADAU1761], device 0: 43c10000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: ADAU1761_2 [ZED ADAU1761], device 0: 43c20000.axi-i2s-adau-hifi adau-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
root@newboard_project:/# ls -l /dev/snd
crw-rw---- 1 root root 116, 0 Jan 1 00:00 controlC0
crw-rw---- 1 root root 116, 32 Jan 1 00:00 controlC1
crw-rw---- 1 root root 116, 64 Jan 1 00:00 controlC2
crw-rw---- 1 root root 116, 24 Jan 1 00:00 pcmC0D0c
crw-rw---- 1 root root 116, 16 Jan 1 00:00 pcmC0D0p
crw-rw---- 1 root root 116, 56 Jan 1 00:00 pcmC1D0c
crw-rw---- 1 root root 116, 48 Jan 1 00:00 pcmC1D0p
crw-rw---- 1 root root 116, 88 Jan 1 00:00 pcmC2D0c
crw-rw---- 1 root root 116, 80 Jan 1 00:00 pcmC2D0p
crw-rw---- 1 root root 116, 33 Jan 1 00:00 timer

如上,共有三个声卡设备:
card 0: ADAU1761
card 1: ADAU1761_1
card 2: ADAU1761_2


在使用aplay和arecord指令进行播放和录音时可正常选择其中某一个声卡,如:

//使用ADAU1761_1录音
root@newboard_project:/# arecord -D hw:ADAU1761_1 -f S32_LE -d 10 -c 2 -r 48000 s32_le.wav
Recording WAVE 's32_le.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
//使用ADAU1761播放
root@newboard_project:/# aplay -D hw:ADAU1761 -f S32_LE -c 2 -r 48000 s32_le.wav
Playing WAVE 's32_le.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
0