Use ALSA for KDE sounds


Building on my last post on Linux sound hacks I’m including this little gem. It’s a little bash script I wrote that plays an input parameter through ALSA. If you disable the KDE sound system you can use this shell script to push system sounds through ALSA. It assumes aplay, oggdec, and mpg321 are installed on your system. (I don’t remember their respective packages but you can use Synaptic to find them.) Here’s the code:

#!/bin/bash

case $1 in

   *.ogg) oggdec -Q -o - "$1" | aplay -q &
   ;;
   
   *.wav|*.voc|*.wav|*.au|*.raw) aplay -q $1 &
   ;;
   
   *.mp3) mpg321 -o alsa $1 &
   ;;
   
   *) echo "unsupported file type $1"
   ;;
esac

To use it you have to save it somewhere on your system and make it executable. (I put mine in $HOME/bin and madify my environment so that $HOME/bin is in my $PATH. Use chmod +x on the command line to make it executable.) Next go into your “System Notification” settings dialog in KDE. In the lower right corner there is a player settings button. Key in the path to the file that you saved, hit apply, then hit ok and you’re all set. If you want you can easily compare the sound that the script gives you with the sound that the KDE sound system gives you (using the player settings dialog) to hear the difference.

Why?
In my experience the KDE sound system plays sound choppy and not as high quality as ALSA. I’ve also had far too many other issues when the Sound system was running than I care to explain. Try my hack and tell me what you think.

6 thoughts on “Use ALSA for KDE sounds

  1. Amazing, been meaning to shut artsd off, it just gets in the way! Though applications that access sound through alsa seem to be happy with artsd hogging /dev/dsp, most binary-only software (Skype, Parallels) isn’t.

    Great work!

  2. Thanx Lad,

    From my experience ALSA plays well with artsd when you enable the ALSA sink in arts. As I get time I’ll explore the issue in more depth and possibly come up with a better more complete analogy to explain it.

  3. Good tip caletron. That does basically what my above script does. I don’t have esdplay installed by default on my distro though. Also I’m not sure how ESD would share with Alsa. I’d have to think that it’s better than ArtsD.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s