How do I select a default sound card with alsa?

Solution 1:

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

Solution 2:

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