May 27 2011

alsa…. man man man…

vi /etc/asound.conf

pcm.!default {
type plug
slave {
pcm "hw:1,0"
}
}
ctl.!default {
type hw
card 1
}

cat /proc/asound/cards
0 [Webcam ]: USB-Audio - Philips SPC 1030NC Webcam
Philips CE Philips SPC 1030NC Webcam at usb-orion-ehci.0-1.2, high speed
1 [Audio ]: USB-Audio - USB Audio
USB Audio at usb-orion-ehci.0-1.5.7, full speed

sheeva[0][~]# aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 1: Audio [USB Audio], Gerät 0: USB Audio [USB Audio]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0

aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=Audio
USB Audio, USB Audio
Default Audio Device
front:CARD=Audio,DEV=0
USB Audio, USB Audio
Front speakers
surround40:CARD=Audio,DEV=0
USB Audio, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Audio,DEV=0
USB Audio, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Audio,DEV=0
USB Audio, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Audio,DEV=0
USB Audio, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Audio,DEV=0
USB Audio, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Audio,DEV=0
USB Audio, USB Audio
IEC958 (S/PDIF) Digital Audio Output

also, make sure the sample rate is set correctly in /etc/asound.conf, otherwise you will hear crackling sound like a bad CD:

period_time 0
period_size 4096
buffer_size 131072
rate 22050


depending on the application you are using. In my case I am using espeak and aplay at 22050 hz.

here you can see the default expected sample rate:
sheeva[1][~]# cat /proc/asound/Audio/stream0
USB Audio at usb-orion-ehci.0-1.5.7, full speed : USB Audio

Playback:
Status: Stop
Interface 1
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 1 OUT (ADAPTIVE)
Rates: 48000
Interface 1
Altset 2
Format: S16_LE
Channels: 6
Endpoint: 1 OUT (ADAPTIVE)
Rates: 48000

Capture:
Status: Stop
Interface 2
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 2 IN (ASYNC)
Rates: 48000

so overall my conf is looking like this now:

pcm.!default {
type plug
slave.pcm "dmixer"
}

pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:1,0"
period_time 0
period_size 4096
buffer_size 131072
# period_size 1024
# buffer_size 4096
rate 22050
}
bindings {
0 0
1 1
}
}

ctl.dmixer {
type hw
card 1
}

test mic:
arecord -f cd -d 5 -D dsnoop:1,0 -c 1 | aplay -
or record:
arecord -f cd -d 5 -D dsnoop:1,0 -c 1 test.wav
5 sec record, 1 channel, cd quality, device dsnoop:1,0 (can be found with aplay -L)

old – not working for me anymore:
asoundconf set-default-card Audio

to set default f***ing card

also worth to check the settings in:
/etc/modprobe.d/alsa-base.conf