How to set up surround 5.1 audio in Linux with Alsa

The 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 morre 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 finaly 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 aditional and more detailed information check out the sites bellow


Add to Technorati Favorites| del.icio.us | Stumble it!| Slashdot   Slashdot It!

8 Responses to “How to set up surround 5.1 audio in Linux with Alsa”

  1. Arturo Says:

    My 5.1 Creative sound card “just works” with all channels for me.

  2. Nicu Says:

    I have a Realtek ac97 on board sound card and by default it only works with 2 channels if i play a stereo sound although if i watch a 5.1 movie it works on all the channels

  3. Bob Says:

    My 7.1 Creative just works will all channels for me in PCLinuxOS. Not so in a few other distros.

  4. Nicu Says:

    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”
    }

  5. fabiaN Says:

    Hello.
    I have sound system 4.0 consist of two stereo pairs: JetBalance jb381 and Microlab Solo1 connected to my sound card Creative Live! 7.1 24bit (ca0106).
    Could you publish .asoundrc file for my configuration, please?
    At that moment my sound system can play in stereo surround 4.0, but not multithreading OR can play only in one stereo pair with multithreading, BUT NOT together (multithreading and 4.0).
    You are my last hope. Please, help.

    P.S. Sorry for my English.

  6. Nicu Says:

    Here for 4.0

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

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

    pcm.ch40dup {
    type route
    slave.pcm softvol
    slave.channels 4
    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1

    }

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

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

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

  7. Anonymous Says:

    Thanks

  8. rulet Says:

    And how about Creative X-Fi Xtreme Audio PCI. Does it also makes surround 5.1?

Leave a Reply

authimage