![]() |
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 | |||
|
Way Too Much Ubuntu
![]() Join Date: Jan 2006
Location: Bristol, UK
Posts: 252
Thanks: 1
Thanked 21 Times in 10 Posts
|
HOWTO: Surround sound in pulseaudio
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 First things first: PULSEAUDIO DEFAULTS TO ONLY TWO CHANNELS! 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. Code:
cp /etc/pulse/daemon.conf /etc/pulse/default.pa -t ~/.pulse/ 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: Code:
gedit ~/.pulse/daemon.conf Code:
; default-sample-format = s16le ; default-sample-rate = 44100 ; default-sample-channels = 2 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: Code:
gedit ~/.pulse/default.pa 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 .endif 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) ### 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 .endif 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. Code:
load-module module-alsa-sink device_id=X channels=X channel_map=x,x,x,x,x,x,x Quote:
For reasons why this is a problem, see this link, quoted below: Quote:
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. Finished! 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: Code:
speaker-test -c #channels If you don't get surround sound, first check the channels aren't actually muted. Open a terminal and type Code:
alsamixer ![]() 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: Code:
cp /etc/pulse/default.pa ~/.pulse/default.pa && cp /etc/pulse/daemon.conf ~./pulse/daemon.conf 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/default.pa. Also useful would be the result of: Code:
aplay -L && aplay -l Code:
pulseaudio -k && pulseaudio -vv Sam
__________________
- Howto: Safely change the system hostname - Howto:Install projectM on Ubuntu Hardy for awesome music visualizations - Howto: Install microdc2, the command line direct connect client - Howto: Surround sound in pulseaudio Last edited by sammydee; November 9th, 2008 at 10:10 AM.. |
|||
|
|
|
| The Following 7 Users Say Thank You to sammydee For This Useful Post: | ||
DariusS (May 21st, 2008), fooman (May 23rd, 2008), grewolf (June 28th, 2008), jerome1232 (July 11th, 2008), MeURi (May 29th, 2008), neymac (June 5th, 2008), stylishpants (June 30th, 2008) | ||
|
|
#2 |
|
First Cup of Ubuntu
![]() Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Thank you very much, sammydee - I hadn't found that tidbit about pulseaudio defaulting to 2 channel, which was the ticket I needed to surround sound on my Revolution 5.1. Your just saved me additional hours of headache (or maybe gave me one, since I'll be blaring music on all four speakers once again).
|
|
|
|
|
|
#3 |
|
Way Too Much Ubuntu
![]() Join Date: Jan 2006
Location: Bristol, UK
Posts: 252
Thanks: 1
Thanked 21 Times in 10 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Thanks Chris, glad I could save someone else the two days of searching it took me to figure this out
I asked on the irc channel yesterday, and it appears that some time in the future this mess with the surround channels will be reolved, and sound card will be visibile in pavumeter with a list of "ports" that can be enabled and disabled at will, so you can point and click to get any combination of speakers you want. That won't be out until at least the next ubuntu release though. |
|
|
|
|
|
#4 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Vimercate (MI), Italy
Posts: 112
Thanks: 2
Thanked 5 Times in 5 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Good guide, sammydee
I only have one problem: my center and rear channels are swapped (compared to Windows), so I hear center and lfe coming out, respectively, from rear-left and rear-right. And vice versa. Since I still need Windows, and there everything works correctly (drivers tell me to put some jacks here and there, and sound comes out from where it's supposed to come out), I just don't want to swap rear and center jacks everytime I boot into Ubuntu. I tried to remap my channels using PA's module-remap-sink, but if I choose the remapped sink as output, PA dies horribly. Do you know, by chance, how could I fix that? (I mean remapping channels, not PA EDIT: My sound card is a Realtek ALC650, integrated into my motherboard; lspci gives Code:
[m3ur1@Daemia: ~]$ lspci | grep audio 00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 02) /etc/pulse/default.pa (I removed comments) Code:
.nofail load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav .fail load-module module-alsa-sink device=hw:0,0 sink_name=AC97 channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe load-module module-remap-sink sink_name=RealtekALC650.Playback master=AC97 channels=6 master_channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe channel_map=front-left,front-right,front-center,lfe,rear-left,rear-right load-module module-alsa-source device=hw:0,0 source_name=RealtekALC650.Capture channels=2 .ifexists module-esound-protocol-unix.so load-module module-esound-protocol-unix .endif load-module module-native-protocol-unix load-module module-volume-restore load-module module-default-device-restore load-module module-rescue-streams load-module module-suspend-on-idle .ifexists module-gconf.so .nofail load-module module-gconf .fail .endif .ifexists module-x11-publish.so .nofail load-module module-x11-publish .fail .endif Code:
default-sample-rate = 48000 default-sample-channels = 6 Code:
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
Code:
[m3ur1@Daemia: ~]$ paplay --device=RealtekALC650.Playback sample.wav Connection failure: Connection terminated Stream errror: Connection terminated [m3ur1@Daemia: ~]$
__________________
2B OR (NOT 2B) That is the question. The answer is FF Last edited by MeURi; May 16th, 2008 at 05:14 AM.. Reason: Missed hardware information |
|
|
|
|
|
#5 |
|
Way Too Much Ubuntu
![]() Join Date: Jan 2006
Location: Bristol, UK
Posts: 252
Thanks: 1
Thanked 21 Times in 10 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Aside from the obvious suggestion of switching the physical jacks around and just leaving them in the wrong sockets (hey, if it works...), I'm not sure what to suggest.
I've found the #pulseaudio channel on irc.freenode.net to be helpful sometimes, however it seems to be a bit sporadic that someone actually replies to your question. module-remap-sink documentation is here but it is pretty sparse. It's probably a good idea to leave comments in when you paste config files here, it makes it easier to read Now I haven't tried using the remap sink function yet, but to switch lfe and centre with front left and front right you used: Code:
load-module module-alsa-sink device=hw:0,0 sink_name=AC97 channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe load-module module-remap-sink sink_name=RealtekALC650.Playback master=AC97 channels=6 master_channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe channel_map=front-left,front-right,front-center,lfe,rear-left,rear-right load-module module-alsa-source device=hw:0,0 source_name=RealtekALC650.Capture channels=2 Code:
#load sink load-module module-alsa-sink device=hw:0,0 sink_name=AC97 channels=6 channel_map=front-left,front-right,front-center,lfe,rear-left,rear-right #load source load-module module-alsa-source device=hw:0,0 source_name=RealtekALC650.Capture channels=2 Failing that, I would suggest using something more like this: Code:
#load sink load-module module-alsa-sink device=hw:0,0 sink_name=AC97 channels=6 channel_map=aux0,aux1,aux2,aux3,aux4,aux5 # load virtual swapped sink load-module module-remap-sink sink_name=RealtekALC650-Playback master=AC97 channels=6 master_channel_map=aux0,aux1,aux2,aux3,aux4,aux5 channel_map=front-left,front-right,front-center,lfe,rear-left,rear-right # load source load-module module-alsa-source device=hw:0,0 source_name=RealtekALC650.Capture channels=2 Let me know if you have any luck. sam |
|
|
|
|
|
#6 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Vimercate (MI), Italy
Posts: 112
Thanks: 2
Thanked 5 Times in 5 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Thanks for the quick reply
I created my remapped configuration looking at PA official docs (the same link you posted), yet I kept original channels name instead of aux# because I tried something more human-readable like fl,fr,rl,rr and so on, but PA failed to start (maybe I was doing something wrong elsewhere, but changing them to the original names solved the problem) Well, using your naming suggestion didn't help, sadly (but PA starts without complaining)... I mean, the remapped sink should be ok, yet I got the same error using paplay, and PA dies (the same happens if I use any other app trying to reproduce sounds) The main issue with exchanging jacks is that I should go under my desk every time I boot into Ubuntu, watching out for dust and cables, and then again if I reboot into Windows... I mean, it's not that pleasant I'll try to use a different channel order and see if it works, without remap-sink Stay tuned
__________________
2B OR (NOT 2B) That is the question. The answer is FF Last edited by MeURi; May 16th, 2008 at 06:32 AM.. Reason: Typo |
|
|
|
|
|
#7 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Vimercate (MI), Italy
Posts: 112
Thanks: 2
Thanked 5 Times in 5 Posts
|
Re: HOWTO: Surround sound in pulseaudio
Ok, PA starts without complaining, but it still seems to me that I have swapped channels
Maybe it's just an impression, but if I use MPlayer and remap channels within it, it gives me a better feeling (better than Totem and VLC when playing 5.1 audio in DVDs or whatever) I tried also doing a speaker test, but I got the following: Code:
[m3ur1@Daemia: ~]$ speaker-test -Dpulse -c6 -twav speaker-test 1.0.15 Playback device is pulse Stream parameters are 48000Hz, S16_LE, 6 channels WAV file(s) Rate set to 48000Hz (requested 48000Hz) Buffer size range from 43 to 349525 Period size range from 21 to 87382 Using max buffer size 349524 Periods = 4 was set period_size = 87381 was set buffer_size = 349524 *** PULSEAUDIO: Unable to create stream. Unable to set hw params for playback: Input/output error Setting of hwparams failed: Input/output error speaker-test: pcm_pulse.c:115: pulse_stop: Assertion `pcm->stream' failed. Aborted ![]()
__________________
2B OR (NOT 2B) That is the question. The answer is FF |
|
|
|
|
|
#8 |
|
Way Too Much Ubuntu
![]() Join Date: Jan 2006
Location: Bristol, UK
Posts: 252
Thanks: 1
Thanked 21 Times in 10 Posts
|
Re: HOWTO: Surround sound in pulseaudio
I think the reversed channel order is a common problem with intel ich4 and ich5 chipsets, do you have one of these (try lspci | grep ICH)?
It is also possible that windows has it wrong - can you swap the channels round in windows? Sam |
|
|
|
|
|
#9 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Vimercate (MI), Italy
Posts: 112
Thanks: 2
Thanked 5 Times in 5 Posts
|
Re: HOWTO: Surround sound in pulseaudio
I edited my first post inserting my hardware information, but you had already replied, so I think you missed it... well, no problem
Yes, I have an ICH4 chipset, and I'm using the onboard audio controller. I hoped to get it working Windows-like with PA... maybe it's just a matter of trial-and-error before getting it to work properly Under Windows I don't think I can swap channels, but I have to check; anyway, my 'problem' is posted here because I come from Windows (and still use it), if I tried Windows coming from Ubuntu, I'd probably say that Windows swaps my channels As far as I can use MPlayer to have a 'correct' output, I don't complain too much (since I notice channel swapping only with real 5.1 audio, not with upmixed stereo); but one question arises: if the channel swapping is a common problem, why doesn't it get corrected? No flaming purpose, here, I just wonder... Thanks for your replies
__________________
2B OR (NOT 2B) That is the question. The answer is FF |
|
|
|
|
|
#10 |
|
Way Too Much Ubuntu
![]() Join Date: Jan 2006
Location: Bristol, UK
Posts: 252
Thanks: 1
Thanked 21 Times in 10 Posts
|
Re: HOWTO: Surround sound in pulseaudio
It'd probably a good idea to check out the irc channel to see if they have a solution MeUri. I'll have a look now and see if I can get anything out of them.
Sam |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|