[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: usb audio device & sound card



Mark Grieveson wrote:
>> Greetings Mark:
> 
>> As others have said, it sounds like the cards are not always getting
>> recognized in the same order, so sometimes your sound card is card 0 and
>> sometimes it is card 1.  That used to happen to me once in a while, but
>> it hasn't lately.
> 
>> In any event, you can verify that this is in fact what is happening by
>> looking at the contents of your /proc/asound/cards file.  It will list
>> all of the cards that the kernel recognizes.  The card statement in your
>> .asound file is telling the system which of those two cards (0 or 1) to
>> use as the default.
> 
>> Another poster suggested modifications to the udev rules.  That is
>> certainly worth a try, but I'm not sure that udev is the process
>> responsible for ordering those cards.  I could certainly be wrong about
>> that, but a quick look through the rules didn't show me anything that
>> looked promising.
> 
>> Back when my system was changing the order of my cards, I planned to
>> write a script and run it from my .bashrc file.  I was going to have the
>> script look at the contents of the /proc/asound/cards file and
>> dynamically generate my .asoundrc file based on the order of the cards
>> listed in /proc/asound/cards.  I never got around to it, and my system
>> hasn't changed the order of initialization in months, so I never got
>> around to doing it.  It would not be a difficult script to write, but if
>> it's not your thing, post the contents of your /proc/asound/cards file
>> and I'll post you back a script.
> 
>> - -Scott
> 
> Thanks Scott.  I certainly appreciate your offer.  Here's the /proc/asound/cards file:
> 
>  0 [Headset           ]: USB-Audio - USB Headset
>                       GENERIC USB Headset at USB-0000:00:04.2-1, full speed
> 
>  1 [CS46xx            ]: CS46xx - Sound Fusion CS46xx
>                       Sound Fusion CS46xx at 0xf4100000/0xf000000, irq 11
> 
> 
> 
> Mark
> 
> 

Greetings Mark:

This script would set your on-board card (CS46xx) to be your default
card for alsa regardless of which card it is in the system (0 or 1):


#!/bin/bash
#
# The awk statement should get the first "word" (the card number)
# from the line which contains the text (the card name)
defcard=`awk '/\[CS46xx/ {print $1}' /proc/asound/cards`

# Create the .asoundrc file as a "here" document inserting the
# card number that the awk statement generated above
cat > ~/.asoundrc <<EOF
pcm.!default {
    type hw
    card $defcard
}

ctl.!default {
    type hw
    card $defcard
}
EOF


The script is going to require both bash and awk to be installed on the
system (I think both are installed by default).  I would dump that code
into a script file (maybe /usr/local/bin/setasoundrc) and make sure that
the file is executable (chmod +x), and then call that script from your
.bashrc file.  Reboot a couple of times and make sure that your
~/.asoundrc file always lists the on-board device as the default card.

Let me know if it's not doing what you need.

-Scott



Reply to: