Results 1 to 10 of 180

Thread: HOWTO: Surround sound in pulseaudio

Threaded View

  1. #1
    Join Date
    Jan 2006
    Bristol, UK
    Ubuntu 9.10 Karmic Koala

    HOWTO: Surround sound in pulseaudio

    Update 05/11/09: Attention everyone. This guide is now OUTDATED and no longer necessary. Configuring surround sound is now ridiculously easy in Ubuntu 9.10 (Karmic) - just go into the hardware tab in sound preferences, click the device to configure, then select a surround sound profile from the drop down box. There is NO NEED to use this guide at all any more!

    Note: This guide has undergone a major revision. It does not suggest editing system-wide configuration files any more, and HAL based auto-detection should still work even if you do it the "hard way".

    Hi everyone.

    I have an m-audio revolution 7.1 sound card and after struggling for a while to get surround sound, I thought that now I've succeeded it would be a good idea to post my experiences here. If you somehow mess up your sound following this guide, don't worry, if you followed my commands you will have taken backups. To restore these, skip to the end of the guide.

    This guide assumes you actually have surround sound speakers and have them all plugged into the appropriate sockets on the sound card. If you have a standard 2.1 setup, it will in 99% of cases only have one 3.5mm jack and will appear to the computer as 2.0 speakers. Following the guide in this case is probably quite a bad idea. A good rule of thumb is, if it works in windows, you have the right hardware and all the plugs are in the right places.


    The above is important to note before you go messing up your asoundrc or anything like that. It is probably VERY EASY to get surround sound working just by changing one config option.

    First copy the system config files to your home directory, we want to change these settings on a per user basis. If you have already modified the config files in ~/.pulse, you don't need to do this, it will erase your modified user settings.

    cp /etc/pulse/daemon.conf /etc/pulse/ -t ~/.pulse/
    The Easy Way

    If you have one of the following combinations of speakers, you are in luck, you can do it the easy way. If you have some other combination, skip to the next section.

    2.0, 4.0, 5.0, 5.1, 7.1

    Simply open a terminal and do:

    gedit ~/.pulse/daemon.conf
    Scroll through until you find the lines that say:

    ; default-sample-format = s16le
    ; default-sample-rate = 44100
    ; default-sample-channels = 2
    Uncomment the default-sample-channels line (remove the ; symbol) and change the number to however many channels you have. If you have 5.1, change it to 6. If you have 4.0, change it to 4 etc... Save and exit.

    Now restart pulseaudio (easiest way is to restart ubuntu) and bingo, surround sound should be perfectly working.

    If you have a surround sound setup not listed here, you need to do it the hard way. Sorry!

    The Hard Way

    You will need to use this method if you have one of the following speaker configurations:

    2.1, 4.1, 6.0

    Or pretty much anything else that isn't listed in the easy method above.

    WARNING: This method is a bit hackish and more likely to cause problems than the officially sanctioned "easy way".

    Why is it harder?

    Pulseaudio has a somewhat weird way for users to define what channels they want. There are essentially two ways of doing it as far as I can gather. The easy way is the method outlined further above, where pulseaudio allocates the number of channels you tell it to, but in a set order. The order goes:

    FL, FR, RL, RR, CEN, LFE, SL, SR

    So if you have a subwoofer and four speakers you're really in a bit of trouble here, because if you tell pulseaudio to use 6 channels, you get low frequency subwoofer sound, but surround sound movies send sound to a centre speaker that doesn't exist, and you don't get any voice on the front speakers. But if you tell pulseaudio that you have four channels, the subwoofer gets no sound. In this case you must define what channels to use manually.

    Open a terminal and type:

    gedit ~/.pulse/
    Ok, skip to line 32. It's the bit that looks like:

    ### 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
    Now, you need to uncomment "load-module module-alsa-sink" and change it to something resembling the following:

    ### 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)
    ### Manual config for configuring surround sound. Comment out line below to revert to defaults.
    load-module module-alsa-sink device_id=0 channels=5 channel_map=front-left,front-right,rear-left,rear-right,lfe
    #load-module module-alsa-source device=hw:1,0
    Ok, you can see above that I have used my own manual channel configuration as an example. In my setup, I have 4.1 speakers and one sound card.

    You can configure your own system by replacing my configuration line with the following template. It's important to note here that the order of these channels makes a difference. If you find that some channels are reversed, eg centre/sub is swapped with rear right/left, then you can simply change the order they are allocated to swap them back round again. Most sound cards will want these channels allocated in the usual way.

    load-module module-alsa-sink device_id=X channels=X channel_map=x,x,x,x,x,x,x
    NOTE: One user reports:
    I have to point out only one thing: in my, when manually loading sink and source, I had to specify device=hw:0, not device=hw:0,0, nor device_id=0, otherwise I got alsa_ctl complaining about extra parameters, or surround51 unavailable (launching PA from terminal)

    For reasons why this is a problem, see this link, quoted below:

    If you select the default ALSA device to be "pulse", you need to make sure that PA doesn't try to open the "default" device for its own audio output. If you previously were loading module-alsa-sink without special device argument this means you have to change it to the raw "hw:0" devices. Example:

    load-module module-alsa-sink device=hw:0
    load-module module-alsa-source device=hw:0
    This obviously only applies to you if you have previously modified your asoundrc to make pulse your default alsa device.

    • device_id - This is of course the id of your card. If you have one sound card, this is likely to be 0, but might be different if you have more than one card.
    • channels=X - The X should be replaced by the total number of channels you wish to use
    • channel_map=x,x,x,x,x,x,x - This is a comma separated list of values that tell pulseaudio which channels to use. It's probably a good idea to stick to the same order that pulseaudio uses (listed at the beginning of the guide) but skip out which channels you don't want. Here is an exhaustive list of valid channel names:

      The currently defined channel names are: left, right, mono, center, front-left, front-right, front-center, rear-center, rear-left, rear-right, lfe, subwoofer, front-left-of-center, front-right-of-center, side-left, side-right, aux0, aux1 to aux15, top-center, top-front-left, top-front-right, top-front-center, top-rear-left, top-rear-right, top-rear-center, (Default depends on the number of channels and the driver)

      It's probably best to stick to some combination of the following:

      front-left, front-right, front-center, rear-center, rear-left, rear-right, lfe, side-left, side-right

    NOTE: If you have a subwoofer, it's almost certainly more desirable to load it as "lfe", NOT "subwoofer". "Lfe" means low frequency effects. This may seem counterintuitive, but as far as I can tell, the subwoofer channel is almost always labelled "lfe".

    When you have finished, save and exit the file. You will need to restart pulseaudio for the changes to take effect. The easiest way to do this is to restart ubuntu.


    When you boot up, you should have surround sound on all the channels you specified, and output channels for which there is no corresponding output device should be automagically upmixed into the other speakers. Try it out with a surround sound movie or music track. If this works, well done, you've done it. Alternatively, if you have added the pulseaudio device in your asoundrc, you can use the command:

    speaker-test -c #channels
    Replace #channels with the number of channels you have, eg for a 5.1 channel system, put 6 here.

    If you don't get surround sound, first check the channels aren't actually muted. Open a terminal and type

    Make sure all the volumes for the channels you want are up. If your alsamixer looks like this:

    You may need to try shared or independent surround, and make sure surround is unmuted. (If anyone has more information about this, I'll include it here).

    NOTE: If you have swapped channels (eg centre/sub is swapped with rear right/left) then it's pretty easy to swap these back. This is a common problem with ICH4 and ICH5 cards, and the solution is explained on page 2 of this thread.

    If you have no sound, or it's all gone horribly wrong somehow, don't panic! Open a terminal and type the following:

    cp /etc/pulse/ ~/.pulse/ && cp /etc/pulse/daemon.conf ~./pulse/daemon.conf
    Reboot ubuntu, and sound will be back how it was before.

    I hope this guide was helpful! If you have problems, please post in this thread and include the contents of ~/.asoundrc, ~/.pulse/daemon.conf and ~/.pulse/ Also useful would be the result of:

    aplay -L && aplay -l
    You should also open a terminal and type the following:

    pulseaudio -k && pulseaudio -vv
    then post the output here along with your configuration files. Please post the contents of the files in a text file attachment, otherwise it makes the thread very long and unreadable, thanks! Please also bear in mind I am not a developer, just a normal user, but I've got a bit of experience with pulseaudio and I'll do my best to help.

    Last edited by sammydee; November 5th, 2009 at 05:09 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts