Friday, 21 October 2011

11.10 und 5.1 surround sound

The lasts evenings and nights I tried to get my 5.1 surround sound bringing back online. With 11.04 it felt that I hadn't to do anything. But I am not more so sure about that ;-).

After a fresh installation of Xubuntu 11.10 I found only one sound device in my sound settings. However I was able to change it to HDMI 5.1 surround output.

Now I got sound with
aplay chan-id.wav
speaker-test -c6
Well, I got sound, but not from the right channels. Center and rear left were interchanged as well as rear right and the bass. What now? After researching, a lot of time and many try&errors I figured out that through the wrong allocation of the channels I was unable to use pulseaudio any further. So I was forced to use ALSA.

Removing pulseaudio from your system:
apt-get autoremove --purge pulseaudio pulseaudio-utils gstreamer0.10-pulseaudio libsdl1.2debian-pulseaudio pavucontrol pavumeter paprefs
Afterwards reboot your system. Otherwise there could be still some pulseaudio settings on.

Now for telling the system that ALSA is primary soundsystem you need to install
apt-get install gstreamer-properties
Start gstreamer-properties and change the settings to ALSA.

So far so good. But the Adobe Flash Player will still be silent for using OSS instead of ALSA.

Now we need the create our own sound setting file including the right channel allocation and the flash player output. Either with .asoundrc in your home folder or  in /etc/asound.conf.

Here the content of my asound.conf file:
#Define the soundcard to use
pcm.snd_card {
    type hw
    card 0
    device 3
}

# 6 channel dmix - output whatever audio, to all 6 speakers
pcm.dmix6 {
    type dmix
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0660
    slave {
        pcm "snd_card"
        rate 48000
        channels 6
        period_time 0
        period_size 1024
        buffer_time 0
        buffer_size 5120
    }

# Some cards, like the "nforce" variants require the following to be uncommented. It routes the audio to the correct speakers.
    bindings {
        0 0
        1 1
        2 4
        3 5
        4 2
        5 3
    }
}

# upmixing - duplicate stereo data to all 6 channels
pcm.ch51dup {
    type route
    slave.pcm dmix6
    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
}

# rate conversion, needed i.e. for wine
pcm.2chplug {
    type plug
    slave.pcm "ch51dup"
}

pcm.a2chplug {
    type plug
    slave.pcm "dmix6"
}

# 'full-duplex' device for use with aoss
pcm.duplex {
    type asym
    playback.pcm "2chplug"
    capture.pcm "microphone"
}

# for aoss
pcm.dsp0 "duplex"
ctl.mixer0 "duplex"

# softvol manages volume in alsa
# i.e. wine likes this
pcm.mainvol {
    type softvol
    slave.pcm "duplex"
    control {
        name "2ch-Upmix Master"
        card 0
    }
}

#pcm.!default "mainvol"

# set the default device according to the environment
# variable ALSA_DEFAULT_PCM and default to mainvol
pcm.!default {
    @func refer
    name { @func concat 
           strings [ "pcm."
                     { @func getenv
                       vars [ ALSA_DEFAULT_PCM ]
                       default "mainvol"
                     }
           ]
         }
}
Thanks to wishie for this great config!

You can check your settings with
speaker-test -Dplug:dmix6 -c6 -l1 -twav 
aplay -D dmix6 chan-id.wav
chain-id.wav is part of sound test files you can find here: http://alsa.opensrc.org/SurroundSound

Check your flash player for 5.1 e.g. with this video on youtube:  Dolby Digital Orchestra Hi-Fi Test

Finally for using e.g. mplayer with your new sound settings you need to add some lines into the /etc/mplayer/mplayer.conf file:
# 5.1 surround sound 
channels 6 
# Using correct sound device 
ao=alsa:device=hw=0.3 
# For both AC-3 and DTS passthrough
h
afm=hwac3,
Check your mplayer settings in the end with
mplayer chan-id.wav
That's it! I am greatful that it's done. Serves my quite some short nights...

No comments:

Post a Comment