9

I wish to select a default sound card, or disable all others, in order to have the correct one selected after suspend.

  • How many sound cards do you have in the system? – Mitch Jun 14 '12 at 15:26
  • 2, but 4 things show up in sound settings for output and 3 things for input. – MarkovCh1 Jun 14 '12 at 16:37
5

This is a way set default sound output card dynamically using PulseAudio (not ALSA).

  1. Check list of Sources and Sinks

    $ pactl list short sources
    0   alsa_output.pci-0000_00_1b.0.analog-stereo.monitor  module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
    1   alsa_input.pci-0000_00_1b.0.analog-stereo   module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
    2   combined.monitor    module-combine-sink.c   s16le 2ch 44100Hz   SUSPENDED
    
    $ pactl list short sinks
    0   alsa_output.pci-0000_00_1b.0.analog-stereo  module-alsa-card.c  s16le 2ch 44100Hz   RUNNING
    1   combined    module-combine-sink.c   s16le 2ch 44100Hz   IDLE
    2   alsa_output.pci-0000_01_00.1.hdmi-stereo    module-alsa-card.c  s16le 2ch 44100Hz   RUNNING
    
  2. Set defaults:

    $ pactl set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo
    $ pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
    

It is possible even to set ports too. See How to switch sound output with key shortcut

Reference: man pactl

| improve this answer | |
  • 3
    pactl is for pulseaudio, not alsa – slang Jan 5 '16 at 2:57
  • @slang, thanks, you are correct, I put a note for that. However the OP has alsa in title, nothing in description and tagged for both. This give me an impression that the user was looking for a solution at any level. BTW, my self I want to know if there is a way using ALSA, this is an old question stayed unresolved for two years. – user.dz Jan 5 '16 at 6:15
  • Pulse is not a solution to doing something with ALSA. If they wanted to use pulse, they'd have asked about pulse. – monokrome Aug 8 at 3:56
4

Find your desired card with:

cat /proc/asound/cards

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

defaults.pcm.card 1
defaults.ctl.card 1

Replace 1 with number of your card determined above. Source: https://www.alsa-project.org/wiki/Setting_the_default_device

| improve this answer | |
  • 1
    This should be the accepted answer. – skolind Mar 27 at 12:02
1

Seeing as I don't have Pulse, the accepted answer isn't valid for others like me.
This should provide a decent solution here that works off of ALSA alone.

I have a bit of detail since I have 3 devices (onboard 2-channel, video card HDMI, PCI 5.1-channel) in my machine, with my preferred device being last.

what worked for me was editing /etc/asound.conf with the following:
(resource: http://www.alsa-project.org/main/index.php/Asoundrc )

pcm.!default {
    type hw
    card 0
}

ctl.!default {
    type hw
    card 0
}

If I would've intuitively set my default device as 2, the order of the above devices would've flipped to this after restarting:

0: [CMI8738        ]
1: [Nvidia         ]
2: [Nvidia_1       ]

with the default device being 2.
(this would continue after every reboot, and no restarting alsa did not make apps play audio)

To stop my machine from trolling me, I had to edit /etc/modprobe.d/alsa-base.conf and add the following line:
(resource (search for the 6th occurrence of "order"): https://alsa.opensrc.org/MultipleCards#How_to_choose_a_particular_order_for_multiple_installed_cards )

options snd slots=snd-cmipci,

which forced my preferred device at 0 so the default card would match:

Hopefully I'll never have to touch these settings again, and it'll help others like me who don't want to deal with PulseAudio dropping audio streams.
(yes this means poorly developed apps like Discord won't identify your audio devices without Pulse)

| improve this answer | |
  • never mind, this stopped working for me after the 3rd or 4th reboot (doesn't mean this won't continue to work for others), the default card was set appropriately, but still failed to output audio (I couldn't get it working again), so I fixed it by removing it (yes the card still works, it's not a hardware problem) after finding I could use my headphone out for my rear speakers, which has yet to give me a problem. – Tcll Nov 29 '18 at 14:42
0

I personally use alsamixer

alsamixer

Hit F6 to select sound card.

enter image description here

| improve this answer | |
  • 5
    F6 only lets you choose which card to modify sound levels for, no? – MarkovCh1 Jun 15 '12 at 0:22
  • 3
    Sets the selected card as default as well (at least it does for me). – Panther Jun 15 '12 at 1:33
  • 3
    You can select card with alsamixer (F6 or S) and than do sudo alsactl store to save your settings as default. – dmitry_romanov Dec 8 '15 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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