# STEP10
# YOUR USB DAC MUST BE CONNECTED TO THE USB PORT AND READY
# edit the configuration of MPD with a DAC USB connected but before:
# identify your USB DAC ID (usually card 1):
$ aplay -l
# in case of *No Soundcard Error*, read our tutorial to install ALSA correctly and prepare your Linux distribution
# to list of playback hardware devices (card 0, card 1, car 2….) and to get the index of your USB DAC
# report this index number in the line device “hw:x,0” of all audio output in mpd.conf see below
# the USB DAC should be indexed 1 or 2
# BEWARE if you disable the RASPBERRY PI HDMI port later (see the corresponding howto) the ID of your DAC will certainly change which require to modify mpd.conf audio output as well
# backup default MPD config mpd.conf into our Downloads/ directory
$ sudo cp /etc/mpd.conf ~/Downloads/mpd.conf
# erase the current config and replace with the settings below
$ sudo truncate -s 0 /etc/mpd.conf
$ sudo nano /etc/mpd.conf
# replace with the settings below
# nano shortcut: CTRL + K to cut an entire line
# this settings use USB DAC on card 1 (hw:1,0), change the index accordingly if needed
# copy the lines below and right-click on nano editor to paste
#
music_directory "/mnt/media" playlist_directory "/var/lib/mpd/playlists" db_file "/var/lib/mpd/tag_cache" log_file "/var/log/mpd/mpd.log" # uncomment pid_file if you do not use systemd #pid_file "/run/mpd/pid" state_file "/var/lib/mpd/state" sticker_file "/var/lib/mpd/sticker.sql" user "mpd" group "audio" bind_to_address "any" port "6600" log_level "default" restore_paused "yes" #save_absolute_paths_in_playlists "no" #metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc" #metadata_to_use "+comment" auto_update "no" #auto_update_depth "3" follow_outside_symlinks "yes" follow_inside_symlinks "yes" zeroconf_enabled "no" zeroconf_name "Music DAC" connection_timeout "120" #password "password@read,add,control,admin" #default_permissions "read,add,control,admin" # ############################################################################### # Database ####################################################################### # #database { # plugin "proxy" # host "other.mpd.host" # port "6600" #} # Input ####################################################################### # input { plugin "curl" # proxy "proxy.isp.com:8080" # proxy_user "user" # proxy_password "password" } # QOBUZ input plugin input { enabled "no" plugin "qobuz" # app_id "ID" # app_secret "SECRET" # username "USERNAME" # password "PASSWORD" # format_id "N" } # TIDAL input plugin input { enabled "no" plugin "tidal" # token "TOKEN" # username "USERNAME" # password "PASSWORD" # audioquality "Q" } # Decoder ##################################################################### # decoder { plugin "ffmpeg" enabled "yes" # gapless "no" } decoder { plugin "wildmidi" enabled "no" } replaygain "off" replaygain_preamp "0" #replaygain_missing_preamp "0" #replaygain_limit "yes" volume_normalization "no" filesystem_charset "UTF-8" ############################################################################### audio_output { type "alsa" name "Default" device "hw:1,0" mixer_type "none" dop "no" } audio_output { type "alsa" name "ALSA DAC DOP" device "hw:1,0" mixer_type "none" dop "yes" } audio_output { type "alsa" name "ALSA DAC NoDOP" device "hw:1,0" mixer_type "none" dop "no" } audio_buffer_size "4096" #buffer_before_play "10%" max_output_buffer_size "131072" max_connections "128" audio_output { type "alsa" name "ALSA EQ" device "plug:plugequal" # format "44100:16:2" # optional # mixer_device "default" # optional # mixer_control "PCM" # optional # mixer_index "0" # optional }
# optional output to stream music to local device (phone, tablet, pc,...) audio_output { type "httpd" name "Local Stream" encoder "vorbis" #encoder "lame" # comment vorbis and use lame for iOS support port "8000" quality "5.0" # do not define if bitrate is defined #bitrate "128" # do not define if quality is defined #format "44100:16:1" always_on "yes" # prevent MPD from disconnecting all listeners when playback tags "yes" # httpd supports sending tags to listening streams. }
# CTRL+O to save
# CTRL+X to exit
# OPTIONAL: You can skip this step if a server distribution is installed
# but for desktop distro you have to disable MPD user service
# because you run it as a headless server:
$ sudo rm /etc/xdg/autostart/mpd.desktop
$ sudo systemctl --global disable mpd.service
$ sudo systemctl --global disable mpd.socket
# MPD server is now configured.
# Click NEXT button to activate Music Player Daemon
#
# TROUBLESHOUTING
# in case of error (generally occurs within 5s just after playing) :
alsa_output: Decoder is too slow; playing silence to avoid xrun
# adding the following lines to all your audio output in mpd configuration (/etc/mpd.conf) may help
#
buffer_time "200000" period_time "5084"
#
# edit mpd.conf and scroll to audio output area to add the 2 lines
$ sudo nano /etc/mpd.conf
. . . audio_output { type "alsa" name "Default" device "hw:1,0" mixer_type "none" dop "no" buffer_time "200000" period_time "5084" } audio_output { type "alsa" name "ALSA DAC DOP" device "hw:1,0" mixer_type "none" dop "yes" buffer_time "200000" period_time "5084" } . . .
#
# in case of non fatal binding error
server_socket: bind to '0.0.0.0:8000' failed (continuing anyway, because binding to '[::]:8000' succeeded): Failed to bind socket: Address already in use
# a binding already exists due to ipv6, however mpd is running correctly. if you do not need ipv6 support follow these instructions to disable it by using sysctl command and by adding the kernel option ipv6.disable=1 https://www.wikihow.com/Disable-Ipv6-on-Linux
# keep a Bit Perfect audio with a control of the volume, possible?
# yes, this is possible but only if this is supported by your USB DAC
# check if hardware volume is supported
# get the card number of your USB DAC
# (should be 1 if you only have 1 DAC connected)
$ aplay -l
pi@musiclounge:~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: S9Pro [Hidizs S9Pro], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0 card 1: MQA [D90 MQA], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 0: fe.dai-link-0 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 1: fe.dai-link-1 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 2: fe.dai-link-2 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0
# in this example we have 2 DAC connected
# list mixer contents of the device 1
$ amixer --card 1 scontents
pi@musiclounge:~$ amixer --card 1 pi@musiclounge:~$
# nothing for the topping D90
# now for the S9 Pro
$ amixer --card 0 scontents
pi@musiclounge:~$ amixer --card 0 Simple mixer control 'PCM',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 127 Mono: Front Left: Playback 127 [100%] [0.00dB] [on] Front Right: Playback 127 [100%] [0.00dB] [on] Simple mixer control 'PCM',1 Capabilities: pvolume pvolume-joined Playback channels: Mono Limits: Playback 0 - 127 Mono: Playback 87 [69%] [-20.00dB]
# great! the hardware volume is supported on this DAC
# now we change the mpd.conf to add this dac with hardware volume control
$ sudo nano /etc/mpd.conf
# add this at the end of your configuration
# hw:0 must changed to corresponding card number of your DAC
audio_output { type "alsa" name "Hidizs S9 Pro Mixer ON" device "hw:0,0" mixer_type "hardware" mixer_control "PCM" mixer_index "0" dop "no" }
# CTRL+O to save
# CTRL+X to exit
# that’s it!
# Our recommendation is to avoid using volume control in MPD configuration if
# a physical or integrated volume control is already included with your DAC
# in case you have no support of hardware mixer (volume) in your DAC capabilities
# but still want a “software” control of the volume here is the audio output to add to mpd.conf
# this is obviously not recommended
audio_output { type "alsa" name "ALSA Software Volume" device "hw:1,0" mixer_type "software" dop "no" }
Click the button NEXT below to continue…