Last active
September 9, 2022 01:27
-
-
Save JasonLG1979/f29cb0f14218a3b20db5d32c2cfae5ed to your computer and use it in GitHub Desktop.
/etc/asound.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/asound.conf | |
############################################################################### | |
pcm.hqstereo20 { | |
@args [ | |
SAMPLE_RATE FORMAT BUFFER_PERIODS | |
BUFFER_PERIOD_TIME VOL_MIN_DB | |
VOL_MAX_DB VOL_RESOLUTION VOL_NAME | |
] | |
# Sampling rate in Hz: | |
# 44100, 48000, 88200, 96000... | |
# Defaults to 44.1 kHz (CD Quality). | |
@args.SAMPLE_RATE { | |
type integer | |
default 44100 | |
} | |
# Format: | |
# S16_LE, S24_LE, S24_3LE, S32_LE... | |
# Defaults to S16_LE (CD Quality). | |
@args.FORMAT { | |
type string | |
default S16_LE | |
} | |
# Periods per buffer. | |
@args.BUFFER_PERIODS { | |
type integer | |
default 4 | |
} | |
# Period size in time. | |
# Defaults to 125ms (0.125 sec). | |
# BUFFER_PERIODS * BUFFER_PERIOD_TIME = buffer time/size | |
@args.BUFFER_PERIOD_TIME { | |
type integer | |
default 125000 | |
} | |
# Minimal dB value of the software volume control. | |
@args.VOL_MIN_DB { | |
type real | |
default -51.0 | |
} | |
# Maximal dB value of the software volume control. | |
@args.VOL_MAX_DB { | |
type real | |
default 0.0 | |
} | |
# How many steps between min and max volume. | |
@args.VOL_RESOLUTION { | |
type integer | |
default 256 | |
} | |
# The name of the software volume control. | |
# If your card does not have hardware volume control | |
# naming it PCM will cause most apps that use alsa volume | |
# to use the software volume control. | |
@args.VOL_NAME { | |
type string | |
default Softvol | |
} | |
type softvol | |
min_dB $VOL_MIN_DB | |
max_dB $VOL_MAX_DB | |
resolution $VOL_RESOLUTION | |
control { | |
name $VOL_NAME | |
card { | |
@func refer | |
name defaults.ctl.card | |
} | |
} | |
slave.pcm { | |
type plug | |
slave.pcm { | |
type dmix | |
ipc_key { | |
@func refer | |
name defaults.pcm.ipc_key | |
} | |
ipc_gid { | |
@func refer | |
name defaults.pcm.ipc_gid | |
} | |
ipc_perm { | |
@func refer | |
name defaults.pcm.ipc_perm | |
} | |
slowptr 1 | |
hw_ptr_alignment roundup | |
slave { | |
pcm { | |
type hw | |
nonblock { | |
@func refer | |
name defaults.pcm.nonblock | |
} | |
card { | |
@func refer | |
name defaults.pcm.card | |
} | |
device { | |
@func refer | |
name defaults.pcm.device | |
} | |
subdevice { | |
@func refer | |
name defaults.pcm.subdevice | |
} | |
} | |
channels 2 | |
period_size 0 | |
buffer_size 0 | |
buffer_time 0 | |
period_time $BUFFER_PERIOD_TIME | |
periods $BUFFER_PERIODS | |
rate $SAMPLE_RATE | |
format $FORMAT | |
} | |
bindings { | |
0 0 | |
1 1 | |
} | |
} | |
} | |
} | |
############################################################################### | |
# Find your sound card: | |
# aplay -l | |
# Find your card's supported format(s) and sampling rate(s) While no other audio is being played: | |
# aplay -Dhw:<card #>,<device #> --dump-hw-params /usr/share/sounds/alsa/Front_Right.wav | |
# For example: | |
# aplay -Dhw:0,0 --dump-hw-params /usr/share/sounds/alsa/Front_Right.wav | |
# The output should look something like this if the card and device combination is correct: | |
# ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED | |
# FORMAT: S16_LE S24_LE S32_LE | |
# SUBFORMAT: STD | |
# SAMPLE_BITS: [16 32] | |
# FRAME_BITS: [32 64] | |
# CHANNELS: 2 | |
# RATE: [8000 192000] | |
# ... | |
# The above card supports formats S16_LE, S24_LE, and S32_LE, at up to a sampling rate of 192000. | |
# Check to see if your sound card has hardware volume controls. | |
# amixer -c<card #> scontrols | |
# For example: | |
# amixer -c0 scontrols | |
# The output should look something like this if your card has hardware volume control: | |
# Simple mixer control 'PCM',0 | |
# ... | |
# Change to the card number that you want to be the default control card. | |
# Default: 0 | |
defaults.ctl.card 0 | |
# Change to the card number that you want to be the default playback card. | |
# It should usually be the same as defaults.ctl.card. | |
# Default: 0 | |
defaults.pcm.card 0 | |
# Change to the device number that you want to be the default device on the default card. | |
# 0 or 1 is usually the correct device number. | |
# Default: 0 | |
defaults.pcm.device 0 | |
# Change to the subdevice number that you want to be the default subdevice on the default device. | |
# Should rarely need to be changed. | |
# Default: -1 | |
defaults.pcm.subdevice -1 | |
# To install high quality samplerate converters on Debian based systems: | |
# sudo apt install -y --no-install-recommends libasound2-plugins | |
# To list available rate_converter's: | |
# echo "$(ls /usr/lib/*/alsa-lib | grep "libasound_module_rate_")" | sed -e "s/^libasound_module_rate_//" -e "s/.so$//" | |
# Uncomment and replace speexrate_medium with the rate_converter of your choice. | |
# defaults.pcm.rate_converter speexrate_medium | |
# Once everything is configure close and save this file and test with: | |
# speaker-test -c2 -l1 | |
# While audio is playing you can verify your settings with: | |
# cat /proc/asound/card*/pcm*p/sub*/hw_params | |
pcm.!default { | |
type empty | |
# Optional args: | |
# SAMPLE_RATE: default: 44100 | |
# FORMAT: default: S16_LE | |
# BUFFER_PERIODS: default: 4 | |
# BUFFER_PERIOD_TIME: default: 125000 | |
# VOL_MIN_DB: default: -51.0 | |
# VOL_MAX_DB: default: 0.0 | |
# VOL_RESOLUTION: default: 256 | |
# VOL_NAME: default: Softvol | |
# Example: | |
# hifiberry dac+ zero on a pi zero. | |
# slave.pcm "hqstereo20:FORMAT=S32_LE,BUFFER_PERIOD_TIME=250000,VOL_MIN_DB=-48.0,VOL_NAME=PCM" | |
slave.pcm "hqstereo20" | |
} | |
############################################################################### | |
ctl.!default { | |
type hw | |
card { | |
@func refer | |
name defaults.ctl.card | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment