Jump to content
The Dark Mod Forums

How to configure the sound system on Linux


MirceaKitsune

Recommended Posts

Ever since I first installed TDM on my Linux machine, there has been just one problem that would never let me enjoy the game in peace: The audio system. Sound will either simply not work, work but constantly flicker, or lag behind as the game goes on. Every now and then I had to adjust the sound settings to get better results... and in doing so I got a hang of what the possible configurations are. I decided to share this info here, for others who are struggling with untangling the buggy sound system.

 

In essence: If you are running The Dark Mod on Linux, you have 3 options for sound, each with its own potential set of problems: PulseAudio, ALSA, or OSS.

 

  • PulseAudio

This is what TDM will try to use by default, when s_driver = "best" and s_alsa_pcm = "default". This is theoretically using ALSA, but the PulseAudio device instead of specifying your own. Sticking with this option should guarantee that the correct audio device is used, but it has one problem: Sound flickers and lags.

 

Solution: The only easy solution is increasing the PA latency for the console you're running TDM in, by modifying an environment variable. Simply run the engine as follows... you can also put this in a TDM.desktop shortcut to do it automatically: "export PULSE_LATENCY_MSEC=60;./thedarkmod.x86".

 

  • ALSA

If the above doesn't work out for you, the second best option is selecting your ALSA device manually. It should guarantee that there are no sound issues and you get the best playback. The downside is that pointing it to the right audio device can be tricky and might not work at all sometimes.

 

Solution: First make sure that s_driver = "alsa". Then up open bash and type "aplay -l" or "aplay -L" to get a list of your audio devices. Identify the name of the one you wish to use, then set s_alsa_pcm to it. For example, you will want to have something like this: s_alsa_pcm = "front:CARD=Intel,DEV=0". Alternatively you can use device numbers directly, such as "plughw:0,0" or "hw:0,0". Simply using "sysdefault" instead of "default" is also said to have solved the problem for some. You might have to try all of these options and devices until you find the one that works.

 

  • OSS

If both of the above options fail, OSS is the third path to take. The good part is that it might work at all... the bad part is that it's mostly deprecated nowadays, meaning your distribution might not support it or it can produce sound issues of its own. Therefore this should be considered the last resort.

 

Solution: Set s_driver = "oss" in the settings. You must also run TDM through aoss for audio to work now, so set your TDM.desktop shortcut to: "aoss ./thedarkmod.x86".

Link to comment
Share on other sites

It really is stunning how today's software engineers can't even make low-latency audio come out of 3+ GHZ multi-core computers with gigabytes of RAM. This is especially so, when we played Quake on machines at ~100 MHz without this problem. This is not the fault of TDM, its PulseAudio. My solution to this is to uninstall it wherever and whenever I find it. I use vanilla ALSA and it just works 99.99 % of the time. It can do software mixing, and record audio...

 

I do not understand why PulseAudio is still suffering from these problems. It isn't the job of everybody who ever wrote an audio playing app to modify it to be compliant with PulseAudio, especially when PA claims to be a drop-in alternative to ALSA.

Link to comment
Share on other sites

AFAIK, PulseAudio makes it easier for multiple programs to use sound simultaneously, and there are good reasons for its existence. I never tried uninstalling it, but there are several games which require that latency override to not have glitched sound, which is indeed a big fail on its end and suggests it needs better default settings.

Link to comment
Share on other sites

Alsa can do sound mixing just fine. I can listen to music and play TDM with sound, or even a text-to-speech system in the background reading something to me.

 

What it can't do is dynamically swap audio between devices like a sound card and a bluetooth headset while the program is running. Some would argue that such a feature is critical for a modern platform. I would argue that not that many people use Bluetooth headsets compared to traditional ones, and it is more important for the audio to just work in most cases than to give this up to support a somewhat uncommon scenario.

Link to comment
Share on other sites

It really is stunning how today's software engineers can't even make low-latency audio come out of 3+ GHZ multi-core computers with gigabytes of RAM. This is especially so, when we played Quake on machines at ~100 MHz without this problem. This is not the fault of TDM, its PulseAudio. My solution to this is to uninstall it wherever and whenever I find it. I use vanilla ALSA and it just works 99.99 % of the time. It can do software mixing, and record audio...

 

I do not understand why PulseAudio is still suffering from these problems. It isn't the job of everybody who ever wrote an audio playing app to modify it to be compliant with PulseAudio, especially when PA claims to be a drop-in alternative to ALSA.

 

You can't really compare the old audio to today audio, i know because i lived through it, back then audio was for the most part wave files at 22khz at some really low bitrate now they are wave/compressed files at 44khz or 48khz at 128 or higher bitrate, back then you had audio hardware acceleration from audio cards (the creative golden age), now audio is all software based (that means it is processed on the CPU for the ones that don't know) even on new Creative sound cards (they just take the CPU processed audio and make changes to it if necessary, like using EFX effects). Audio will improve when game developers stop relying more on graphics and on "good enough" audio and return to see it as a important immersion tool, and perhaps hardware acceleration will return.

Edited by HMart
Link to comment
Share on other sites

... But then there was Unreal. It featured absolutely kick-ass sound for the time, at up to 48 KHz with 32 effect channels, on top of the tracker music. It provided echo effects in software and the latency was low as long as you weren't using Windows NT. Literally everyone else mastered the sound problem forever ago. As a Linux fan, it is shameful that this is still a problem for us.

 

By just layering something else on top of the ALSA stack, the best you can hope for is slightly worse performance; (more RAM used and slightly higher latency due to the overhead).

Edited by kano
Link to comment
Share on other sites

I suspect PulseAudio works fine for games that are designed to use it (which they probably should be if they're expecting to be run on a modern Linux desktop, where for better or worse PulseAudio is the standard). What seems to be a problem is applications designed for direct ALSA access which are then redirected to PulseAudio using the pretend ALSA driver.

 

I can't comment on how easy or pleasant it is to write applications against the PulseAudio API since I've never used it, but nevertheless this is probably the way to go to solve these issues in TDM once and for all.

 

As for "Windows has solved this problem completely" - no, actually it hasn't. I have to switch to the crappy built-in audio hardware to play Windows games because my external USB sound device has a nasty habit of suddenly stopping working in the middle of a game, and trying to use the digital output with an external DAC gives continuous clicking and popping. Clearly latency and direct access issues are present on Windows too.

Link to comment
Share on other sites

As for "Windows has solved this problem completely" - no, actually it hasn't. I have to switch to the crappy built-in audio hardware to play Windows games because my external USB sound device has a nasty habit of suddenly stopping working in the middle of a game,

Why not get a PCIe version of youir USB card with digital out? I have an 'cheap-n-chearfull' Cmedia 8738 based PCIe sound card in my media PC and it works flawlessly.

Link to comment
Share on other sites

I have wireless headphones myself FYI. They use their own USB transmitter... there is a bluetooth mode but it never worked for me. I don't need to change my audio device on the run though, as I don't use other speakers.

 

Also a heads up: The instructions in the first post will depend on your version of the engine! With 2.03 I still get the audio flicker in PulseAudio even after changing the latency, whereas in 2.04 (SVN) I don't but I can no longer use my device through ALSA (currently set as "plughw:2"). So currently I'm sticking to ALSA, and once 2.04 is out I'll have to change back to PA.

Edited by MirceaKitsune
Link to comment
Share on other sites

Why not get a PCIe version of youir USB card with digital out? I have an 'cheap-n-chearfull' Cmedia 8738 based PCIe sound card in my media PC and it works flawlessly.

 

The external card I have (Fast Track Pro) is actually fairly decent, and having the external card dramatically reduces the amount of electrical noise that appears on the line out (due to power fluctuations on the motherboard as the CPU switches states). Of course the best fidelity is achieved with a digital out and then a totally separate (electrically isolated) DAC, but I don't currently have such a device. Using the digital input on my old minidisc deck is the closest I have to an independent DAC, and it's a PITA to use.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...