You are not logged in.

#1 2009-04-28 18:07:59

Roberth
Member
From: The Pale Blue Dot
Registered: 2007-01-12
Posts: 894

How do I choose which soundcard ALSA uses?

Hello I am having a problem that ALSA uses the wrong soundcard, does alsa-utils or any others package provide a tool which I can make ALSA use the right soundcard?


Use the Source, Luke!

Offline

#2 2009-04-28 19:06:32

dan.boff
Member
Registered: 2009-04-07
Posts: 42

Re: How do I choose which soundcard ALSA uses?

try this:
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dsp0 {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 8192
rate 48000 #many new cards are 48000 only
}
bindings {
0 0
1 1
}
hint {
show on
description "Onboard Soundcard"
}
}
ctl.dmixer {
type hw
card 0
}

change hw:0,0 to your sound device

Offline

#3 2009-04-28 19:16:34

droog
Member
Registered: 2004-11-18
Posts: 877

Re: How do I choose which soundcard ALSA uses?

I used to use alsaconf, the wiki says it can cause conflicts with udev if you have a pci card though.

Offline

#4 2009-04-28 19:28:38

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: How do I choose which soundcard ALSA uses?

Load your sound drivers in the required order in rc.conf MODULES - the alsa default card will be the one that is loaded first.

Offline

#5 2009-04-28 20:56:45

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: How do I choose which soundcard ALSA uses?

I spent weeks trying to find the best solution to this problem, and it's very simple. 
Just put this in your .asoundrc:

defaults.pcm.card 0
defaults.ctl.card 0

Change the number to whatever you want, and you can find them out with "aplay -l".  And only use numbers.
Using this method, you can change the default sound card on a per-user basis, after boot time, without having to edit anything as root.
I wrote a script that can do it for you, and handles volume control too:

#!/bin/sh

config=~/.asoundrc

choose () {
    echo Choose a card:
    aplay -l
    read card
    
    echo Choose a control:
    amixer -c $card scontrols
    read control
    
    echo "#" $control > $config
    echo defaults.pcm.card $card >> $config
    echo defaults.ctl.card $card >> $config
}

control=(`cat .asoundrc`)
control=${control[1]}

case $1 in
    up)      amixer -q set $control 5%+ ;;
    down)  amixer -q set $control 5%- ;;
    mute)  amixer -q set $control toggle ;;
    *)    choose ;;
esac

Last edited by Odysseus (2009-04-28 20:58:47)


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#6 2009-06-05 14:55:07

jazz452
Member
Registered: 2008-07-29
Posts: 21

Re: How do I choose which soundcard ALSA uses?

I  added sound drivers in rc.conf modules as tomk suggested and so far so good.Seems the easiest method to me.
I was having problems due to dvb-s card and pci sound card.
Cheers tomk

Last edited by jazz452 (2009-06-05 14:56:50)

Offline

Board footer

Powered by FluxBB