Method for switching playback from one soundcard to another

Problems and successes with specific brands/models of computer audio hardware
Post Reply
Message
Author
User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

Method for switching playback from one soundcard to another

#1 Post by darkcity »

Greetings

I have a built in a soundcard VIA 8237 and a USB Audiobox.

I have found a method for switching playback from one card to another. Unfortunately it doesn't work on the fly, the audio app must be restarted for it to take effect (tested with Slacko 5.3.1 using Firefox and aplay).

It involves writing to /etc/asound.conf

NOTE assumes /etc/asound.conf contains only two lines, something like:
defaults.pcm.card 0
defaults.pcm.device 0


Please back up /etc/asound.conf before using code and or tinkering.


for switching soundcard 0, device 0 the bash code using sed-

Code: Select all

#switch to soundcard 0, device 0
asoundconf=/etc/asound.conf
sed -i '1s/.*/defaults.pcm.card 0/' $asoundconf
sed -i '2s/.*/defaults.pcm.device 0/' $asoundconf
for swtiching soundcard 1, device 0 the bash code using sed-

Code: Select all

#switch to soundcard 1, device 0 
asoundconf=/etc/asound.conf
sed -i '1s/.*/defaults.pcm.card 1/' $asoundconf
sed -i '2s/.*/defaults.pcm.device 0/' $asoundconf
I've written a script that toggles between card 0 and card 1, its very basic, improvements and suggestions welcome

Ref.
http://ptspts.blogspot.co.uk/2009/03/ho ... -have.html
http://alsa.opensrc.org/MultipleCards
Attachments
playbacktoggle.tar.gz
(802 Bytes) Downloaded 340 times

Post Reply