Skip to content

Instantly share code, notes, and snippets.

@thanley11
Created February 27, 2016 18:39
Show Gist options
  • Save thanley11/100754cc911442901867 to your computer and use it in GitHub Desktop.
Save thanley11/100754cc911442901867 to your computer and use it in GitHub Desktop.
Example asoundrc file
# Posted at http://dl.dropbox.com/u/18371907/asoundrc
# Info: http://www.sabi.co.uk/Notes/linuxSoundALSA.html
# Soundcard roundup: http://forums.gentoo.org/viewtopic-p-4192284.html#4192284
# Show programs currently opening ALSA:
# fuser -fv /dev/snd/* /dev/dsp*
# Show opened settings:
# cat /proc/asound/card0/pcm0p/sub0/hw_params
# Show codec:
# cat /proc/asound/card0/codec#0 | grep Codec
# Codec: Realtek ALC889
# Ignore alsaconf: http://wiki.debian.org/alsaconf
# Maybe OSS can be compatible with dmix (aoss, alsa-oss):
# https://bbs.archlinux.org/viewtopic.php?pid=981179#p981179
# http://alsa.opensrc.org/Dmix
# http://forums.gentoo.org/viewtopic-t-856668.html
# http://www.knoppix.net/forum/threads/25372-HowTo-ALSA-Dmix-OSS
# dmix - plug:dmix supports 1-8 channels, and does use dmix!
# Whereas surround51 doesn't use dmix
# http://bbs.archlinux.org/viewtopic.php?pid=745946#p745946
# cat /proc/asound/card0/pcm0p/sub0/hw_params
# From https://bugs.launchpad.net/debian/+source/sdl-mixer1.2/+bug/66483
# Not needed.
#defaults.pcm.dmix_max_periods -1
# Seems reasonable quality, low CPU usage
defaults.pcm.rate_converter "speexrate_medium"
# See /usr/share/alsa/pcm/dmix.conf
#defaults.dmix.period_time 0
#defaults.dmix.periods 4
#defaults.pcm.surround51.device "0"
# softvol: https://bbs.archlinux.org/viewtopic.php?id=126789
# Duplicate output to 2 audio devices:
# http://forums.gentoo.org/viewtopic-t-902670.html
# Equalizer: http://krustev.net/w/articles/Global_equalizer_for_ALSA/
# From https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1853
# Posted at http://bbs.archlinux.org/viewtopic.php?id=95582
# Is a dmix that actually works!
# To prove it, run these commands simultaneously, starting with the first one:
# speaker-test -c 2 -D default
# speaker-test -c 6 -D surround51 -t wav
# Reasons why needed:
# https://bbs.archlinux.org/viewtopic.php?pid=1252966#p1252966
pcm.dmixed {
type asym
playback.pcm {
# See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
type dmix
# Don't block other users, e.g. the Timidity midi-player daemon
# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
ipc_key_add_uid true
ipc_key 5678293
ipc_perm 0660
ipc_gid audio
# Don't put the rate here! Otherwise it resets the rate & channels set below, as shown by: cat /proc/asound/card0/pcm0p/sub0/hw_params
slave {
# 2 for stereo, 6 for surround51, 8 for surround71
channels 6
pcm {
# mplayer chooses S32_LE, but others usually S16_LE
#format S32_LE
format S16_LE
# 44100 or 48000
# 44100 for music, 48000 is compatible with most h/w
#rate 44100
rate 48000
# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
# Maybe helps
nonblock true
type hw
card 0
device 0
subdevice 0
}
# mplayer2 chooses 1024
# period_size 512 with buffer_size 16384 stops crackling in xmame
# 320 breaks flash - https://bbs.archlinux.org/viewtopic.php?id=129458
#period_size 512
period_size 1024
#period_size 512
# 4096 might make sound crackle
# mplayer2 chooses 8192. Half-Life 2 chooses 16384.
# If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=2048
buffer_size 8192
}
}
# apulse (a cut-down replacement for pulseaudio) needs dsnoop
# https://bbs.archlinux.org/viewtopic.php?id=187258
capture.pcm "dsnoop"
}
# Playing
#pcm.!default {
# type asym
# playback.pcm "upmix_20to51_resample"
#}
# Simple upmixing, from http://forums.bodhilinux.com/index.php?/topic/2493-how-to-51-surround-sound-with-alsa/
#pcm.!default {
# type plug
# slave.pcm "surround51"
# slave.channels 6
# route_policy duplicate
#}
# Check that e.g. ut2004 still works, if default is redefined.
# Flash, etc. use this "default" entry.
pcm.!default {
type plug
# Would need to always output to all 6 channels, so the dmixer actually works if e.g. 6-channel is attempted to be started, while 2-channel is playing.
slave.pcm "dmixed"
}
pcm.!surround20 {
type plug
slave.pcm "dmixed"
}
pcm.!surround40 {
type plug
slave.pcm "dmixed"
}
pcm.!surround51 {
type plug
slave.pcm "dmixed"
}
pcm.wine {
type plug
# Output directly, for performance
#slave.pcm "hw:0"
slave.pcm "surround20"
}
# If get error "Slave PCM not usable", then need to use plug:
# If get error "Cannot find rate converter", then install libsamplerate and alsa-plugins
# Lunar Linux: lin ladspa-bs2b
# listplugins
# analyseplugin bs2b
pcm.bs2b {
type ladspa
path "/usr/lib/ladspa"
plugins {
0 {
id 4221 # Bauer stereophonic-to-binaural (4221/bs2b)
input {
controls [ 700 6 ]
}
}
}
# http://bbs.archlinux.org/viewtopic.php?id=95582
slave.pcm "surround20"
}
# http://quitte.de/dsp/caps.html#Narrower from caps-plugins
# Alternative to bs2b, for music via headphones
# analyseplugin caps | grep -A14 Narrow
pcm.narrower {
type ladspa
path "/usr/lib/ladspa"
plugins {
0 {
id 2595 # Narrower - Stereo image width reduction
input {
controls [ 0 0.25 ]
}
}
}
slave.pcm "surround20"
}
# speaker-test -D headphones -c 2 -t wav
# audacious uses less CPU when running bs2b as a listed plugin, probably because of samplerate_best
# Posted at http://bbs.archlinux.org/viewtopic.php?pid=626573#p626573
pcm.headphones {
type rate
slave {
pcm "plug:bs2b"
#pcm "plug:narrower"
#rate 44100
rate 48000
}
#converter "speexrate_medium"
hint {
show on
description "Headphones"
}
}
# speaker-test -D ch51dup -c 2 -t wav
pcm.ch51dup {
slave.pcm "surround51"
slave.channels 6
type plug
# Front and rear
ttable.0.0 0.5
ttable.1.1 0.5
ttable.2.2 0.5
ttable.3.3 0.5
# Center and LFE
ttable.4.4 1
ttable.5.5 1
# Front left/right to center
ttable.0.4 0.5
ttable.1.4 0.5
# Front left/right to rear
ttable.0.2 0.5
ttable.1.3 0.5
}
# From http://marcansoft.com/blog/2009/06/acer-aspire-8930g-linux-audio-support/
# To bring all the 8930g speakers into play.
# Works in mplayer but not audacious - weird!
# Have increased the volume, because mplayer is so quiet.
# speaker-test -D stereo8930 -c 2 -t wav
pcm.stereo8930 {
type plug
slave.pcm "surround51"
slave.channels 6
hint {
show on
description "Stereo speakers 8930g"
}
ttable.0.0 1.5
ttable.1.1 1.5
ttable.0.2 1.5
ttable.1.3 1.5
ttable.0.4 0.3
ttable.1.4 0.3
ttable.0.5 1.0
ttable.1.5 1.0
}
# http://alsa.opensrc.org/SurroundSound
# http://alsa.opensrc.org/Low-pass_filter_for_subwoofer_channel_%28HOWTO%29
# Lunar: lin ladspa tap-plugins swh-plugins cmt-plugins libsamplerate
# Fedora: yum install ladspa ladspa-blop-plugins ladspa-caps-plugins ladspa-cmt-plugins ladspa-swh-plugins ladspa-tap-plugins libsamplerate
# Arch Linux: pacman -S ladspa blop swh-plugins libsamplerate tap-plugins cmt
# For id 1672 - 4 Pole Low-Pass Filter with Resonance (FCRCIA) (1672/lp4pole_fcrcia_oa), install blop-plugins
# listplugins
# analyseplugin cmt
# http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html
# http://forums.gentoo.org/viewtopic-p-4528619.html#4528619
# speaker-test -D upmix_20to51 -c 2 -t wav
# This is one big & nasty PCM, to stop Skype from querying the individual PCM definitions and then crashing with: Assertion `!snd_interval_empty(i)' failed
pcm.upmix_20to51 {
# From http://alsa.opensrc.org/Low-pass_filter_for_subwoofer_channel_%28HOWTO%29
# Set up a third channel for the subwoofer
type plug
slave.channels 3
ttable {
0.0 1 # left channel
1.1 1 # right channel
0.2 0.5 # mix left and right ...
1.2 0.5 # ... channel for subwoofer
}
slave.pcm {
# Apply subwoofer filter
type ladspa
# Set the path to ladspa, to fix this error:
# Playback open error: -2,No such file or directory
path "/usr/lib/ladspa"
channels 3
plugins {
0 {
id 1098 # Identity (Audio) (1098/identity_audio)
policy duplicate
input.bindings.0 "Input"
output.bindings.0 "Output"
}
# From http://alsa.opensrc.org/Low-pass_filter_for_subwoofer_channel_%28HOWTO%29
1 {
id 1672 # 4 Pole Low-Pass Filter with Resonance (FCRCIA) (1672/lp4pole_fcrcia_oa)
policy none
input.bindings.2 "Input"
output.bindings.2 "Output"
input {
controls [ 300 2 ]
}
}
}
slave.pcm {
# Final mixing of 6-channel output
type plug
slave.channels 6
ttable {
0.0 1 # front left
1.1 1 # front right
0.2 1 # rear left
1.3 1 # rear right
# Front left/right to center
0.4 0.5
1.4 0.5
# Subwoofer, more powerful to compensate for bass-removal from other speakers
2.5 2
}
# This next line needs to be "dmixed" rather than e.g. "surround51" - bizarre
slave.pcm "dmixed"
}
}
}
# Channels are wrong way around in Doom3! This fixes them.
# http://www.linuxforen.de/forums/archive/index.php/t-206470.html
# http://forums.seriouszone.com/showthread.php?t=49869&page=10
# http://forums.gentoo.org/viewtopic-p-4173170.html#4173170
# For Audigy 4
# Weird, Doom3 has crappy sound if I add an alsa rate converter.
# Posted at http://ubuntuforums.org/showthread.php?t=1304228
pcm.doom-surround51 {
slave.pcm "dmixed"
slave.channels 6
type route
ttable.0.0 1
ttable.1.1 1
ttable.2.4 1
ttable.3.5 1
ttable.4.2 1
ttable.5.3 1
}
# Pulseaudio workaround: http://ubuntuforums.org/showthread.php?t=1705760
pcm.doom3-8930g {
type plug
slave.pcm {
type dmix
ipc_key 1093 # Must be unique
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm "hw:0,0"
rate 44100
channels 2
#period_time 0
# period_size was 1024 - maybe 512 is better to stop clicks - not sure
period_size 1092
#buffer_time 0
# Doom 3 wants buffer_size 8192
# In ~/.doom3/base/autoexec.cfg
# And ~/.quake4/q4base/autoexec.cfg
# seta s_alsa_pcm "doom3-8930g"
buffer_size 8192
}
}
}
# From https://bbs.archlinux.org/viewtopic.php?id=99185
# And in ~/.mplayer/config: ao=alsa:device=movie
# Alternative, in ~/.mplayer/config: af-add=volnorm=2:0.75
# speaker-test -D movie -c 2 -t wav
pcm.movie {
type plug
slave.pcm "ladcomp_compressor"
slave.channels 6
hint {
show on
description "Movie Volume"
}
}
pcm.ladcomp_compressor {
type ladspa
slave.pcm "ladcomp_limiter"
path "/usr/lib/ladspa"
plugins [
{
label dysonCompress
input {
# peak limit, release time, fast ratio, ratio
controls [0 1 0.5 0.99]
}
}
]
}
pcm.ladcomp_limiter {
type ladspa
slave.pcm "plug:movie8930"
path "/usr/lib/ladspa"
plugins [
{
label fastLookaheadLimiter
input {
# InputGain(Db) -20 -> +20 ; Limit (db) -20 -> 0 ; Release time (s) 0.01 -> 2
# also possible... 20 0 0.8
# If movie is too quiet, increase the first number.
controls [ 5 0 0.8 ]
}
}
]
}
pcm.movie8930 {
type route
slave.pcm "dmixed"
ttable.0.0 1.0
ttable.1.1 1.0
ttable.2.2 1.0
ttable.3.3 1.0
ttable.4.4 1.0
ttable.0.5 0.6
ttable.1.5 0.6
ttable.4.5 0.6
ttable.5.5 0.8
}
pcm.downmix_51to20 {
# From http://www.halfgaar.net/surround-sound-in-linux
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503839
type route
slave.pcm "surround20"
# Front and rear, at 33% of original signal strength
ttable.0.0 0.33
ttable.1.1 0.33
ttable.2.0 0.33
ttable.3.1 0.33
# Center channel routing (routed to front-left and front-right),
# 6dB gaindrop (gain half of main channels) per channel
ttable.4.0 0.16
ttable.4.1 0.16
# LFE channel routing (routed to front-left and front-right),
# 6dB gaindrop (gain half of main channels) per channel
ttable.5.0 0.16
ttable.5.1 0.16
}
# http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PerfectSetup/
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment