Topic: Pulseaudio and #! - A How To

Pulseaudio is a sound server for linux. It lets you do fun things like easily piping your audio to other machines on your network, having a system wide equalizer, or switching from internal analog to hdmi audio with 1 click. Pulseaudio has earned a bad reputation, mostly due to a bad implementation in several versions of Ubuntu. I have installed it on a couple of #! installs and the Debian implementation seems to be solid.

First we need to install the following packages. Note that this is a light install of pulseaudio, no bluetooth, no plugins for any programs, though this is easy to fix by opening synaptic and searching for pulse, and checking your audio application settings. For a heavier install check the links at the end of this post.

sudo apt-get install pulseaudio paprefs pavucontrol pulseaudio-module-hal pulseaudio-module-x11 pulseaudio-utils libasound2-plugins paman pavumeter  pulseaudio-esound-compat libpulse0 libsdl1.2debian-pulseaudio

Now save the following into /etc/asound.conf

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}

ctl.!default {
    type pulse
}

You should be able to run pulseaudio -D in a terminal now and have a running Pulseaudio setup. Execute pavucontrol to see if things are working. If not try rebooting your machine.

Now we need to apply one tweak to make volumeicon work better with Pulseaudio. If you click on Open Mixer in the menu it will still launch the alsa mixer. To make it launch the Pulseaudio mixer open $HOME/.config/volumeicon/volumeicon in your favorite text editor. Find the onclick= line and change it to read as follows:

onclick=pavucontrol

If your keyboard has media keys, your volume controls may not work. I was able to fix this by putting the following code into the <keyboard> section of $HOME/.config/openbox/rc.xml.

    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
        <command>amixer set Master 5%+</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
        <command>amixer set Master 5%-</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
      <action name="Execute">
        <command>amixer set Master toggle</command>
      </action>
    </keybind>

Enjoy your new pulseaudio setup!


UPDATE March 23 2011:
SDL programs need a change to work with pulseaudio. This is included in the how to now, but if you need it here is how.

sudo apt-get install libsdl1.2debian-pulseaudio

UPDATE April 30 2011:
Removed the pulseaudio -d added to autostart.sh as it was not needed, and to add a note about possibly needing to restart your machine to get things working. Thanks @ceph for pointing this out.


These instructions were largely stolen from the following sources:
Pulseaudio : The Perfect Setup
Debian Sid and Pulseaudio
Debian Forums - How-to:Pulseaudio

Last edited by hardran3 (2011-04-30 23:58:31)

Re: Pulseaudio and #! - A How To

Worked like a charm (after reboot), thanks for this!

Re: Pulseaudio and #! - A How To

What is the advantage of running pulseaudio over alsa?

Let's do it and don't screw it.
      Github || Deviantart

Re: Pulseaudio and #! - A How To

@unia: hardran3 mentioned a few of the benefits in the first paragraph...basically alsa works more like a basic mixing board with a single main output channel; PuleaAudio is more complex, allowing for multiple output channels, send/return loops, yada.

while ( ! ( succeed = try() ) );

Re: Pulseaudio and #! - A How To

Yes but other than that, there's little to gain from using pulseaudio? I mean, I only play music/videos on my own laptop, so a simple alsa would suffice. Or is there something I´m missing?

Let's do it and don't screw it.
      Github || Deviantart

Re: Pulseaudio and #! - A How To

afaik Pulse has per-app volume control. Which is almost enough to get me to switch.. cool

Leave the gun. Take the cannoli.

Re: Pulseaudio and #! - A How To

^ But don't most media apps have their own internal volume controls anyway?  Is that redundant, or just redundant?

@Unia:  I agree, for your usage (as well as mine wink ) alsa is more than adequate.

while ( ! ( succeed = try() ) );

Re: Pulseaudio and #! - A How To

I'm not inclined to use pulse either but none the less this is a nice howto smile

A Creative Commoner | My images at Google+ | A Waldorf Review

Silence is sometimes the best answer - Dalai Lama.

Re: Pulseaudio and #! - A How To

One possible advantage to having PulseAudio on a laptop, if you frequently use the laptop with external speakers, would be to (for example) send your music player's output to the external speaker jack, but have audio from Youtube videos go to the internal speakers.  I haven't been able to do this with alsa.

while ( ! ( succeed = try() ) );

Re: Pulseaudio and #! - A How To

@pvsage, I hadn't thought of that.. yikes but maybe it's like a new paradigm someone's trying to setup...of course I don't really know, this is all just relayed from blog posts! tongue

Leave the gun. Take the cannoli.

Re: Pulseaudio and #! - A How To

omns wrote:

I'm not inclined to use pulse either but none the less this is a nice howto smile

Thanks omns! All my threads will come in handy when I have to reinstall smile

@Unia
ALSA will probably suffice in your situation. In fact most people will not need pulseaudio, but it has some nice features. I use it to send my audio to an Airport Express, and my netbook has HDMI so being able to switch outputs easily is nice.

Re: Pulseaudio and #! - A How To

So hadran3, would you say that as long as I have a single laptop with one set of speakers, I wouldn't need pulse? b/c I was thinking about switching but I have a knack for screwing things up tongue

Leave the gun. Take the cannoli.

Re: Pulseaudio and #! - A How To

mahatman2 wrote:

So hadran3, would you say that as long as I have a single laptop with one set of speakers, I wouldn't need pulse? b/c I was thinking about switching but I have a knack for screwing things up tongue

hadran3 hmm No, you probably don't need pulse, and where I come from, screwing things up is called learning. Take whatever you want from that smile

Re: Pulseaudio and #! - A How To

hardran3 wrote:

screwing things up is called learning

Hah, I forgot about that! tongue Thanks smile

Leave the gun. Take the cannoli.

Re: Pulseaudio and #! - A How To

Hi, very good tutorial, but after this i cannot set up multimedia keys work properly.
alsamixer shows: card: pulseaudio and only one channel: Master. For me that incorrect and cannot adjust volume.
So, my suggestion:
Run killall pulseaudio  -- Kills pulseaudio
In /etc/asound.conf change to your sound card:

pcm.V8237 {
    type pulse
}

ctl.V8237 {
    type pulse
}

pcm.V8237 {
    type pulse
}

ctl.V8237 {
    type pulse
}

To get sound card:

cat /proc/asound/cards

Mines says:

 0 [V8237          ]: VIA8237 - VIA 8237
                      VIA 8237 with CMI9761A+ at 0xd000, irq 22

So in .conf i use V8237
And make sure irq exist, that's your real card !
In terminal type pulseaudio -D
After this i can set PCM channel work with multimedia keys

And other issue witch i figured out how to fix: then using multimedia keys than master channel 0% others channels go to 0% too. More info about that + properly explained: http://askubuntu.com/questions/15069/ho … xer-levels

Issue two may not exist in your system so fix doesn't needed.

Last edited by suf3r (2011-03-19 15:42:22)

Re: Pulseaudio and #! - A How To

Thanks for this, works great!!

Re: Pulseaudio and #! - A How To

Just for others doing this, I had to restart my machine to get pulseaudio to work. I also didn't need to add it to my autostart.sh, the pulseaudio daemon was initialised on startup automatically.

If you have noticed this notice you may have noticed that this notice is not worth noticing

Re: Pulseaudio and #! - A How To

Nice tut hardran3

Does pulse work better with Intel hd audio? Alsa seems to be lacking when it comes to audio output.

Re: Pulseaudio and #! - A How To

This came in handy today, thanks for doing it, hardran3! I've installed Pulseaudio a couple of times before but this made it go really quick on a new install. It was pretty helpful on cleanup for an existing install also. I switched the audio card back to onboard to move the good one to the newer PC so what I did was refresh PA using your apt-get string (it pulled in a couple of things that were missing even though PA ran anyway, if a bit quirky at times) and replaced my existing asound.conf with the one you posted.

In case anyone else runs into this if they switch cards, if you get "connection refused" errors, what worked for me was removing the .pulse directory (off home) and deleting .pulse-cookie

PA has gotten better than it used to be (or it could be the difference in implementation). I need it for LiVES on one box and to get xbmc to play nice with everything else on another and even though it had a really rough start (I got bit by the Ubuntu/Hardy implementation good so after that switched to OSSv4 for a long time) it seems pretty much alright now. 

Thanks again for posting this!

Last edited by chillicampari (2011-05-19 01:02:37)

Re: Pulseaudio and #! - A How To

nvm, reverted to alsa, pulse gives out horrible choppy sound in videos.

Last edited by el_koraco (2011-07-30 09:45:04)

Re: Pulseaudio and #! - A How To

Thanx Hardran3 worked like a charm ... Even got my Macally 2.1 usb speaker/cooling fan thumpin...kewl beanz!