Skip to content

Instantly share code, notes, and snippets.

@hww
Last active January 31, 2018 05:43
Show Gist options
  • Save hww/6917df719fe523659a24ccd61d2517e5 to your computer and use it in GitHub Desktop.
Save hww/6917df719fe523659a24ccd61d2517e5 to your computer and use it in GitHub Desktop.
# =========================================================================
# first some of helpfull functions
# =========================================================================
# -------------------------------------------------------------------------
# to start stop service
# -------------------------------------------------------------------------
systemctl stop mpd
systemctl start mpd
# -------------------------------------------------------------------------
# to kill/restart alsa
# -------------------------------------------------------------------------
alsactl kill rescan
alsactl nrestore
# -------------------------------------------------------------------------
# to start stop pulse
# -------------------------------------------------------------------------
pulseaudio --kill
pulseaudio --start
# -------------------------------------------------------------------------
# too kill and start mpd
# -------------------------------------------------------------------------
mpd --kill
# to satrt
mpd
# -------------------------------------------------------------------------
# check alsa devices
# -------------------------------------------------------------------------
cat /proc/asound/pcm
# -------------------------------------------------------------------------
# check actual sampling rates
# -------------------------------------------------------------------------
cat /proc/asound/U7/pcm*/sub*/hw_params
# -------------------------------------------------------------------------
# check list of devices
# -------------------------------------------------------------------------
aplay -l
# in my case result is
**** List of PLAYBACK Hardware Devices ****
card 0: U7 [Xonar U7], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
............
# the device name betwee card X: and first bracket [
# so in my case "U7"
# =========================================================================
# now edit asound.conf or ~/.asoundrc
# This file will load when any app load alsalib
# -------------------------------------------------------------------------
# Settings for XonarU7 sound board
pcm.xonarU7 {
type hw
card U7
}
ctl.xonarU7 {
type hw
card U7
}
# Settings for DMIX for mixing multiple channels
# for sound board which does not support it
pcm.dmixer {
type dmix
ipc_key 4455
slave {
pcm xonarU7
rate 192000
format "S24_3LE" # U7 support S24_3LE
period_time 0
period_size 1024
buffer_size 4096
}
}
# Settings for default alsa device
pcm.!default {
type plug
slave.pcm "dmixer"
}
# Additional stuff from random web page in case
# if dmixer setting are not working as they shoutld
defaults.pcm.dmix.rate 192000
defaults.pcm.dmix.format S24_3LE
# -------------------------------------------------------------------------
# NOTE Another ide is to use automatic conversion plugin
# https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
# =========================================================================
# make alsa appliction does not look the device
# chanche /etc/pulse/default.pa
load-module module-alsa-sink device=dmixer
# =========================================================================
# EDIT /etc/mpd.conf
# See: /usr/share/doc/mpd/mpdconf.example
# =========================================================================
# -------------------------------------------------------------------------
# User
user "valery"
# Requred
db_file "~/.config/mpd/database"
log_file "~/.config/mpd/mpd.log"
# Optional
music_directory "/my-data/mypassport/MUSIC/"
playlist_directory "~/.config/mpd/playlists"
pid_file "~/.config/mpd/pid"
state_file "~/.config/mpd/state"
sticker_file "~/.config/mpd/sticker"
# Sound Settings
# This is way to send to pulse and resample there
audio_output {
type "pulse"
name "Pulse Audio"
format "192000:32:2"
}
# As alternative
# There is way send to alsa
audio_output {
type "alsa"
name "U7 - USB Audio"
# device "hw:0,0"
# auto_resample "no"
# auto_format "no"
# auto_channels "no"
replay_gain_handler "none"
# mixer_type "none"
mixer_type "software"
format "192000:32:2"
}
audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "44100:16:2"
}
# Playlist
save_absolute_paths_in_playlists "no"
filesystem_charset "UTF-8"
id3v1_encoding "UTF-8"
log_level "default"
auto_update "yes"
auto_update_depth "4096"
# Player
replaygain "off"
# Networking
port "6600"
bind_to_address "127.0.0.1"
max_connections "10"
max_playlist_length "16384"
max_command_list_size "2048"
max_output_buffer_size "8192"
zeroconf_enabled "True"
# -------------------------------------------------------------------------
# =========================================================================
# Configure pulseaudio
# -------------------------------------------------------------------------
# ~/.config/pulse/daemon.conf
resample-method = speex-float-1
default-sample-format = s24le
default-sample-rate = 192000
alternate-sample-rate = 48000
default-sample-channels = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment