You are not logged in.

#1 2013-08-10 19:08:46

Registered: 2013-08-10
Posts: 1

ALSA automatic upmixing with lowpass filtering and dmix support

I thought I'd just let this here, since others may find this useful as well and I haven't found an up-to-date configuration that provides this functionality.
This .asoundrc is to be used when you are on surround speakers and want to play surround sources natively and stereo ones upmixed automatically.

My system specs:

  • 5.1 speaker set without integrated crossover (i.e. a mechanism that sends signals below a certain frequency to other speaker than those above that same frequency) or low/highpass-filtering of any sort.

  • Asus Xonar D1 sound card

This is my  ~/.asoundrc:

# ALSA configuration for use with surround speaker sets.
# Provides on-demand upmixing via plugin plus
# lowpass filtering/crossover capability plus
# software-mixing/dmix support.
# Possibly useful sources include:
# For those who understand German:

# Change default samplerate conversion algorithm to
# SRC_SINC_MEDIUM_QUALITY. Requires package "libsamplerate".
# See
# Other resampling algorithms are available.
defaults.pcm.rate_converter "samplerate_medium"

# The first ALSA device of the first soundcard
# (here: Analog Multichannel Ouput).
# See /proc/asound and "aplay -l".
pcm.sndcard {
	type hw
	card 0
	device 0

# Dmix software mixing device.
# Takes multiple input streams, resamples them to target
# rate (here: 48kHz) and sends it to the sound card.
pcm.dmix51 {
	type dmix
	ipc_key 1024
	slave {
		pcm "sndcard"
		channels 6
		rate 48000
		period_time 0		# Fixes audio crackling/stutter
		period_size 1024	# with libsamplerate and chromium.
		buffer_time 0		# Not all options may be
		buffer_size 4096	# absolutely necessary.

# Convert float data from "lowpass51" to integer data
# and pass it on to the dmix device.
pcm.lowpass_float {
	type lfloat
	slave {
		pcm "dmix51"
		format "S16_LE"

# Lowpass filter.
# Requires "ladspa" for plugin support,
# "cmt" for identity_audio plugin and
# "swh-plugins" for lpf plugin.
# See
pcm.lowpass51 {
	type ladspa
	slave.pcm "lowpass_float"
	path "/usr/lib/ladspa"
	plugins {
		# Copies all audio of all channels to other plugins.
		# If no other plugin handles a channel, it comes out unchanged.
		0 {
			id 1098 # Identity (Audio) (1098/identity_audio)
			policy duplicate
			input.bindings.0 "Input";
			output.bindings.0 "Output";

		# Actual low-pass filter functionality.
		# Operate on channel 5 (LFE) and remove
		# frequencies higher than 120Hz.
		1 {
			id 1051  # Low Pass Filter (One Pole) (1051/lpf)
			policy none
			input.bindings.5 "Input";
			output.bindings.5 "Output";
			input {
				controls [ 120 ]

# Automatic upmixing. Requires package "alsa-plugins".
pcm.upmix51 {
	type upmix
	# Simply "lowpass51" won't work.
	# "plug:..." specifies a plug device like
	# the long form for the default device below
	# and takes care of channel/format conversions
	# automatically.
	slave.pcm "plug:lowpass51"
	# Specifying the number of channels to upmix to here is mandatory.
	channels 6

# Default device to be used by all applications playing all sorts of sources.
# There's automatic upmixing for 2.0 sources and native playback of 5.1 sources.
# (possibly others as supported by the upmix plugin)
pcm.!default {
	type plug
	slave.pcm "upmix51"

To understand this file a bit better, read it from bottom to top: Audio data gets passed to the default device declared by "pcm.!default".
It then manipulates that data and passes it on to its slave, so the audio goes from "default" to "upmix51" to "plug:lowpass51" and so on until it finally ends up at "sndcard" which then sends it to your speakers.

Feedback welcome, but note I'm neither an ALSA nor an audio expert.

Last edited by RGamma (2013-08-10 19:17:14)


#2 2013-10-14 17:24:18

Registered: 2009-02-06
Posts: 10

Re: ALSA automatic upmixing with lowpass filtering and dmix support

With your config neither dmix nor upmix are working.
Soundcard is Intel PCH (ALC887-VD).
With no/empty asoundrc dmix is working, but i can't get upmix to work.
Any idea how to fix it?


#3 2013-10-15 08:22:55

Registered: 2007-04-03
Posts: 3,529

Re: ALSA automatic upmixing with lowpass filtering and dmix support

Phate666 wrote:

With your config neither dmix nor upmix are working.

Try a larger buffer_size for starters, e.g. 8192 or 16384.

See config in my sig for ideas.

Show some diagnostic info, including an error message.


Board footer

Powered by FluxBB