How to set up surround 5.1 audio in Linux with Alsa

he main problem I had with the sound setup in linux was getting it
to work so that i can use all my speakers. After a few hours of
searching the web and trial and error I finally figured out how to do
it. I have put together this tutorial hoping to help other people in a
similar situation.

The goal of this tutorial is to play stereo sounds on all 6 channels of
your audio card. All you need to do is to write the routing information
in your ~/.asoundrc file. Here is my setup with every block explained

pcm.sndcard{
type hw
card 0
device 1
channels 6
}

Here i am setting an “alias” for my sound card. if you have more
sound cards in your system, specify the default card by replacing “card
0″.

pcm.dmix6 {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm sndcard
rate 48000
channels 6
period_time 0
period_size 512
buffer_time 0
buffer_size 10240
}
}

This is a dmix, its purpose is to mix sounds that are played simultaneously.

pcm.ch51dup {
type route
slave.pcm softvol
slave.channels 6
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.4 0.5
ttable.1.4 0.5
ttable.0.5 0.5
ttable.1.5 0.5
}

Here is the actual routing where the stereo sound is converted into a 6 channel sound.

pcm.softvol {
type softvol
slave {
pcm “dmix6″
}
control {
name “softMaster”
card 0
count 2
}
}

This is an optional mixer slider controlling the volume on all the channels at once.

pcm.duplex {
type asym
playback.pcm “ch51dup”
capture.pcm “hw:0″
}

pcm.!default {
type plug
slave.pcm “duplex”
}

And finally the output and input of the sound card are combined in the same virtual device which is set as the default device.

Don’t forget to restart all the applications that use the sound card
(and your mixer program if you installed the optional mixer slider) and
enjoy the music.

For additional and more detailed information check out the sites bellow

Here is an adaptation for 7.1

pcm.sndcard{
type hw
card 0
device 1
channels 8
}

pcm.dmix8 {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm sndcard
rate 48000
channels 8
period_time 0
period_size 512
buffer_time 0
buffer_size 10240
}
}

pcm.ch71dup {
type route
slave.pcm softvol
slave.channels 8
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.4 1
ttable.1.5 1
ttable.0.6 0.5
ttable.1.6 0.5
ttable.0.7 0.5
ttable.1.7 0.5
}

pcm.softvol {
type softvol
slave {
pcm “dmix8″
}
control {
name “softMaster”
card 0
count 2
}
}

pcm.duplex {
type asym
playback.pcm “ch71dup”
capture.pcm “hw:0″
}

pcm.!default {
type plug
slave.pcm “duplex”
}

source:
http://www.linuxtricks.net/index.php/archives/121/how-to-set-up-surround-51-audio-in-linux-with-alsa/

Powered by ScribeFire.

5 thoughts on “How to set up surround 5.1 audio in Linux with Alsa

  1. ok sir. I do not know this fact. Sorry sir. I did so because most of the times, the sites may down and the user may not get the thing. hereafter, i wont do this.

    Thanks for your advice.

  2. Thanks a lot for copying the whole article, because it happens, what you supposed would happend. The source isn´t avaible anymore. thxalot tshrinivasan

  3. I tried this and, with some adjustments, got for my audio working with more then 2 speakers. But I was not satisfied because I had to configure the application one by one to use alsa. then I found this http://wiki.bodhilinux.com/doku.php?id=surround_sound

    and practically only needed this command to resolve it:
    pactl set-card-profile # output:PROFILE
    Where # is your card number and PROFILE is the profile you determined from /usr/share/pulseaudio/alsa-mixer/profile-sets

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s