Howto Install OSS4 in ubuntu 10.04 (Lucid) for better sound quality

Sponsored Link
After upgrading to Ubuntu 10.4 LTS, I was happy to notice that audio in all applications (including Skype) was finally working perfectly! However, I was less happy to notice that Pulseaudio was using quite a lot of CPU-time, and that the sound quality was absolutely awful... So I decided to give OSS4 a try. After some googling, installing a few packages and some minor configuration, OSS4 was up and running, and I must admit the improvement in sound quality is rather significant!

  • In a terminal, run sudo dpkg-reconfigure linux-sound-base
    Choose OSS. This should, among other things, prevent the ALSA modules from loading. Reboot.
  • There are (at least) three ways to install OSS4:
    • Install from the Ubuntu repositories:
      sudo apt-get install oss4-base oss4-dkms oss4-source oss4-gtk
      This will automatically rebuild the OSS modules when your kernel is updated, and is the preferred way of installing third-party kernel modules. However, the oss4-dkms package is currently broken for Ubuntu (bug #519577), so for the time being use the package from the Opensound website (recommended, see below) or from this PPA (not recommended as it currently breaks sound in the Adobe Flash plugin).
    • Download the OSS4 binaries as a DEB package from http://www.opensound.com/download.cgi and install it. This is currently the easiest way, but you'll manually need to reinstall the package every time your kernel is updated. Also, this package is not GPL but has a commercial one-year license.
    • Fetch the source from the Mercurial repository and compile the package yourself, as described in https://help.ubuntu.com/community/OpenSound
      This will give you the latest GPL-version of the drivers.
  • If you get errors about snd_pcm being in use, try rebooting and running sudo soundon. If the problem persists, use lsmod to check if any ALSA modules are still loaded. If so, blacklist them manually. For instance, I had to blacklist the saa7134_alsa module by creating a configuration file /etc/modprobe.d/blacklist-saa7134_alsa.conf with the line blacklist saa7134_alsa
  • Either configure Pulseaudio to use OSS4 or remove it altogether.
    • To configure Pulseaudio with OSS4:
      Edit the default configuration file: gksu gedit /etc/pulse/default.pa
      Comment out the modules for automatic hardware detection.
      Add the following line:
      load-module module-oss device="/dev/dsp" sink_name=output source_name=input mmap=0
    • To remove Pulseaudio:
      sudo apt-get remove pulseaudio
      You will have to manually restore the volume manager icon to your panel later.
  • Configure Gstreamer for OSS4 output:
    Install gstreamer0.10-plugins-bad
    Run gstreamer-properties and set input and output to OSS.
  • Set up ALSA (or rather libasound) to output through OSS4 instead of the native ALSA drivers. Create a configuration file:
    gedit ~/.asoundrc

    Insert the following:

  •  pcm.!default
     {
       type oss
       device /dev/dsp
     }
     mixer.!default
     {
       type oss
       device /dev/dsp
     }
    
    
  • Add the following PPA to your Software Sources and run update-manager: https://launchpad.net/~dtl131/+archive/ppa
    This will enable Gnome audio output and volume management to use Gstreamer instead of Pulseaudio.
  • Right-click over your panel, select "Add to panel" and add the volume control applet. Alternatively, you can add a button to your panel or menu to start the OSS4 mixer (/usr/bin/ossxmix) instead of the normal Gnome volume manager.
  • Configure applications that natively support it (e.g. Audacious, Audacity, Kdenlive, SMPlayer, VLC, Wine, etc.) to use OSS output. Many applications don't (or no longer) have native support for OSS. This is no problem, these should continue to work fine through Gstreamer or ALSA emulation (or Pulseaudio if you decide to keep it).
  • After removing Pulseaudio, it could be that Rhythmbox or Movie Player start to complain about missing audiosink plugins. In that case you'll need to manually change some Gconf-keys. Start gconf-editor. Open system/gstreamer/0.10/audio/default. Check if any keys (e.g. musicaudiosink and chataudiosink) are still set to "pulsesink". If so, change them to "osssink".

Reverse back your changes

  • In a terminal, run sudo dpkg-reconfigure linux-sound-base
    Choose ALSA. Reboot.
  • Remove the libasound configuration file: rm ~/.asoundrc
  • Reinstall Pulseaudio and associated packages: sudo apt-get install pulseaudio indicator-sound libcanberra-pulse pulseaudio pulseaudio-esound-compat pulseaudio-module-bluetooth pulseaudio-module-gconf pulseaudio-module-x11 ubuntu-desktop ppa-purge
  • Restore the original Pulse-based Gnome volume manager: sudo ppa-purge ppa:dtl131/ppa
  • Configure Gstreamer for Puseaudio output by running gstreamer-properties and setting input and output to PulseAudio.
  • If you manually configured applications (e.g. Audacious, Audacity, Kdenlive, SMPlayer, VLC, Wine, etc.) to use OSS4, switch them back to Pulseaudio or ALSA-output.
  • Start gconf-editor. Open system/gstreamer/0.10/audio/default. Check if any keys (e.g. musicaudiosink and chataudiosink) are set to "osssink". If so, change them to "pulsesink".
  • Remove the OSS4 package using Synaptic or with sudo apt-get remove oss-linux. Optionally you can also remove gstreamer0.10-plugins-bad and ppa-purge now.

Credit goes here

Sponsored Link

You may also like...

19 Responses

  1. Mike says:

    PulseAudio uses a high quality resampling algorithm by default. ALSA supports only one, a simple linear resampler. If, like most people, you can’t hear a difference anyways, you can configure PulseAudio to use a linear algorithm too by adding “resample-method = src-linear” in /etc/pulse/daemon.conf. CPU usage will drop…

    Taken from here:
    http://www.vidarholen.net/contents/blog/?p=21

  2. som says:

    if its not broken then dont try to fix it
    thats my motto

  3. lefty.crupps says:

    When will Pulse work well for people? This mess has been going on for years; distros say it’s broken and the Pulse people say the distros are using the software wrong.

  4. Manolo says:

    what are the lines for automatic hardware detection?

    how to install this: gstreamer0.10-plugins-bad ? aptitude install gstre… doesnt works

  5. mkleber says:

    I?e tried this on LL 10.04, the sound stops for ever… The hint to make the ALSA backs doesnt worked…

  6. qdsgblads says:

    OSS was kicked out of Linux after the makers tried to monetize on it. They changed their license and tried to force everybody to pay for something they had been saying a long time it’s for free. This has lead to ALSA, which has a better independence and, licence agreements(it’s free) and architecture but is still not completely developed although it’s getting there(it’s pretty good already and sufficient for most users)

    Within two years, It is going to be better to use ALSA anyway.

  7. Markus says:

    I think this article is dangerous in that it invites confused individuals (and to get confused in Linux audio is normal) to dig deeper in the mess that is Linu audio. I have used it for so many years that I can tell you that we don’t need OSS4, we already got two sound systems too many. ALSA should have been enough, but does not allow sharing of the soundcard (at least not in any configuration that I have seen), so they pulled pulseaudio out of the hat. I would have been happier if they used jackd, as it is the most powerful of them all and would have sufficed for any application.

    So why is OSS4 bad in my eyes? Well, Linux audio is just stabilizing after having sent so many users screaming back to windows, since they JUST COULD NOT GET THAT GODDAMN soundsystem to work and who can blame them? You need weeks and moths and years to just know what is what. A standard for audio? Linux does not have it.

    Now we are at the point, where Ubuntu is leading the way with Pulseaudio and Alsa and the idea is that ALL programs will work with it and I think we are getting there. Now at this point, we need less choice, not more. Coming from a time where choice was no problem, lots of it existed, but getting a program to produce any sound at all was and the different sound systems messing eachother up.

    So you might not agree with me, that choice here is a bad thing, but I speak for the linux community at large, especially the desktop one, where users don’t want to spend hours and days getting audio to work or having to edit config files with that or this.

  8. John Eadie says:

    Markus is so right. It’s been a year or more I must boot into windows for sound. Ridiculous. Painful. Stupid.

  9. Kevin says:

    Thanks for your howto, works great. The wrapper for alsa to oss is working fine, but the wrapper from pulseaudio to oss creates crackling noises and is sometimes slowing down the music.

    I have many of these in the pulseaudio log:
    D: module-oss.c: EAGAIN

    I already changed many parameters in the configuration file of pulseaudio, but no change.

    Is it possible to wrap pulseaudio to alsa?
    like: Pulseaudio -> Alsa -> OSS

    What if i remove pulseaudio complete? Are some apps depending on pulseaudio only?

    Thanks.

  10. rmainard says:

    I tried your writeup and it trashed my sound system, I had to remove alsa, pulseaudio, oss, and the settings in /etc/pulse/default.pa and then completely re-install alsa pluseaudio and the ubuntu desktop in order to get things going again I think you may need to update your removal instructions.

  11. RTaylor says:

    I got this to work for me and had no choice it seemed since I could not get sound through anything else. But, here is the problem. I still have no sound when going on the internet. Also, when playing movies the sound is so freaking low that I might as well be watching a silent film or turning on subtitles. If anyone know the how-to on this, your help is appreciative.

  12. starZ says:

    Works fine for me the improved latency over ALSA is worth it.

  13. Runaway1956 says:

    I see the negative responses, and wonder, “Why?” I’m no guru, by any means – but I’ve used all the methods outlined above, and they work. Downloading the commercial .deb package is easiest, but the other methods are almost painless. Come on people – whatever OSS’ faults in the past, they now make the best sound system available. It “just works” with Virtualbox, whereas nothing else works with Virtualbox!

  14. Cocoro Cara says:

    I hoped the severe audio problems in 11.04 (natty) would be solved by changing to OSS4, but I followed the instructions and now there is no sound from the laptop speakers though the headphone plays fine. What could be the problem?
    I am using a Lenovo T510. hwinfo gives the following:
    26: PCI 1b.0: 0403 Audio device
    [Created at pci.318]
    UDI: /org/freedesktop/Hal/devices/pci_8086_3b56
    Unique ID: u1Nb.WiEkMfkoYv9
    SysFS ID: /devices/pci0000:00/0000:00:1b.0
    SysFS BusID: 0000:00:1b.0
    Hardware Class: sound
    Model: “Intel Ibex Peak High Definition Audio”
    Vendor: pci 0x8086 “Intel Corporation”
    Device: pci 0x3b56 “Ibex Peak High Definition Audio”
    SubVendor: pci 0x17aa “Lenovo”
    SubDevice: pci 0x215e
    Revision: 0x06
    Driver: “oss_hdaudio”
    Driver Modules: “oss_hdaudio”
    Memory Range: 0xf8520000-0xf8523fff (rw,non-prefetchable)
    IRQ: 17 (268733 events)
    Module Alias: “pci:v00008086d00003B56sv000017AAsd0000215Ebc04sc03i00”
    Config Status: cfg=new, avail=yes, need=no, active=unknown

  15. Cocoro Cara says:

    Please help. I am desperate. Sound from the headphones just stops after a playing a couple of minutes of music. No sound from the speakers as yet.

  16. ladoga says:

    I think this article is dangerous in that it invites confused individuals (and to get confused in Linux audio is normal) to dig deeper in the mess that is Linu audio.

    That’s exactly why OSS4 should be used. ALSA is Linux only, while OSS follows UNIX principles (low level API, does well what it’s supposed to) and is default sound system on BSDs and all other *NIXes excluding OS X.

    Even today much of software is written to use OSS APIs (as it’s lot simpler, better documented and doesn’t restrict developer to Linux only) so now we have OSS, ALSA and even Pulseaudio at same time. Such a mess makes no sense.

    Now we are at the point, where Ubuntu is leading the way with Pulseaudio and Alsa and the idea is that ALL programs will work with it and I think we are getting there. Now at this point, we need less choice, not more. Coming from a time where choice was no problem, lots of it existed, but getting a program to produce any sound at all was and the different sound systems messing eachother up.

    I’ve had lot of problems when using Pulseaudio (which I have no need for anyway). On some machines I can get sound only through ALSA, but pa stays silent. When I get sound it’s often low quality (crackles) and pa seems to also be CPU hog.

    So far I’ve been using ALSA only, which has worked fine for me. But I realize it is also unnecessarily complex and can be cryptic to configure.

    Now that OSS4 is under GPL it would be answer to solve this complexity and get back to using OSS as default.

  17. ladoga says:

    “OSS was kicked out of Linux after the makers tried to monetize on it. They changed their license and tried to force everybody to pay for something they had been saying a long time it’s for free.”

    Linux audio folks could have just forked OSS and develop it onwards. Instead they decided to build abstraction layer above another and thus we are in the mess we are. User shouldn’t need to know about anything of this (but sadly with ALSA and Pulseaudio they often have to). Sound should just work.

    OSS4 is also GPL now so no one can take it away.

  18. Sean McCullough says:

    Just a short note: in essence, this method also works for Quantal Quetzal (12.10). I’m not sure I have the Gnome volume control redirected to GStreamer, but audio is now playing OK including from Flash. One small note: the GUI volume control for OSS/OSS4 is /usr/bin/ossxmix, not /usr/bin/ossmix which is the terminal-only mixer.

    Otherwise, an excellent tutorial!

  19. someone says:

    $gstreamer-properties: command not found

Leave a Reply

Your email address will not be published. Required fields are marked *