Ubuntu: Enabling 5.1 Surround

arcenite

Lifer
Dec 9, 2001
10,660
7
81
Linux successfully detected my sound card, but when I play music it only comes out of 2 speakers. Any ideas?
 

hooflung

Golden Member
Dec 31, 2004
1,190
1
0
There is no support for 5.1 through OSS or ALSA by default, although both supposedly support it. You will need the latest kernel, which includes the latest ALSA, and the latest ALSA-tools. You will also need to make sure if your application is 5.1 compatible I believe. You shoudl really go to the ubuntu forums for help on this. Gentoo forums have some help on this as well.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
depending on the sound card and drivers you can get Ac3 passthru on a digital line for your receiver to decode into multiple channels. This is what I do for movies/home theater and such. Not all sound cards or drivers support this though.

Otherwise if your listenning to music and such your only dealing with 2 channels anyways. You can use things like Dobly 'Prologic' type stuff to take 2 channel audio and sort of remix it on the fly for 'surround' sound... but to me this has always seemed kinda ghetto. Usually nowadays all this stuff is done in software, like for the nforce onboard or most other consumer cards.. which means that to use prologic to remix sounds the driver developers would have to license stuff from Dobly. I realy don't know how that works or much about the actual drivers. I never realy looked into it before.

Also there is no support for hardware acceleration stuff like EAX extensions for Alsa and whatnot.

With alsa drivers you can do some advanced stuff, but it's not easy. If you setup your ~/.asoundrc or /etc/asound.conf configuration files correctly you can then configure paticular applications to output on paticular channels. Like maybe output music to your back speakers, while having your game output to the front speakers. Stuff like that, but it can take some fiddling and such to get that to work.

When I say advanced stuff, I mean it. Linux audio is very powerfull, but also kinda difficult. The capabilities are there, it's just taking a lot of time for it to mature.

For isntance here is some documentation for surround sound:
http://alsa.opensrc.org/index.php?page=SurroundSound

Alsa sound devices can be configured by the end user in their paticular .asoundrc file in their home directory (the . makes it 'hidden') or in system wide configuration in /etc/asound.conf These configurations can then be used by Alsa-enabled applications to perform many functions.

See here for various documentation on asoundrc configuration files and other things.
http://alsa.opensrc.org/AlsaOpensrcOrg

see here for various sound card specific documentation.
http://www.alsa-project.org/alsa-doc/

here is for surround sound in Doom3:
http://zerowing.idsoftware.com/linux/do...36163f1dfc3a253ef72c0f821b0b0dd2fc17b1

here are some notes on alsa naming, related files, and some sample config stuff.
http://www.sabi.co.uk/Notes/linuxSoundALSA.html

It just depends on much effort you want to put into it.

I think it may be as easy as simply telling your Alsa-ready applications to use 'pcm.surround51' rather then the default 'pcm.default'. Or just 'surround51' rather then 'default'.

Or if your feeling adventurous and don't want to configure each and every program then maybe making a .asoundrc file with something like:

pcm.!default {
type route
slave.pcm "surround51"
}

will be enough.

Needless to say doing this isn't nearly as convient as it is in Windows, however it should lead to superior sounding stuff. I'll have to experiment with it tomorrow and get surround sound working with Doom3 and see if I can get 2 channel music mixing to 5.1 channels.

Also it would be nice to know what type of card your using.
 

Seeruk

Senior member
Nov 16, 2003
986
0
0
That is interesting Drag... I'm no audiophile and I don't game on linux for obvious reasosn... but I have always assumed that I had 5.1 because I had sound from all speakers (well after some messing around with alsa mixer for a bit) :) Now of course all I typically hear from my Linux speakers is system sounds I have never really noticed that it wasn't 5.1 as such.... just stereo split between the 6 speakers right?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: Seeruk
That is interesting Drag... I'm no audiophile and I don't game on linux for obvious reasosn... but I have always assumed that I had 5.1 because I had sound from all speakers (well after some messing around with alsa mixer for a bit) :) Now of course all I typically hear from my Linux speakers is system sounds I have never really noticed that it wasn't 5.1 as such.... just stereo split between the 6 speakers right?

It just depends on the source of the sound.

Most music has only 2 channels. A left and a right.. (In fact this is usually more ideal to listen to then "surround sound" for various reasons.) Which makes sense considuring that music cds, and such are restricted to 2 channels only.

It's possible to have multichannel audio files. You can do that in wave format, as well as Ogg Vorbis, and newer versions of the Mp3s (as well quite a few other formats). However you generally have a hard time finding them since 'just for music' it's fairly pointless to do more then 2 channels and you can obtain them by ripping cds and such.

So that is were things like Dobly Prologic, and Prologic II come in. It takes a regular stereo input and mixes them on the fly to the multiple outputs. I don't know for sure exactly how it works, but basicly it will take the sounds that only appear on one or the other channel and puts those on the left or right front and rear outputs. Then sounds that come out both speakers it will send to the center. Then for the subwoofer (or LFE, for low frequency effects) it will mix both channels together then use a lowpass filter to remove all the sounds above a certain frequency.

It's basicly a method devised to sell surround sound systems. Having lots of speakers is impressive, and it's a nice way to sell new equipment and lots of speakers to people.

'Real' Stereo is still prefered method to listen to music from audiophiles due to all these different variables and whatnot. Basicly with nice speakers, proper placement, and good sitting arrangement a proper stereo setup can make any sound seem to come from different directions. After all you only have 2 ears. They have all these fancy terms to describe how well the speakers, stereo receiver, and audio information is able to do this. Stuff like 'stereo imaging' and whatnot. Usually they'll have a subwoofer for very low stuff, since it's difficult for humans to determine were realy low frequency sounds come from.

What surround sound like 4.1, 5.1, 7.1, etc.. is designed for is for special effects in movies and games. You can make it feel like the ground is rumbling, or you can make a telephone suddenly ring off to your right, or a monster from behind, or a car zoom from left to right. It's designed for big impressions, not so much so you can do things like make the listener thinks there is a guy playing the violin kinda off to the right and up about 10 feet off the ground.

So that is the other purpose for prologic stuff. By putting subtle 'hints' and such into 2 audio streams you can take a multiple channel input, downmix it to 2 audio channels, then use prologic to 'upmix' it back into multiple channels. That's what they are doing when you see on the Simpsons or whatnot "encoded in prologic surround sound" type stuff. Since with TV you only realy can have 2 analog channels.

Nowadays with all our digital media we have things like Dolby AC-3 format (Dolby Digital). Since it's digital you can encode as many channels as you feel like as long as the format supports it. Dolby Ac-3 supports up to 5 independant channels, and then you can do fancy stuff to get the 'LFE' (the .1) for the subwoofer. For DVDs and I beleive HDTV the minimal and required option is Dolby Digital 2.0, which is just digital 2 channel format. Then you have 2.1, 4.1, 5.1 stuff it can support.

In Linux movie players like Xine and VLC and a few other are smart enough to handle and understand stuff like AC-3. What I do when I want to watch a DVD is that I have a audigy and a el'cheapo Sony 5.1 digital receiver I got from K-mart. It supports things like Dobly Digital and Prologic, so I just setup so that I have the left front speaker of my Audigy (thats how creative has it setup in the hardware) connected directly into the 'dvd' input on the receiver. Then when I play the dvd with Xine I enable 'AC-3 passthru' and it just sends the digital data from the dvd (or avi or whatever) directly thru the digital output and into the receiver. The receiver's hardware is smart enough to detect this and it then decodes it to analog outputs on all 6 speakers I have.

(BTW with DVDs, digital sattalite, digital cable, the format for video is Mpeg2 encoding. In AVI files it's a container format (like quicktime or ogg format) it can contain mixtures of different audio/video formats. Like you can have avi files that mpeg2 with Ac3, or mpeg4 (divx is a mpeg4 codec) with pcm audio (uncompressed audio), or with mpeg4 + ac3, mpeg4 + mp3, or even mpeg4 + vorbis. Other types of container files can contain different things. Ogg files for instance usually have Vorbis audio, but they can also contain mp3 if you realy wanted to.. (I dont know if that is supported by any players though), Generally with video Ogg files you can use Theora (which is similar purpose to mpeg4) and vorbis for audio. (technically Ogg Vorbis can handle up to 256 different audio channels at once))

Digital DTS is a competator to Dolby Digital. Originally intended for movie theaters it's a optional sound track on some DVDs. It does 5.1 sound also. I don't know if anything in Linux supports this or not. I suppose so, but it may only be commercial programs. In comparision Dolby Digital is part of the required standard for DVDs and such.


Now beyond 5.1 sound for Dolby Digital, you have things like Dolby Digital EX, THX, DTS-ES, and the like.

Now this is still 5.1 audio, but unlike just plain Dolby Digital you have the 'rear' two speakers to be mixed to create sound for use behind the viewer. On regular 5.1 you place the speakers in front and then off to the side.

So to still retain the front and side arrangement but still be able to account for sounds coming from behind you add a extra 2 channels for the rear output. This is were 7.1 comes in. Then you use some fancy logic in the receiver to split up the rear channel from the other left/right/front/side/center/LFE speakers.

So I think it's sort of like 'prologic', but just for the rear.

I don't suppose that Linux supports any of this either, but I can't say for certain since it's something that I realy don't care much about and haven't tried it.


Stereo = take 2 channel input and output for 2 channels (or maybe 3 if you do a lowpass filter for a subwoofer).
So Prologic = take 2 channels input and remix/upmix/whatever for 3-6 channel output. (left front, right front, left rear, right rear, center, subwoofer(LFE))
So Dolby Digital (Ac-3)/DTS = take 2-5 channels and output for 2-6 channels.
THX/EX/DTS-ES = take 5 channels and output for 6-8 channels.


Or something like that. It's a big mess.


edit:
In Linux some sound cards and do the prologic-style or Ac3 stuff themselves. Like I've listened to music plenty times on my Audigy on multiple speakers thru the analog outputs on the back. I just realy depends on the sound card, and how much stuff they put into the hardware vs how much they left in the software to accomplish, how mature the drivers are for a paticular device, and how much documentation and help is provided for the programmers by the original hardware developers.
 

Seeruk

Senior member
Nov 16, 2003
986
0
0
Interesting Stuff - I used to be heavily into my music (going back 8-12 years when I was a DJ at university) and only really cared about having good decks, Nice headphones, an easy to use mixer and the biggest baddest pair of speakers I could find :) Thinking back to that time I only actually ever used to listen to the basslines as that's what I had to mix.

Now my only interest in sound (apart from a ton of MP3's on my phone) is in the gaming world where it is crucial to hear that sneaky bastard coming up to stab you from behind when you are sniping. I can count a lot of kills being based on positional sound, those spin and shoot moments where you really appreciate the fact you were able to spin to the exact location of the enemy based on sound alone and pop a cap where it hurts :)

Apart from that, audio is generally of such a high quality these days that I find you can generally rig up almost any old components and get sound quality you would have dreamed about even back in my DJ days (where I was using 12" Vinyl of course!). And no doubt I have damaged my hearing some anyway from those days which is probably the reason I cannot identify any difference between a £100 pair of speakers and £1000 pair these days :)

But great info mate ;)
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: Seeruk
Now my only interest in sound (apart from a ton of MP3's on my phone) is in the gaming world where it is crucial to hear that sneaky bastard coming up to stab you from behind when you are sniping. I can count a lot of kills being based on positional sound, those spin and shoot moments where you really appreciate the fact you were able to spin to the exact location of the enemy based on sound alone and pop a cap where it hurts :)

Well, EAX isn't going to work in Linux. So games that use that for special effects won't be able to if you run them in something like Cedega or Wine. Maybe Cedega has some sort of way to remix EAX stuff to independant multiple channels for linux output... but I have no idea about it, I doubt it, but Cedega does license stuff from corporations for things like anti-piracy workaround items.

There maybe some issues with sound latency if you need to use a sound deamon like Artsd to take a program like Quake3 that only can output straight to sound cards, but I think there are better solutions for artsd for those sort of things.

Doom3 has been modified to support Alsa directly and it can do surround sound type multichannel output. Ut2004 uses SDL for some stuff, but OpenAL for audio which supports multiple channel. I never bothered trying to get it to work though.

Originally SDL did only stereo (which is why Unreal Tournament stuff uses OpenAL), but it does now. Quake 4, even though it's based on Doom3 code, uses SDL for most of it's linux-compatability stuff. That's worlds better then the old Id-specific code they used in Quake3 and such. That supports multiple channel output now. (obviously rendering and whatnot is still done on id-specific OpenGL code)

Since Quake3 is open source now maybe somebody will port the client to support SDL and surround sound output.. I just don't know. (there are enhanced versions of Doom1/2, and Quake1/2 that use modern GLX and/or SDL rendering as well as SDL for input and sound, but I don't think they've been modified for multichannel surround sound.)

The best solution though I've found for competative online gaming in Quake3 and Wolfenstein mods is just a pair of very nice headphones. I can hear things much nicer and get more directionality better with 2 speakers like that then with multiple speakers. And since headphones are generally cheaper I can get much higher quality headphones then I can get speaker-wise. Just get big fluffy stupid looking ones that sound good and are comfortable. Earbuds suck.

Remeber that 'home theater surround sound' is more for just special effects then anything else. Audiophiles, I think, refer to it as 'Impressive' style surround sound only.

Now with Quake4, I don't know. Maybe with surround sound it'll be more advantage for me to use the home theater stuff. I doubt it though. It will probably make it funner though because then you can get the subwoofer in on the action, which is the point of playing games. :)

(I am going to have to put off playing that game until I can upgrade my hardware.. I've been waiting on the new virtual technology stuff in the next gen of AMD and Intel proccessors)
 

Seeruk

Senior member
Nov 16, 2003
986
0
0
I agree buds suck - especially as I must have ears shaped differently from the rest of humanity as I have never found a pair that would stay in my ear for more than 2 secs.

I have a huge pair of technics headphones which I used to use when DJ'ing and now use for gaming. I use em late at night when the GF is sleeping and when playing scary games like FEAR because them little subtle creeks and scary sounds are completely lost in big speakers :)

Do you think they will ever consolidate to a standard in Linux distros? To switch between the different protocols in Ubuntu for different things is one of my biggest bugbears about it.
 

Zelmo3

Senior member
Dec 24, 2003
772
0
0
Wow, thanks for the links, Drag! Yesterday I had resigned myself to thinking I couldn't get 5.1 surround without JACK (which wasn't working for me). Today I saw this thread and checked out the Doom 3 link, and now I have full surround working in Quake 4.