Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I bought an USB sound card. I'd like to set up my Linux desktop so that it prefers the USB device, if it is plugged in and automatically switches as the device is (un)plugged. Is it possible, and how?

share|improve this question
    
Debian uses pulseaudio instead. –  Braiam Aug 5 '13 at 20:35

2 Answers 2

find your card with

cat /proc/asound/cards

and then create /etc/asound.conf with following:

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}

replace ("card 1" with number of your card determined above)

Alternatively, you can change ordering of your cards so your USB card will be card 0 and it will work without editing asound.conf

share|improve this answer
    
I tried your suggestion, but when the USB card is unplugged, audio stops working completely, instead of switching to the built-in card. –  Petr Pudlák Aug 11 '13 at 11:29

this is the method for selecting default sound card in Alsa. You may want to install Alsa for this method to work if you are using Pulse Audio.

cat /proc/asound/modules

will list your sound modules .The output of the command will be like this (eg):

0 snd_hda_intel

1 snd_usb_intel

you can pretty easily understand which one is your usb sound card from above.

nano /etc/modprobe.d/alsa-base.conf

edit this alsa-base.conf in such a way that your preferred card has an index =-2 / 0 and the other card has index =-1 / 1 (stick with -2 and -1 )

options snd_hda_intel index=-1

options snd_usb_intel index=-2

in this case usb device is preferred device.

if you are having two differnt cards with same name from the output, like this:

options snd_hda_intel

options snd_hda_intel

issue this cammand and find out which is which

cat /proc/asound/cards

then edit modules in this way:

options snd_hda_intel index enable=1 index=0

options snd_hda_intel index enable=0 index=1

a reboot may be necessary.so you might have to manually switch over your sound cards.

share|improve this answer
    
What do you mean by "modifying the output"? How can I modify the output? –  Petr Pudlák Aug 11 '13 at 9:05
    
i have made necessary changes in the answer.try this version.hope this helps.the methods may vary according to the flavour of linux you use. –  Ash Aug 11 '13 at 12:50
    
Thank you. How can I verify the setup? I identified the cards, added the appropriate options, rebooted, but I don't see any change - still the internal (intel) card is the preferred one. –  Petr Pudlák Aug 11 '13 at 18:14
    
try >options snd-usb-intel enable=1 index=0 (to enable) >options snd-hda-intel enable=0 index=1 (to disable) or >options snd-hda-intel enable=0 index=0 >options snd-usb-intel enable=1 index=1 and reboot –  Ash Aug 11 '13 at 19:27
    
i.e, enable usb disable the other one using enable =0 or 1,do this vice versa also.i'm not sure which will work for you.reboot is necessary.i wish u solve yor problem –  Ash Aug 11 '13 at 19:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.