Main Menu

Projects

Linux Games
Linux Games
[HOWTO Home :: HOWTO INDEX Hardware :: This page]  

Sound and Teamspeak 2 Howto

Author: Tobias 'kung' Schleuss
Keywords: ALSA OSS

Creative Commons License
This work is licensed under a Creative Commons License.

Warning: This HOWTO comes with no explicit or implicit warranty whatsoever. Use at your own risk!

  1. Introduction
  2. General Notes
  3. About TeamSpeak 2
  4. Requirements
  5. Sound under Linux
  6. Information About The Sound System
  7. The Sound Devices
  8. Getting Started
  9. How to configure ALSA
  10. About OSS
  11. Setting up TeamSpeak 2
  12. Using arts, artsdsp
  13. Using dmix/dsnoop for recent games
  14. Troubleshooting
  15. Sources/ Related Links

1. Introduction

The methods described here have proven to work, though some state of the art techniques or are not treated here (udev devices instead of old device handling/mknod). In principal it is still valid. We have received a couple of comments, a recent one complaining about this "less than optimal" howto. So I considered to revise this howto and took a deeper look at the much lauded oss2jack, which tested weeks ago for the first time. This method disqualifies itself for our purpose.

  1. it only allows OSS applications to run, thus preventing i.e. alsa based applications from using the same device.
  2. it is based on jackd, which blocks one entire device even in alsa mode and is not able to share it i.e. through dmix
  3. in case you have more than one audio device our your card supports hardware mixing, you probably don't need to share the TS device anyways

It does not make a big difference if the mp3 player shares the sound device with TS or with the game you are running. So if you are running OSS only games, oss2jack may be an alternative for you. Other methods like ALSA's soft mixing feature "dmix" is of no use with TS (which does not support alsa), nevertheless it can be of benefit in combination with artsd, which is described in chapter 13) and is the major innovation in this howto version Meanwhile I have also tried the commercial OSS drivers. Their deinstallation routine is magnificent.

Up to now nobody came up with better methods (to run TeamSpeak and Games) than those described here, but if you have anny improvements in mind or want to write some hints to udev sound configuration pls contact us.

Update:Since aoss, the simple alsa-oss wrapper library improves with each ALSA version and now works fine with TeamSpeak, it will be probably the best solution for TeamSpeak and software mixing. Check out section 13 for that.

2. General Notes:

All commands used in the howto should be available on your system. I a program is missing, a package should be available for your distribution. If you do not know how to handle a command, a list of options is often available by "command --help". Also you can try to take a look at the man page of this command "man command" (replace "command" by the command of your choice). Some things in this howto are mentioned several times, its called redundance...

3. About TeamSpeak 2

Team Speak 2 (TS2) is a voice over ip tool, that allows you to talk to your team mates during game play. One advantage, besides being free, is, that it offers cross platform support.

4. Requirements

The most important thing for this HOWTO is a sound card with full-duplex support and at least one combined capture/playback plus one playback only device. This HOWTO does not address owners of soundcards, that support hardware mixing, like sblive etc. These sound cards work fine with several input/output sources at once without any tricks and workarounds. Also this HOWTO can not help users with "cheap" single device sound cards, (like AC97 systems). Those Users may take a look at this Forum Thread. It describes how to run several applications on single device sound chips using ALSA software mixing, which is supported since version 1.0.8. Furthermore you need a running X-Server and TeamSpeak 2. How to install the program itself is well documented on the TS2 homepage or you can use the tools shipped with your distribution if it inludes a TS2 package.

5. Sound under Linux

There are two major sound architectures for Linux. The older one is OSS (Open Sound System), its free parts were standard until the 2.4 kernel series. Note: Not all of it is open source, so some cards may only be supported in the commercial version of this driver. Since kernel 2.6 ALSA (Advanced Linux Sound Architectures) is placed into the kernel by default and OSS becomes obsolete. ALSA offers way more features and more flexibility. Its API includes backwards compatibility to OSS. ALSA also supports device sharing by several applications, which was not available with OSS. Additional sound demons like artsd or esd were necessary to achieve this functinallity. The ability of sharing a device is highly reliant on the applications itself. In general one can state: "If an application supports ALSA, device sharing is possible, otherwise it is not." Unfortunately TS2 does not support ALSA features and always blocks the entire device.

6. Information About The Sound System

This section shows how to gather some information about the sound system of your computer and its abilities. You can find information about supported sound cards in the ALSA Soundcard Matrix and detailed instructions on how to set it up at the ALSA documentation pages.

/sbin/lspci | grep audio

It displays all (pci) sound cards in your system. You can now look, if your sound card is supported by ALSA.

/sbin/lsmod | grep snd

It displays all ALSA modules currently loaded. You can see if the correct sound driver and alsa-oss emulation (snd_pcm_oss; snd_mixer_oss) are loaded.
Note: the sound driver may be compiled into your kernel and will not see these modules.

Once the ALSA drivers are loaded, the /proc file system provides some information about your sound system. It is available in most distributions nowadays.
Note: If you don't have /proc you can not get the following information.

cat /proc/asound/cards

cat /proc/asound/devices

The first command displays all sound cards used by alsa, the second shows the devices available on these cards.

For this HOWTO the combined capture/playback and playback only devices are important (see below). Cards and devices are numbered continuously, starting from zero.

cat /proc/asound/pcm

It displays a list of available playback and capture devices. Here you can see, whether your sound card is capable of playing game sound and using TeamSpeak at the same time. You Need one combined playback/capture device and one playback only device.

You can get much more information, about current device settings and so on, check it out on your own. One more thing for the use with alsa oss emulation I want to mention at this point.

cat /proc/asound/oss/devices

It displays information about all available oss devices. In the first column of the output you can see the minor device numbers, which might be of some importance later on.

7. The Sound Devices

7.1 General

Like all devices on linux the sound devices can be found in "/dev/". Sometimes they are placed in a subdirectory, like "/dev/sound/". In these cases a symbloic link (symlink) is placed in the main device tree. To see what sound devices are available on your system use the following command:

ls /dev/*dsp* -l

It displays all dsp and adsp devices that exist on your system.

ls /dev/sound/*dsp* -l

If the devices are placed in that subdirectory, replace "sound" by any other subdirectory that fits your system configuration. Note: some distributions don't care about devices physically available from the sound card and just create a whole bunch of devices there, so some (or most) of these devices don't really make any sens.
The option "-l" displays a long listing with additional information, like permissions, owner etc.. The numbers between group and date are the major and minor device numbers. (14 means sound device, afaik; the minor numbers were mentioned before).

Two devices should exist here at a minimum. The first one is called "/dev/dsp" or "/dev/dsp0" with minor number 3. It is the first device of the first sound card usually.

If neither device exists, make sure your sound card is supported on linux and the drivers for sound card and oss emulation are loaded properly. If it still does not exist you can create the device manually like described below.
For this howto it is important, that "/dev/dsp" is only a symlink.
First I describe the old way of creating devices on linux. Most of the actual linux distributions use udev to create the devices. If you know, that your distribution supports udev or if you are unsure scroll down to the bottom of this section and take a look at the example given there.

7.2 Old system devices - obsolete!!

(this old method is recommended for systems with 2.2 or 2.4 kernel series only not using udev or devfs)

Only if the device does not exist or if it is called "/dev/dsp" login as root and execute:

rm /dev/dsp

mknod /dev/dsp0 c 14 3

The first command deletes your "/dev/dsp" device, the second command (re)creates the primary sound device as dsp0.

The second device would be "/dev/adsp" or "/dev/adsp0" with minor number 12 or "/dev/dsp1" with minor number 19. As far as I know adsp devices have some extra functionality combined with alsa, but no major differences to dsp devices.
If the device does not exist make sure your sound card has a second (playback) device, as described above. Then you can add it to your linux devices

mknod /dev/adsp0 14 12

You may have several other sound devices, but they are not important for this howto.
Note: Usually the first device of each card is mapped to a dsp device, all following to adsp devices.

To have access to the devices as normal user you need to have read and write permission. To control these devices you should have the same permissions for the mixer device (/dev/mixer with minor number 0 usually).

You can change these permissions for owner and group

chmod 660 /dev/dsp0

chmod 660 /dev/adsp

chmod 660 /dev/mixer

Now change owner and the correct group if necessary. The groups settings can be found in "/etc/group".

chown root.audio /dev/dsp0

chown root.audio /dev/adsp

chown root.audio /dev/mixer

Make sure, that your user is in the correct group ("audio" in the example above).

If your system uses devfsd you can make all these changes in /etc/devfsd.conf. Please refer to other documentations on how to do that and take a look at the OSS section below.

Your sound card should work now and you can do a little test, that should result in some sort of noise or beep in your speakers.

cat /dev/urandom > /dev/dsp0

cat /dev/urandom > /dev/adsp

7.3 The new method:

Since most distributions nowadays use udev to create the devices I will give a short example here. With udev the devices on your system are defined by a set of rules, which can usually be found in /etc/udev/rules.d/. In my case I added the following lines to the main udev.rules file:

KERNEL=="dsp",          NAME="sound/%k",        SYMLINK+="sound/dsp0",  SYMLINK+="dsp0"

KERNEL=="adsp",         NAME="sound/%k",        SYMLINK+="dsp"

It causes the devices usually called "dsp" and "adsp" by the kernel (KERNEL==) to be created (NAME=) in the sound (subfolder of /dev/) with the usual kernel name (%k) and a symlink to be created in /dev/ and or /dev/sound/. I you need a different owner/group, than the ones created by default, you can add the GROUP and/or OWNER argument to these lines. Its even more safe to not modify the main rules file, but rather create a new one. For a detailed description how to write udev rules take a look at this howto. And take aswell a look at the udev manpage

8. Getting Started

For TeamSpeak a full-duplex capable sound card is necessary, to talk and listen at the same time. Also the card should have at least one combined playback and capture device plus one additional playback only device, to hear in game sound, while using TeamSpeak.
In theory ALSA supports simultaneous access to one sound device by several applications, but the program has to support that.TeamSpeak whatsoever is not (yet??) capable of that. It always blocks the entire device, and no trick worked so far. Onboard sound cards often have one single device only, so a different sound card is needed. I took a SB PCI 128, which I can recommend at this point.

9. How to configure ALSA

If you are using the ALSA sound drivers, make sure the necessary modules are loaded (card-driver and oss emulation). In my case it would look like that:

modprobe snd-ens1370

modprobe snd-pcm-oss

Other modules necessary (like snd-mixer-oss) should be loaded automatically.

With ALSA and /proc there is another way to gather information about the sound system

ls /proc/asound/card0/

The listing should include something like pcm0p pcm0c pcm1p; these PCM streams can also identify what playback and capture devices your sound card offers (/proc/asound/cardX/pcmY[cp]/oss, where X is the card number, Y the PCM device number, both starting with zero, and p is for playback and c for capture). These pcm devices are needed, as shown below.

A problem with some popular games, like the quake series, wolfenstein i.e. is, that they can not handle the ALSA oss emulation and need to have direct access to the sound device.
Unfortunately they use /dev/dsp by default and there is no easy way to change that. TeamSpeak needs the combined device, which is usually the first device of the sound card. Thats why I mentioned earlier, that "/dev/dsp" needs to be a symlink. In case of ALSA the playback only device is called /dev/adsp (may also be i>/dev/dsp1 depending on your sound card).
Depending on your sound card and configuration it may direct to /dev/sound/dsp, /dev/sound/dsp0 or /dev/dsp0. Now it is sufficient to link "/dev/dsp" to the playback only device like that:

ln -sf /dev/adsp /dev/dsp

(Depending on your distribution you may need to take an other device than "/dev/adsp". Like described earlier look for the sound device with minor device number 12 or 19 and link that one. In case both exist I recommend the one belonging the one belonging to the card of the combined device)

You may also redirect the combined device if its a symlink, but thats not necessarily necessary.... If you want to make these changes permanent with devfsd, have a look at the OSS section below.

Now you have to tell some games to use the playback only device (take this list as an example):

echo "quake3.bin 0 0 direct">/proc/asound/card0/pcm1p/oss
echo "quake3.x86 0 0 direct">/proc/asound/card0/pcm1p/oss
echo "quake3-smp 0 0 direct">/proc/asound/card0/pcm1p/oss
echo "wolfsp.x86 0 0 direct">/proc/asound/card0/pcm1p/oss
echo "wolf.x86 0 0 direct">/proc/asound/card0/pcm1p/oss
echo "et.x86 0 0 direct">/proc/asound/card0/pcm1p/oss

To get TS2 running with games like quake it may be necessary to disable capture for this game in a similar way. Add a second line for each game, but now take the capture device:

echo "et.x86 0 0 disable">/proc/asound/card0/pcm1c/oss
echo "quake3.x86 0 0 disable">/proc/asound/card0/pcm1c/oss
(Thanks to bdove for this information at this point)

10. About OSS

The OSS driver results in two sound devices dsp0 and dsp1, either directly in /dev/, sometimes in a subdirectory, like "/dev/sound".

If devfsd is used by your system, you can setup the devices in /etc/devfsd.conf, the following lines need to be added

REGISTER        ^sound/dsp1     CFUNCTION GLOBAL mksymlink /dev/sound/dsp1 dsp
UNREGISTER      ^sound/dsp1     CFUNCTION GLOBAL unlink dsp
REGISTER        ^sound/dsp    CFUNCTION GLOBAL mksymlink /dev/sound/dsp dsp1
UNREGISTER      ^sound/dsp    CFUNCTION GLOBAL unlink dsp1

If you are not using devfsd, follow the instructions given earlier (delete /dev/dsp if necessary, create /dev/dsp0 etc.)

ln -sf /dev/dsp1 /dev/dsp

It crates a symlink /dev/dsp to the playback only device.

Note: replace "/dev/dsp1" by your playback only device (for example /dev/sound/dsp1 /dev/adsp0), if necessary.

11. Setting up TeamSpeak 2

If it is not included in your distribution you first need to download the TS2 Client and install it following the instructions given in the readme file included in the package.

In TeamSpeak "-> Settings -> Options -> Sound Devices (folder)" you can now change the sound driver to the combined device /dev/dsp0, while the games are still using /dev/dsp and don't even recognize, they're using the playback only device...
Now make sure the microphone is activated for capture. Activate microphone boost if the microphone is too silent. If you recognize some echo while talking check, whether the pcm device is activated and deactivate it for capturing. Also deactivate playback for the microphone.

12. Using arts, artsdsp

Meanwhile linux offers several possibilities to run more than one application over a single sound device. While ALSA's software mixer "dmix" is probably the most elegant way, the use of a sound daemon like artsd or esd is very common. To use dmix, the application needs to support it, which is not the case for TeamSpeak. For the sound daemons either the application supports it (like KDE applications support artsd) or the accesses the sound device directly. In that case a wrapper can be used can be used to remap the sound output to the daemon. The method described here is based on artsd and its wrapper artsdsp, note that for esd there is a wrapper called esddsp, which might work in a similar fashion.
To our knowledge only the use of a sound daemon is the only way to run TeamSpeak2 plus a game over a single device sound card without hardware mixing, since there is no alsa support in TS2.

First set up ARTS.

Go to KDE Control Center, Sound & Multimedia, Sound System. Yes, you gonna check that checkbox 'Activate the sound system'. No, there's no workaround. Now make sure you're not running the soundserver with realtime priority and uncheck the automatical shutdown too.
On the next tab choose ALSA as a backend, "default" as a sound device and check the 'Full duplex' checkbox. Click Apply. So, now the KDE sound server is running and wasting your worthful CPU cycles.

Now tell Teamspeak to use ARTS.

Open the TeamSpeak launch script (in your TeamSpeak folder) with your favored editor and change the second line: from your/install/dir/TeamSpeak2/TeamSpeak.bin $* to artsdsp -m your/install/dir/TeamSpeak2/TeamSpeak.bin $*

Then you can start TeamSpeak and afterwards your game or application in a similar way:

artsdsp -m quake3

That way it is possible to play with sound, use TeamSpeak and even listen to your favored music at once.

Using this method, some players recently complained about a one second delay between a shot in ut2003 and the corresponding sound. I've also experienced that problem before, but didn't remember the solution. So I checked it out again and here is how to solve it:
The "real time" and "full duplex" options didn't have an effect on it, but I soon recognized, that the "audio buffer" has a direct effect on the "response time". I recommend to change these settings in the KDE Control Center (->Sound&Multimedia->Sound System->Sound In-/Output). Move the regulator to the very beginning (highest CPU load, fastest reaction ...).
(But you can also start artsd manually like this:

/usr/bin/artsd -F 6 -S 256 -a alsa -d -m artsmessage -l 3 -f

13. Using dmix/dsnoop for recent games

Update:

The latest ALSA versions already include sample .asoundrc files installed globally so you usually don't have to setup the .asoundrc file. Also the aoss wrapper, the most simple and resource saving tool to add the software mixing capabilities for OSS only applications works fine with TeamSpeak. So if you are unsatisfied with ARTS latency or its cpu usage, try TeamSpeak with aoss:

aoss your/install/dir/TeamSpeak2/TeamSpeak

aoss works fine with scripts too so you don't even have to modify the TeamSpeak startup script.

If your games don't support alsa natively, there're good chances they'll work with aoss too. Just put "aoss" in front of the game startup command, like this:

aoss coldwar

Recent titles like Quake4 include alsa support, but may not work using old oss drivers or alsa-oss emulation. Thus the sound daemon/wrapper method described above is of no use for them but still the only way to run TS2. Here ALSA's software mixer "dmix" is doing the trick. Since the sound daemon has alsa support aswell as the game we can it using soft mixed device. First make sure you have a recent version of ALSA. Now you have to create a file called .asoundrc in your users home directory (for a detailed description about how to set up dmix or other alsa plugins take a look at the links below). My .asoundrc looks like this (you may want to copy&paste it):

pcm.card0 {
        type hw
        card 0
        mmap_emulation true
}

pcm.!playback { type dmix # dmix plugin for mixing the output ipc_key 1234 # an uniqe number slave { pcm "card0" period_time 0 period_size 1024 buffer_size 8192 rate 44100 } bindings { 0 0 1 1 } }

pcm.!capture { type dsnoop # dsnoop plugin for input ipc_key 5678 # another uniqe number slave { pcm "card0" period_time 0 period_size 1024 rate 44100 } }

# # combined playback/capture device # pcm.!duplex { type asym playback.pcm "playback" capture.pcm "capture" }

# # making the playback/capture device default # pcm.!default { type plug slave.pcm "duplex" }

# # for oss compatibility (maybe) # pcm.!dsp { type plug slave.pcm "duplex" }

ctl.!mixer0 { type hw card 0 }

Now after restarting artsd from the KDE command center, it should access the default dmix device, while the game with ALSA support can aswell access that device. For older games without ALSA but OSS support you can still use the wrapper method described above.

Update:

The latest ALSA versions already include sample .asoundrc files installed globally so you usually don't have to setup the .asoundrc file. Also the aoss wrapper, the most simple tool to add the software mixing capabilities for OSS only applications works fine with TeamSpeak. So if you are unsatisfied with ARTS latency or its cpu usage, try TeamSpeak with aoss:

aoss your/install/dir/TeamSpeak2/TeamSpeak

aoss works fine with scripts too so you don't even have to modify the TeamSpeak startup script.

14. Troubleshooting (for ALSA drivers)

The troubleshooting section deals with the alsa driver, since it is included in the latest kernel series (a must have for gamers) and makes the old OSS drivers obsolete.
I've made the experience, that "alsamixer" is not capable of handling all features of a sound card. Therefor I recommend to use "gamix", which is the most feature rich mixer I've seen so far.

i) Microphone does not work (in TS)

Is the microphone working at all?
Use your mixer to activate "microphone boost". Make sure "capture" is enabled for the microphone. Also activate "playback" for the microphone. Now you should be able to talk and directly hear your words.

Do you use the correct device?
In TS "-> Settings -> Options -> Sound Devices (folder)" make sure to mark the field "other" and enter the combined (capture/playback) device.
In TS "-> Settings -> Sound Input/Output Settings" mark "Voice Activation" and check that the control is not in position "shout" (middle should be OK)

Most distributions use alsactl to restore the mixer settings between reboots. The config-file is /etc/asound.state, and there is an entry

   control.39 {
                 comment.access 'read write'
                 comment.type BOOLEAN
                 iface MIXER
                 name 'Mic As Center/LFE'
                 value false
         }

(the number 39 is pretty sure different for others... the important part is Mic As Center/LFE) . The value has to be set to false in order to use a microphone! Thanks to the guy - whose nick I don't know - for that hint..

To store your current alsa mixer settings to /etc/aousnd.state, execute as root:

alsactl store

A hint from gladiac for those, who use alsamixer:
Move the volume slider of the microphone to the minimum
Move capture auf von Mic almost to the top and
activate the +20db MicroBoost.

ii) No sound (at all/ in TS)

Check if the mixer volume is turned up, all ALSA devices are muted by default and check if the card drivers are loaded.

lsmod | grep snd

Several lines should appear including your sound card driver module. If they do not try to load the module manually (refer to the ALSA documentation how to do that)

Check, if the oss modules are loaded.

lsmod | grep oss

"snd_pcm_oss" and "snd_mixer_oss" are the important modules.

If the modules are loaded correctly you can get information from the /proc file system:

"cat /proc/asound/cards" to see the soundcard(s) used by alsa
"cat /proc/asound/pcm" to see the pcm devices available with playback and capture capability

By default the devices are mapped in the following way:

00-00 (first card, first device) -> /dev/dsp0 (maybe /dev/dsp)
00-01 (first card, second device) -> /dev/adsp0 (maybe /dev/adsp)
01-00 (second card, first device) -> /dev/dsp1
01-01 -> /dev/adsp1
...

Only the first device of a card is mapped to /dev/dspX usually all following devices are /dev/adspY devices, where X,Y are continuous numbers. But in some distributions it might be different.

Make sure the sound devices exist on your system.

ls /dev/*dsp* -la

In some cases all these are symlinks. Change to the appropriate directory, vor example "cd /dev/sound" and repeat the listing "ls *dsp* -la".
You should see as many devices as displayed in /proc/asound/pcm. If you don't see them you can try to add the devices manually using "mknod".

For example:
"mknod /dev/dsp0 c 14 3" The most important primary device (14 is the major 3 the minor device number)
"mknod /dev/adsp0 c 14 12" The adsp device, often the playback only device
"mknod /dev/dsp1 c 14 19" The second pcm/oss device (if available)

Now you can create symlinks to /dev/dsp and /dev/adsp, as I described before.

An easy way to test these devices is:

cat /dev/urandom > /dev/dsp0 (or any other available sound device). It should result in some sort of noise in your speakers.

Check if other applications are using your sound devices

lsof | grep dsp (lists all files accessing a dsp or adsp device)

To kill all applications blocking a device you can use the command fuser -k /dev/dsp (replace /dev/dsp by whatever device is blocked)

iii) Device not found error or no output on secondary device

The reason for a non working sound device (/dev/adsp i.e.) with correct major and minor device number, that seems to be availabe (in the device tree as in the /proc output) may be:
On newer soundchips this device often belongs to an optical/digital output and can only be used with a proper speaker system.

15. Sources/ Related Links

http://www.linux-gamers.net/
http://www.goteamspeak.com/
http://www.alsa-project.org/alsa-doc/
http://www.alsa-project.org/~iwai/OSS-Emulation.html
http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
http://alsa.opensrc.org/index.php?page=Dmix+Kde+-+arts%2C+ESD+and+SDL+quick+and+dirty+HOWTO
http://www.spotlite.de/blog/archives/534-Alsa-ueber-mehrere-Soundkanaele-Softmixer.html
http://www.linux-gamers.net/modules/newbb/viewtopic.php?topic_id=1705&forum=6
http://alsa.opensrc.org/DmixPlugin
Man and Info pages to devfsd and devfsd.conf

*/
Last modified: 04.01.10 by GlaDiaC  

Comments

 Re: Sound and Teamspeak 2 Howto

Posted: 2007/11/12 0:04  Updated: 2007/11/12 0:04

TTimo


Joined: 2007/11/11
From:
Posts: -1
That's a pretty complete article. I ended up here while trying to get Q3 + TS working with an EMU10K1 card.

Sadly I couldn't get it going yet. I applied the udev changes (for some reason Debian Sid does none of that), and /dev/dsp symlinks to /dev/adsp

But .. in my /proc/asound/card0/pcm*, I don't have a playback only device that also has an OSS entry. I have:

# ls -d pcm*
pcm0c pcm0p pcm1c pcm2c pcm2p pcm3p

but no pcm3p/oss
The comments are owned by the poster. We aren't responsible for their content.
Linux Games
Linux Games
Terms of Use · Privacy Policy · Creative Commons License · Credits · Linux Games · Linux Games · World Time · Vereins Intern