ALSA Device Order

Sound cards changing order on each boot

Problem

I have two sound cards in this machine:

 0000:00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)
 0000:01:08.0 Multimedia audio controller: Ensoniq 5880 AudioPCI (rev 02)

The first is an on-board devices and uses the snd-intel8x0 module, the second is a Sound Blaster 4.1 PCI card, which uses the snd-emu10k1 module.

Sound cards changing order on each boot

Problem

I have two sound cards in this machine:
 0000:00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)
 0000:01:08.0 Multimedia audio controller: Ensoniq 5880 AudioPCI (rev 02)
The first is an on-board devices and uses the snd-intel8x0 module, the second is a Sound Blaster 4.1 PCI card, which uses the snd-emu10k1 module. On startup the system loads both of the modules automatically, however the order this happens changes on each startup. This causes them to be assigned different ALSA device IDs - when I have specific cards selected in applications, this then causes the audio to come out of the wrong device. It's possible to list ALSA devices through the /proc filesystem:
$ cat /proc/asound/cards
0 [AudioPCI    ]: ENS1371 - Ensoniq AudioPCI
           Ensoniq AudioPCI ENS1371 at 0xb400, irq 209
1 [nForce2    ]: NFORCE - NVidia nForce2
           NVidia nForce2 with ALC658D at 0xe8081000, irq 201
This shows the Sound Blaster as the primary card (0) and the on-board as the secondary (1).

Solution

Create a new file in /etc/modprobe.d/ (on Debian) called something sensible such as "sound-card-order" and in it, put this:
options snd cards_limit=2
options snd-emu10k1 index=0
options snd-intel8x0 index=1
Simply change the index numbers and modules for your own system configuration.