Making an (external) soundcard optional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I have a laptop and use an Aureon 5.1 USB card from Terratec at home,
and my internal sound card if I'm on the road. I am, of course, too lazy
to switch the default soundcard manually, so I wonder if there is a way
to either

i)  make the USB soundcard the default, and automatically use the other
    if the USB card isn't available
or
ii) use a multi device to dupe the audio stream to both cards that
    doesn't fail if one card isn't available, but silently ignores that
    and just plays on the other one.

Of course I could write a script that changes my ~/.asoundrc if the USB
card is available or not, if there is no sane way to do it with alsa.

At the moment, I have a setup like in ii), but currently it fails if the
USB card isn't plugged in. My ~/.asoundrc follows.

pcm.!default plug:both

ctl.!default {
   type hw
   card ICH6
}

# This creates a 2-channel interleaved pcm stream based on
# two 2-channel slave devices.

pcm.both {
   type route;
   slave.pcm {
       # create a virtual 4-channel device from two sound devices
       type multi;
       slaves.a.pcm "intel8x0";
       slaves.b.pcm "aureon";
       slaves.a.channels 2;
       slaves.b.channels 6;
       bindings.0.slave a;
       bindings.0.channel 0;
       bindings.1.slave a;
       bindings.1.channel 1;

       bindings.2.slave b;
       bindings.2.channel 0;
       bindings.3.slave b;
       bindings.3.channel 1;
       bindings.4.slave b;
       bindings.4.channel 2;
       bindings.5.slave b;
       bindings.5.channel 3;
       bindings.6.slave b;
       bindings.6.channel 4;
       bindings.7.slave b;
       bindings.7.channel 5;
   }

   # Map two channels of input to four channels of output
   ttable.0.0 1;
   ttable.1.1 1;

   ttable.0.2 1;
   ttable.1.3 1;
   ttable.0.4 1;
   ttable.1.5 1;
   ttable.0.6 0.5;
   ttable.1.6 0.5;
   ttable.0.7 0.5;
   ttable.1.7 0.5;
}

# Some programs will be unhappy if there is no mixer to talk to,
# so we set this to one of the cards.

ctl.both {
   type hw;
   card ICH6;
}

pcm.aureon {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:1"
        period_time 0
        period_size 2048
#        buffer_size 8192
        buffer_size 65536
        buffer_time 0
        periods 128
        rate 48000
        channels 6
     }
     bindings {
        0 0
        1 1
        2 4
        3 5
        4 2
        5 3
     }
}

pcm.intel8x0 {
    type dmix
    ipc_key 2048
    slave {
        pcm "hw:0"
        period_time 0
        period_size 2048
#        buffer_size 8192
        buffer_size 65536
        buffer_time 0
        periods 128
        rate 48000
        channels 2
     }
     bindings {
        0 0
        1 1
     }
}

ctl.aureon {
    type hw
    card "Audio"
}

ctl.intel8x0 {
    type hw
    card "ICH6"
}

Tobias

-- 
open STDOUT, "|-"
    and print "uJa tsonrehtP  lreahrekc"
    or  print pack "nN"x4, unpack "vV"x4, <STDIN>



------------------------------------------------------------------------------
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux