Skype for Linux — ALSA Configuration

ALSA configuration window

Skype ALSA configuration window
In Skype showing list of hardware devices only

Skype ALSA configuration window
In XMMS featuring selection list with text input where you can enter custom ALSA device name (skype in here)
Once we have ALSA support in Skype we can use it configuration flexibility to use any combination of sound cards and speakers/headphones/microphone connected to them.

As of Skype 1.3.0.30 BETA there are a few limitations:
The current workaround is to actually redefine default ALSA configuration so Skype use configuration we want. Given that we have full flexibility of how to setup our sound system.

Typical ALSA configuration can be done in on of two places: global /etc/asound.conf and user's ~/.asoundrc. You can edit either.


Examples:

Setup second sound card as a default

I have two cards: onboard C-Media & Sound Blaster. I want Skype to use Sound Blaster.
#C-Media card (first)
pcm.cmedia {
    type	hw
    card	0
}

#Sound Blaster card (second)
pcm.soundblaster {
    type	hw
    card	1
}

#I define 'skype' alias for the card I want to use
pcm.skype {
    type    plug
    slave.pcm "soundblaster"
}

#since there is no way in skype to tell we want to use 'skype' device, we need to force it as default
#(yes, the exclamation mark before default)
pcm.!default {
    type    plug
    slave.pcm "skype"
}
  

Speakers on one sound card, microphone on another

You can further extend the configuration to support virtually any combination of sound devices.

I want to use microphone from Sound Blaster (second sound card), but headphones are connected to the C-Media (first sound card).
#C-Media card (first)
pcm.cmedia {
    type	hw
    card	0
}

#Sound Blaster card (second)
pcm.soundblaster {
    type	hw
    card	1
}

#define "skype" device
#in the future (I hope) we will be able to configure Skype to use it directly
pcm.skype {
  type asym

  playback.pcm "cmedia"        #cmedia for playback
  capture.pcm "soundblaster"   #soundblaster for recording
}

#define the default device (currently used by Skype always)
pcm.!default {
  type                  plug
  slave.pcm             "skype" 
}

Cards with multiple sound channels (eg 5.1 cards)

If the sound card has multiple channels, eg. surround 5.1 card you may need to create a device that will route stereo sound (eg. from skype) to some or all channels of the card.
pcm.soundblaster-front {
  type route
  slave.pcm surround51:0 # :0 here is 1st hardware card (hw:0,0)
  slave.channels 6
  ttable.0.0 1 #left stereo channel to left front channel
  ttable.1.1 1 #right stereo channel to right front channel
}

You can also route the sound to the other speakers (eg. rear ones). It's up to you to use rear speakers port to connect a headset, while having main (front) port with standard stereo speakers.
pcm.soundblaster-rear {
  type route
  slave.pcm surround51:0 # :0 here is 1st hardware card (hw:0,0)
  slave.channels 6
  ttable.0.2 1 #left stereo channel to left rear channel
  ttable.1.3 1 #right stereo channel to right rear channel
}

pcm.skype {
  type                  plug
  slave.pcm             "soundblaster-rear" 
}

If you would like to hear your stereo sound through all 5.1 speakers at the same time you can configure that too:
pcm.soundblaster-2to51 {
  type route
  slave.pcm surround51:0 # :0 here is 1st hardware card (hw:0,0)
  slave.channels 6
  ttable.0.0 1 #left stereo channel to left front channel
  ttable.1.1 1 #right stereo channel to right front channel
  ttable.0.2 1 #left stereo channel to left rear channel
  ttable.1.3 1 #right stereo channel to right rear channel
  ttable.0.4 0.5 #(mix) left stereo channel to center speaker
  ttable.1.4 0.5 #(mix) right stereo channel to center speaker
  ttable.0.5 0.5 #(mix) left stereo channel to subwoofer
  ttable.1.5 0.5 #(mix) right stereo channel to subwoofer
}

Software mixing

Some sound cards cannot do hardware mixing (eg. play from two sources simultaneously). In this case application would have to wait until the device is free. ALSA do software mixing, so the problem is nonexistent.
If you experience such problems (Device not available messages or so) add below dmix configuration.
#define software mixing device 
#hw:0,0 stands for hardware sound card 0, cannot use 'cmedia' alias here
pcm.cmedia_dmix {
    type dmix
    ipc_key 1024 # must be unique!
    slave {
	pcm "hw:0,0"
	period_time 0
	period_size 1024
	buffer_size 8192
	rate 44100      #this may be unnecessary (but it is on my machine)
    }
}

#"skype" device definition that use mixing device
pcm.skype {
  type asym

  playback.pcm "cmedia_dmix"
  capture.pcm "soundblaster"
}

Other applications

If you want other (ALSA aware) programs use first (non-default) sound card, you will need to pass them the device name. It could be:

Make skype use 'skype' device using skype_dsp_hijacker

Until we have proper solution for selecting custom ALSA devices in Skype itself there is workaround that can be used to avoid changing the default system sound device.

skype_dsp_hijacker (version 0.8+) can tell ALSA to use 'skype' device instead of 'default', so you can skip sections that change pcm.!default in above examples.

Remember to compile skype_dsp_hijacker with command
make CFLAGS=-DHAVE_ALSA

Resources




→ Go back to Skype for Linux Resources page
2006.07.04, Jan SÅ‚upski, email: jslupski at juljas dot net