TIP: Switching Soundcards In Ubuntu
If you have multiple soundcards in your system and have to switch between them regularly (e.g. laptop owners like me, who use an external soundcard while being docked to groove to the highest and the lowest of frequencies through those 7.1 channels and use the in-built sound card while on the move) you would definitely be under-whelmed by the less-than-stellar performance of ubuntu in switching between the sound cards. For me at least, ubuntu (fiesty 7.04 amd64) never seems to recognize that I’ve connected the speakers to my Audigy 2 ZS Notebook PCMCIA card, and merrily continues to huff-puff through the tinny laptop speakers until I manually go into the sound preferences, switch over to multichannel playback and vice versa. Well, I still haven’t found an automated solution for the switching, but here is a little cli-magic to do this in a click.
If you have alsa on ur system, just use the command “asoundconf list” first to list out all the soundcards connected to your system. e.g. on my system, the output is
$asoundconf list
IXP
AUDIGY2
Here, IXP is my internal sound card and AUDIGY2 is my external (PCMCIA) sound card. Now, all you need to is use “asoundconf set-default-card ” to switch over to any card desired. So, what I did was make 2 bash scripts, and insert this command in them with each having one of my soundcards’ names.
script 1 - setixp.sh
#!/bin/bash
asoundconf set-default-card IXP
Similarly, script 2 - setaudigy.sh
#!/bin/bash
asoundconf set-default-card AUDIGY2
Now, all that remains is save the two scripts (maybe in ur home directory or ur desktop), and make them executable (use “chmod +x ”). Now, whenever you want to switch to a card, just double-click on the appropriate script, and watch the sound getting redirected. oops, make that “hear” the sound :P.