HOWTO: PulseAudio Fixes & System-Wide Equalizer Support
Diambil Dari http://ubuntuforums.org/showthread.php?t=789578
Overview:
Note 1. Karmic & Jaunty users: If you have dist-upgraded from a previous release, I recommend that you follow the guide to remove obsolete configuration. If you have performed a clean installation, follow the guide only if you are experiencing issues.
Note 2. Jaunty & Intrepid users: due to a bug in the ALSA libraries, your PCM mixer may occasionally become muted or reset to 0% volume. If you cannot hear sound - or hear a faint crackling - refer to Part A, Step 6.
Note 3: OSSv4 users: PulseAudio does not support OSSv4, so this guide will serve no purpose to you. If you have chosen to install OSSv4 and experience issues, you should seek guidance within the threads dedicated to OSSv4. I do not recommend users to install OSSv4 due to compatibility and support issues.
Note 4: Kubuntu users: Don't follow this guide - PulseAudio isn't used in your distribution.
PulseAudio is an advanced sound server which has been included in Ubuntu (i.e. the standard GNOME version) since the release of Hardy Heron (8.04). Unfortunately, Hardy shipped with a suboptimal configuration of PulseAudio which has resulted in users experiencing various problems, ranging from sporadic crashes in Firefox to sound mixing being completely broken. PulseAudio in Intrepid should work by default, but it is quite possible that your configuration is suboptimal. For more information, refer to the FAQ below.
For best results, I recommend all users who are interested in PulseAudio to install the latest release - Karmic Koala (9.10). The developers have done an excellent job with PulseAudio integration and configuration in this release - enough to make this guide virtually obsolete.
When you are ready to follow this guide, this is all you need to know:
Hardy users: Follow Part A & B.
Intrepid users: Follow Part A & C.
Jaunty users: Follow Part A.
Karmic users: Follow Part A.
Additionally:
Appendix A gives general troubleshooting tips - if you have problems, start here.
Appendix B gives useful information on the more advanced/technical features of PulseAudio.
Appendix C gives information on how to properly configure specific applications that may not work with PulseAudio by default, including (but not limited to): WINE, Skype, and all OSS applications.
Appendix D (only for Intrepid and lower) will show you how to enable equalized audio for all applications on your system - this is especially useful for laptop users who experience poor audio quality with their internal speakers.
Frequently Asked Questions
The most common queries are answered here.
Q. What exactly is PulseAudio?
A. From the homepage:
Quote:
PulseAudio is a sound server for POSIX and Win32 systems. A sound server is basically a proxy for your sound applications. It allows you to do advanced operations on your sound data as it passes between your application and your hardware. Things like transferring the audio to a different machine, changing the sample format or channel count and mixing several sounds into one are easily achieved using a sound server.
Simplified: PulseAudio is responsible for playback and mixing of audio on your system. It is not a sound driver - in fact, it runs on top of the Advanced Linux Sound Architecture (ALSA). Aside from all the cool effects PulseAudio provides, it serves as a replacement for ALSA's virtual sound mixing device (DmixPlugin, or "dmix") - thus allowing multiple applications to share access to your sound card.
Q. PulseAudio? Bleh! I don't want it on my system.
A. Well... tough! PulseAudio is already installed and active on Hardy and Intrepid by default; it replaces ESD (ESound Daemon) for system sounds, and most of Ubuntu's default applications already use it (Totem, Rhythmbox, and any other applications using the GStreamer framework). Although some high-profile applications support PulseAudio natively (such as VLC and mplayer), most applications use plain ALSA or OSS output, and thus don't have native PulseAudio support.
Q. If PulseAudio is already installed, why do I need this guide?
A. While PulseAudio has been installed by default since Hardy Heron (8.04), we dropped the ball when it came to the configuration part. A quote from the main PulseAudio developer, Lennart Pöttering:
Quote:
Some distributions did a better job adopting PulseAudio than others. On the good side I certainly have to list Mandriva, Debian, and Fedora. OTOH Ubuntu didn't exactly do a stellar job. They didn't do their homework. Adopting PA in a distribution is a fair amount of work, given that it interfaces with so many different things at so many different places. The integration with other systems is crucial. The information was all out there, communicated on the wiki, the mailing lists and on the PA IRC channel. But if you join and hang around on neither, then you won't get the memo. To my surprise when Ubuntu adopted PulseAudio they moved into one of their 'LTS' releases rightaway. Which I guess can be called gutsy -- on the background that I work for Red Hat and PulseAudio is not part of RHEL at this time. I get a lot of flak from Ubuntu users, and I am pretty sure the vast amount of it is undeserving and not my fault.
When PulseAudio is running, it requires exclusive access to your sound card in order to work correctly as it assumes responsibility for mixing application's sounds instead of ALSA's "dmix" device. If you launch a "regular" application that does not have explicit PulseAudio support, it will most likely try to open the "Dmix" device - and this will deprive PulseAudio of control over the sound card. From the user's perspective, they will observe that audio mixing between applications is broken.
PulseAudio includes ALSA plugins (within the package "libasound2-plugins") which are designed make regular ALSA applications remap audio to the PulseAudio server (and thus avoid mixing problems as described above). Unfortunately, Hardy Heron shipped without these plugins enabled (or even installed) by default, which is causing many, many audio mixing issues for users. To compound the problem, the version of these PulseAudio ALSA plugins in the Hardy repositories do not function correctly, so updated versions are required for ALSA applications to work correctly with PulseAudio.
By following this guide, your system will be configured to use these PulseAudio ALSA plugins for Hardy users (and updated versions of necessary packages will get installed from my PPA). Although Intrepid has these plugins installed and configured by default, following this guide is still worthwhile because a) it will ensure you have a clean PulseAudio configuration, and b) you will hopefully gain a better understanding of how PulseAudio works.
Q. I'm glad to hear these issue are fixed in Intrepid, but why the hell aren't they fixed in Hardy already?
A. The simplest answer to this question is: complexity. Hardy is a LTS (Long Term Support) release, and there is a very strict policy towards updates (SRU; even the most trivial of bugfixes are entered into a code review). In order to fix Hardy, many components will require updates and changes, including but not limited to: libflashsupport, ia32-libs, pulseaudio, libasound2, libasound2-plugins, flashplugin-nonfree, nspluginwrapper...
Up until the last moment of Hardy's development cycle, the PulseAudio ALSA plugins weren't functioning correctly, and Flash 9 absolutely would not work without the "evil" libflashsupport library (I say evil, because it caused frequent random crashes in Firefox) - and so it wasn't possible to enact the required changes before the final release. It's possible now, but there would require a huge amount of effort to review and apply these changes.
Q. I followed your guide and PulseAudio still doesn't work!
A. Refer to Appendix A and provide the requested information in your post.
Q. I can't get Skype/WINE/an OSS application/XYZ working correctly with PulseAudio, what can I do?
A. Some applications require some extra configuration, and some applications don't work with PulseAudio - please refer to Appendix C for information on specific applications.
Q. Where can I find the appropriate bug reports related to these issues?
A. If you click on a step number it will link to the appropriate bug report, if one exists.
Part A: Common instructions (Hardy, Intrepid, Jaunty & Karmic)
All users must must follow the steps in this section to guarantee a fully working PulseAudio configuration.
1. Backup (and then delete) your previous configuration files:
Code:
$ mkdir ~/pulse-backup && cp -r ~/.pulse ~/.asound* /etc/asound.conf /etc/pulse -t ~/pulse-backup/
$ rm -r ~/.pulse ~/.asound*
$ sudo rm /etc/asound.conf
Warning: As always, use caution when removing files on your system. Any typos can potentially cause data loss.
Note: Don't worry if some of these files did not exist on your system.
2. Ensure you have the necessary PulseAudio libraries and configuration utilities installed:
Code:
$ sudo apt-get install libasound2-plugins padevchooser libsdl1.2debian-pulseaudio
3. Ensure the evil "libflashsupport" library is not installed:
Code:
$ sudo apt-get remove --purge libflashsupport flashplugin-nonfree-extrasound
Note: the libflashsupport library was (and to a certain extent, still is) the most common cause of Firefox instability since the Hardy release, because many users have been misled into thinking they must install it to ensure Flash & PulseAudio can work correctly. If you notice any postings that recommend this library to be installed, please reply to the post and point them to this thread, or the bug report linked. The more people that are aware of this issue the better. Thanks!
4. (Karmic users - please skip this step, it's not necessary). Open System/Preferences/Sound. In the Devices section, ensure that all "Sound playback" options are set to Autodetect. Set the "Sound capture" item to "ALSA", or the appropriate hardware definition. Close the application when you're finished.
Note: Choosing PulseAudio for sound capture may result in crashes, so you are advised to choose the "direct" ALSA device instead.
5. Open the PulseAudio Volume Control application ("pavucontrol", or you can launch "Applications/Sound & Video/PulseAudio Device Chooser" and select Volume Control from this applet's menu). In the Output Devices section you will see a listing of the playback devices available on your system. Right-click on the entry that you desire to be made the default playback device on your system and enable the "Default" checkmark. Similarly, navigate to Input Devices, then right-click on the device you wish to set as your default input device (microphone), and ensure the "Default" setting is checked. Close the application when you're finished.
Note: If you are greeted with the error "Connection failed: Connection refused", manually launch PulseAudio before opening the PulseAudio Volume Control application:
Code:
$ pulseaudio & pavucontrol
6. Ensure that your sound card's PCM mixer is not muted or set to 0% volume (this appears to be a common bug in Intrepid and Jaunty):
Code:
$ alsamixer -Dhw
Note: When the PulseAudio ALSA plugins are active, you must explicitly specify your hardware device in alsamixer (marked in blue above), otherwise it will open the PulseAudio mixer.
7. Continue to Part B if you are running Hardy Heron (8.04), or Part C if you are running Intrepid Ibex (8.10). If you are running Karmic Koala (9.10) or Jaunty Jackalope (9.04), you're finished - log out and back in for changes to take effect!
Part B: Hardy Heron (8.04)
Follow the steps in this section only if you are running the Hardy Heron release.
Disclaimer: My PPA contains the necessary packages backported from Intrepid for: PulseAudio, ALSA, Flash 10 and nspluginwrapper. If you upgrade to a newer distribution, or Hardy receives official updates for any of these packages, you will not experience any issues.
0. 64-bit users only: Install "getlibs" and some extra 32-bit libraries that are required for Flash 10 & Skype to function properly:
Code:
$ wget http://www.boundlesssupremacy.com/Cappy/getlibs/getlibs-all.deb && sudo dpkg -i getlibs-all.deb && rm getlibs-all.deb
$ sudo getlibs -p libnss3-1d libnspr4-0d libcurl3 libasound2-plugins
1. Edit /etc/apt/sources.list:
Code:
$ gksudo gedit /etc/apt/sources.list
If they don't already exist, add the following lines to the end of this file and save:
Code:
# PulseAudio Fixes - http://ubuntuforums.org/showthread.php?t=789578
deb http://ppa.launchpad.net/psyke83/ubuntu hardy main
deb-src http://ppa.launchpad.net/psyke83/ubuntu hardy main
2. Add the authentication key for my PPA, update your repositories and upgrade packages:
Code:
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16AE4E77 && sudo apt-get update && sudo apt-get dist-upgrade
3. Enable the PulseAudio ALSA plugins:
Code:
$ asoundconf set-pulseaudio
Note: Please wait until you have upgraded packages in the previous step before running this command. My packages have a patch for "asoundconf" to ensure it enables the PulseAudio plugins correctly.
4. Log out & back in for changes to take effect!
Part C: Intrepid Ibex (8.10)
Follow the steps in this section only if you are running the Intrepid Ibex release.
Disclaimer: Currently there are no updated packages for Intrepid in my PPA (except for an updated nspluginwrapper package for i386 users). I have decided to keep this step in the guide in case I upload any important updates that will not make it into the official repositories. I will never upload any "risky" packages (i.e. highly untested backports), only upgrades that seem compelling and relatively stable.
1. Edit /etc/apt/sources.list:
Code:
$ gksudo gedit /etc/apt/sources.list
If they don't already exist, add the following lines to the end of this file and save:
Code:
# PulseAudio Fixes - http://ubuntuforums.org/showthread.php?t=789578
deb http://ppa.launchpad.net/psyke83/ubuntu intrepid main
deb-src http://ppa.launchpad.net/psyke83/ubuntu intrepid main
2. Add the authentication key for my PPA, update your repositories and upgrade packages:
Code:
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16AE4E77 && sudo apt-get update && sudo apt-get dist-upgrade
4. Log out & back in for changes to take effect!
Appendix A - General Troubleshooting
This section will outline some general troubleshooting steps you can perform to help identify your problem, and the information I need to help with your issues:
Close all applications that may be accessing the sound card.
Open the "PulseAudio Device Chooser" from Applications/Sound & Video. Click on the applet icon, and click "Volume Control...". Click on the "Playback" tab.
Launch the application you wish to test and allow it to play sound.
Check PulseAudio Volume Control's Playback tab and see if the application displays an entry while the application is (or should be) playing audio.
Here are the possible results within the PulseAudio Volume Control's Playback tab:
The application does plays audio and does list an entry in the Playback tab;
- the application is using PulseAudio correctly.
The application does plays audio and does not list an entry in the Playback tab;
- the application is either accessing your sound card directly or playing sound via ALSA's dmix device. This will prevent PulseAudio from working correctly & cause audio mixing errors.
The application does not play audio and does list an entry in the Playback tab;
- the application is using PulseAudio but there is a problem, such as: a bug in PulseAudio, a problem with your ALSA kernel module or libraries, or your PCM/Master volume is muted.
The application does not play audio and does not list an entry in the Playback tab;
- the application is trying either to access your sound card directly or to play sound via ALSA's dmix device, but the sound card is already in use. This is the opposite case to result B, which will also cause mixing errors.
The PulseAudio Volume Control application displays the error: "Connection failed: Connection refused";
- the PulseAudio daemon is not running.
Other (please specify).
Note: Unless the application you are testing is known to be incompatible with PulseAudio, you should always expect result "A" on a properly configured system.
If you require assistance with a particular application - or simply cannot get PulseAudio to work - provide the following information:
Your distribution version and architecture (e.g. Hardy Heron i386, Intrepid Ibex amd64, etc.).
A listing of your sound devices:
Code:
$ aplay -l
The verbose output from pulseaudio on your system:
Code:
$ pkill pulseaudio; sleep 2; pulseaudio -vv
If you are having a problem only with a specific application, specify the application's name and result you received from the instructions above (A-F).
Appendix B: Advanced PulseAudio Configuration
This appendix will explain some of the more advanced/technical features of PulseAudio.
Q. Where are the PulseAudio configuration utilities?
A. Providing you've followed this guide, you can gain access to all the utilities by launching "Applications/Sound & Video/PulseAudio Device Chooser". The applet's icon will appear in your notificiation tray - left-click to see the options.
The main applications you will want to check are the Manager (to see the current server status) and Volume Control (to manipulate the volume and stream settings).
Note: Please don't mess with any of the options until you have established a working configuration by following this guide - otherwise it'll be a nightmare to isolate your problem.
Q. How can I tell if an application is using PulseAudio successfully?
A. The application will give you result "A" from the troubleshooting steps of Appendix A.
Q. How can I change the default playback and/or recording device for my system?
A. Refer to Part A, Step 5.
Q. Is it possible to change to a different playback and/or recording device for an individual application?
A. Yes. Launch the desired application and play some sound (or begin recording), and open the PulseAudio Volume Control. Click the Playback or Recording tab (depending on which you want to change) and right-click on the desired application's entry. Choose the option "Move Stream..." and select the desired output device.
Note: The volume level, sink (playback) and source (recording) settings will be saved automatically for every application you run, so PulseAudio should remember your settings. If you wish to view or delete these saved settings, they're stored in the file "~/.pulse/volume-restore.table".
Q. If I plug in my USB/Bluetooth headset, my external speakers no longer work!
A. This is normal behaviour, as PulseAudio supports "hotplugging" of audio devices. If you plug in a new device, PulseAudio may choose it as the default sink (audio device). Also see Part A, Step 5.
Q. PulseAudio is working correctly, but I am noticing some stuttering on my system. Is there anything I can do to help?
A. Edit the file /etc/pulse/daemon.conf:
Code:
$ gksudo gedit /etc/pulse/daemon.conf
Find the following lines (usually at the bottom):
Code:
default-fragments = 8
default-fragment-size-msec = 10
Try experimenting with different values for both of these entries. I can't tell you what values are optimal for your system, as each sound card has different buffer sizes and characteristics - therefore you'll need to use trial & error. The default fragment amount and size used by an untweaked PulseAudio installation is 4 and 25, respectively.
Note 1: you must restart pulseaudio for any configuration changes to take effect.
Note 2: If your system was stuttering in versions of Ubuntu prior to Hardy, then you could be suffering from an ALSA kernel issue - these instructions probably won't help.
Q. I'm unhappy about the audio quality / CPU usage of PulseAudio. How do I change this?
A. For the record, PulseAudio should offer superior quality audio playback than ALSA's by default, as PulseAudio uses a higher quality audio resampler. This also means that PulseAudio may use more CPU usage compared to ALSA, unfortunately. If you wish to change the resampler:
Edit /etc/pulse/daemon.conf:
Code:
$ gksudo gedit /etc/pulse/daemon.conf
Find the following line:
Code:
resample-method = speex-float-1
You can change the resampler to any of the following, listed in descending order, from highest quality to lowest quality (and therefore, CPU usage):
Quote:
src-sinc-best-quality, src-sinc-medium-quality, src-sinc-fastest, speex-float-{10-0}, speex-fixed-{10-0}, ffmpeg, src-zero-order-hold, src-linear, trivial
Appendix C: Application Compatibility Guide
This appendix will explain how to configure specific applications that may require manual configuration to work with PulseAudio.
OSS applications: You need to launch the application using the "padsp" wrapper. For more information, see "man padsp".
Skype: The latest release of Skype has native PulseAudio support, and does not require special configuration. If you are using an older version, continue reading. Open Skype's Options, then go to Sound Devices. You need to set "Sound Out" and "Ringing" to the "pulse" device, and set "Sound In" to the hardware definition of your microphone. For example, my laptop's microphone is defined as "plughw:I82801DBICH4,0".
WINE: Open the Wine Configuration application ("winecfg"). On the Audio tab, choose the ALSA driver, and leave everything else to default. If your sound stutters, choose the OSS driver instead, and use the "padsp" wrapper to launch the wine executable (via the terminal, or edit your shortcuts).
Audacity (Intrepid users only, version in later distributions work correctly): From the PerfectSetup page:
Quote:
Audacity has now been packaged with a proper "alsa: pulse" device listed, in a ppa for ubuntu intrepid. See https://launchpad.net/~diwic/+archive
Everything else: refer to the Third Party Applications section of the upstream PerfectSetup wiki page.
Note: Many of the instructions on the PerfectSetup page are either outdated, too distro-agnostic to work on Ubuntu, or have been obsoleted by the fixes in this guide. You should ignore the advice for: ALSA applications, Flash, ESOUND, GNOME, GStreamer Applications, SDL, and Skype.
Appendix D: System-Wide Equalizer
In this section, we will configure PulseAudio to use equalized output, which is especially useful for laptops speakers which have very poor frequency response. If your sound is "tinny" or distorted at high ranges, then this will most likely enhance the quality of your audio.
Warning 1: this section is obsolete for users of Karmic or later. If you are using a recent distribution version, please ignore these instructions and use the PulseAudio Equalizer Script instead.
Warning 2: Do not attempt to set up the equalizer until you have followed the other parts of this guide and verified that PulseAudio works correctly using "unmodified" output.
Warning 3: The equalizer may not work on 64 bit systems, as extra 32-bit libraries could be required. If it doesn't work, simply revert the changes you made.
Warning 4: The equalizer currently does not work for Jaunty users, as there seems to be missing LADSPA plugins in the libasound2-plugins package. I'm investigating the issue currently, though you may want to test the Karmic equalizer script (mentioned above).
1. Install the required LADSPA plugins and tools:
Code:
$ sudo apt-get install swh-plugins ladspa-sdk
2. Edit ~/.asoundrc:
Code:
$ gedit ~/.asoundrc
Append the following text to the bottom of this file and save:
Code:
pcm.equalized {
type plug
slave.pcm "equalizer";
}
pcm.equalizer {
type ladspa
# The output from the EQ can either go direct to a hardware device
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go
# to the software mixer shown here.
slave.pcm "plughw"
#slave.pcm "plug:dmix"
# Sometimes you may need to specify the path to the plugins,
# especially if you've just installed them. Once you've logged
# out/restarted this shouldn't be necessary, but if you get errors
# about being unable to find plugins, try uncommenting this.
path "/usr/lib/ladspa"
plugins [
{
label mbeq
id 1197
input {
#this setting is here by example, edit to your own taste
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz,
# 1250hz, 1750hz, 2500hz, 5000hz, 10000hz, 20000hz
#range: -70 to 30
controls [ -1 -1 -1 -1 -5 -10 -20 -17 -12 -7 -6 -5 -5 0 0 ]
}
}
]
}
Note 1: If you are using the Intrepid or Jaunty release, this file will not exist - that's ok. Simply paste into the new file and save normally.
Note 2: If you have multiple sound cards, the section of this text marked in blue may need to be modified slightly. If you have problems, ask in the thread.
3. Edit /etc/pulse/default.pa:
Code:
$ gksudo gedit /etc/pulse/default.pa
Find the following line marked in blue:
Code:
### Load audio drivers statically (it's probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
Change the line in blue to the following, and save:
Code:
load-module module-alsa-sink device=equalized
Note: Be sure to also remove the comment (#) at the beginning of the line.
4. Log out & back in for changes to take effect!
That's all folks!