mpd-configure: automatically turn Linux into an audiophile music player

Music Player Daemon (mpd) is a great free and open source tool which, together with Linux, can be used to turn any computer into a highest quality bit perfect audio player. That way your PC will act as a transparant transport device for streaming your PCM files, like WAV, FLAC and AIFF, and DSD audio files to your DAC and audio equipment.

For best results, the PC should be connected an external DA-converter with USB or HDMI/I2S and run as few applications as possible, thereby minimizing system load and switching of processors, memory and busses. This can be achieved by running a headless Linux installation and storing and accessing the music files on/from a network connected storage device like a NAS or NFS file server. The sound daemon should be controlled from a remote device, like a smartphone, tablet, laptop or desktop computer running a mpd-client.

A little background on pulseaudio, mpd and alsa

Modern Linux distributions ship with a standard audio library (pulseaudio) which will resample and convert digital audio on the fly for the best plug-and-play user experience. Default mpd-installations will also use those features, which unfortunately makes it unsuitable for audiophile purposes out of the box. The average audiophile user is less concerned with plug-and-play and more concerned with discretion; he/she wants the computer to act as a high end –black-box like– transport device for delivering the original –non altered– digital audio to the DAC or sound card.

This is perfectly feasible with stock software, by performing a few modifications to the mpd configuration file. However, finding the right values can be daunting for non-computer-savvy audio enthusiasts. This page with its scripts is aimed at helping those users. It will automagically find the right values and put them in a valid configuration file.

To determine which formats are natively accepted by your USB DAC, and how it actually behaves when feeding it a certain format, have a look at the article “Alsa-capabilities shows which digital audio formats your USB DA-converter supports” Then, convert your audio files accordingly as explained in the article “Script to convert FLAC files using Shibatch SRC while preserving metadata”.

Preparation

  1. Install Linux on a computer.
  2. Open a terminal by pressing and holding CTRL+ALT while typing T or starting it from the application menu
  3. Install the music player daemon on that computer. Users of Debian (and its derivatives like Ubuntu and Mint) and Arch users may use the following command: sudo apt-get install mpd git || sudo pacman -S mpd git Users of other distributions like Fedora or RHEL/Centos may consult the installation Wiki page for mpd.
  4. Optional but recommended for sound quality: connect the computer to an external (USB-)DAC

That’s it for the preparation. Next we’ll download and use the script to create a working bit perfect mpd configuration file.

Basic usage of mpd-configure

## make the directory where you want to store the script
mkdir /tmp/mpd-configure
## change to that directory
cd /tmp/mpd-configure
## download and unpack the script and other files needed
wget https://lacocina.nl/mpd-configure -O - | tar --strip-components=1 -zxf -
## run the script
bash mpd-configure

That’s it.

Now with some explanation and clarification.

  1. Open a terminal by pressing and holding CTRL+ALT while typing T or starting it from the application menu
  2. Make a directory for the script, the location is not important. mkdir mpd-configure
  3. Change to that directory cd mpd-configure
  4. Download and unzip the mpd-configure script in the current directory wget https://lacocina.nl/mpd-configure -O – | tar –strip-components=1 -zxf –
  5. Stop mpd. sudo systemctl stop mpd
  6. Run the script to generate /etc/mpd.conf : sudo bash mpd-configure -o “/etc/mpd.conf”
  7. Start mpd using the new configuration file. sudo systemctl start mpd

What’s next

Now you’ve installed mpd, configured it for bit perfect playback and started it, you should grab a mpd-client, connect to the mpd-daemon and start enjoying your unaltered bit perfect music!

Advanced usage

More advanced usage: backup an existing `/etc/mpd.conf`, overwrite it with the script generated mpd configuration file, which without any prompts configures mpd to use the first available USB DAC interface in your system, execute the following:

## become root if neccessary
[[ $EUID -eq 0 ]] || sudo su
## stop mpd
systemctl stop mpd
## set the paths to the music and mpd data directories and run the script
## saving the output to `/etc/mpd.conf` and creates a backup of that file
## in case it exists:
CONF_MPD_MUSICDIR="/srv/media/music" CONF_MPD_HOMEDIR="/var/lib/mpd" \
bash mpd-configure --limit usb --noprompts --output "/etc/mpd.conf"  && \
systemctl start mpd
## done (press ENTER)

The code for this script is maintained using the software version control system git. With it is even easier to get and update the script

# install git
sudo apt-get install git || sudo pacman -S git
# download the latest source files for the script
git clone https://gitlab.com/ronalde/mpd-configure.git
# change to the directory where you've downloaded the sources
cd mpd-configure

In the future you can update the script to the latest version by changing to the directory created above and entering

git pull

For more advanced usage, please consult the README file, the mpd man page, the online mpd user manual and the article “How to setup a bit-perfect digital audio streaming client with free software (with LTSP and MPD)”.

One may browse, share, clone and fork the source code of the script at https://gitlab.com/ronalde/mpd-configure.

Summary of changes

    changelog Jan 8, 2016 Added command line parameters Jan 5, 2016 Bug fixes and enhancements Sep 11, 2014 Modified command line instructions

    • installation instructions compatible with Arch Linux
    • other instructions compatible with Arch and other systems using systemctl.

    Apr 21, 2014 Changed configuration snippets:

    • from included in code to seperate files in `./confs-available` which may be symlinked to `./confs-enabled` to activate, ie: cd confs-enabled ## change to the `confs-enabled` directory ln -s ../confs-available/plugin-playlist-lastfm.conf ## enable the plugin bash mpd-configure > mpd.conf ## regenerate the conf

    Apr 18, 2014 Major rewrite of the script:

    • moved `tests/detect-alsa-output-capabilities.sh` to `alsa-capabilities`
    • modified `alsa-capabilities` to make it suitable to be sourced or run by itself from the command line
    • added simple and regexp filtering to `alsa-capabilities`
    • removed alsa interface detection logic out of `mpd-configure`. This
      is now done sourcing `alsa-capabilities`.
    • modified `mpd-configure` to not write to a file by default (see updated `README`)

    Mar 20, 2014:

    Jan 6, 2014

    • fixed several typos and explained the usage a bit more

    Sep 18, 2013

    • enhanced the mpd-configure script and fixed several (severe) bugs, see changelog

    101 thoughts on “mpd-configure: automatically turn Linux into an audiophile music player

    1. This works well.
      I ran the script with no parameters and then edited the resulting mod.conf file manually to alter the file paths and the bind to address.
      The only strange outcome is that files encoded at higher rates than 48khz are sent to the amplifier as 48khz according to the display on the onkyo amplifier. And a 192khz file plays, but stutters!

    2. I spent hours reading and trying to figure this out.
      Your script ran once and worked perfectly.
      Thank you. Thank you.

    3. Thanks for the great tutorials, I have one question:

      With a mpd audio output like this:

      audio_output { 
      type               "alsa"
      name               "MPD alsa"
      device             "hw:0,0"
      mixer_type         "hardware"
      mixer_device       "hw:0"
      mixer_control      "Master"
      auto_resample      "no"
      auto_format        "no"
      }
      

      I can keep using pulse right? it will just “circumvent” pulse, or am I wrong here?

      1. Kamiru said: “I can keep using pulse right? it will just “circumvent” pulse, or am I wrong here?”

        The answer depends on what you mean.

        If you mean “Can I use pulse to playback audio at the same time mpd does?” the answer is no, unfortunately you can’t.

        The purpose of pulse-like systems is to make access to sound cards non-exclusive, ie. make sure different software pieces can access the same physical ports in the audio device in the “same” time. The obvious trade-off is that the “device-sharing” daemon (ie pulse) reconfigures all incoming audio streams to the same format (sample rate and resolution) before sending them as a single combined digital audio stream to the driver/module (ie alsa) of the sound device. With your mpd configuration (device hw:0,0) , mpd will try to access alsa exclusively.

        If you mean “Can I leave pulse installed?” the answer is yes, although you have to stop it before starting mpd.

        I hope this answers your question,
        Ronald

    4. Hi,
      This script don’t works on Xubuntu, complains about zeroconf variable unbound.
      Maybe i forgot something.

    5. Hello, thank for this, your work is much appreciated!
      I’m using USB DAC (Dr. DAC Nano), and since it plays a bit quiet on my headphones, is there a way to get some volume override?

      My settings are:

      audio_output {
      	type             "alsa"
      	name             "Dr. DAC nano - USB Audio"
      	device           "hw:2,0"
      	auto_resample    "no"
      	auto_format      "no"
      	auto_channels    "no"
      }
      mixer_type  "software"
      

      Thanks a lot!

      1. If you want bit perfect playback and you could do without volume control (on the computer side) you could try the following:

        1. set `mixer_type` to `”none”` in `mpd.conf`
        2. using `alsamixer` in the terminal, set the volume of `hw:2,0` to `100(%)`
        3. restart mpd (`sudo systemctl restart mpd`)

        This is general advise which fits scenarios in which the usb dac is connected to a (pre) amp at line level.

        But, in your case, I guess you need a software volume control (as the Dr. Dac seems to lack that?). The real problem appears to be your headphones’ impedance and sensitivity in combination with the (power) amp inside the Dr.Dac.

        Good luck,
        Ronald

    6. Hello Roland, thank you for the answer.

      I’m using this on laptop (on Archlinux), and I also need PulseAudio installed. And it is working just fine. MPD is working just fine, exclusively using the DAC (hw 2,0).

      But I seem to have problem controlling the DAC volume through ALSA. Opening alsamixer, default card is PulseAudio, with F6 selecting sound card “Dr. DAC Nano” and it exits with error “cannot load mixer controls: Invalid argument”.

      Still can not solve this. That’s why I have to control the volume through MPD :(

      Cheers

      1. Hi Blum,

        I understand your need for pulseaudio. Although it’s beyond the scope of this article, did you investigate the alsa mixer problem? For instance, did you try to run:

        pasuspender -- alsamixer -c 2
        

        `pasuspender` to pause pulseaudio while running alsamixer, and `-c 2` to make sure the failure is not caused by failing controls from another sound card, like the one embedded in your system.

        Good luck,
        Ronald

        1. Hello Ronald,
          I tried that, but the result is the same..:

            % pasuspender -- alsamixer -c 2
          cannot load mixer controls: Invalid argument
          

          In fact alsamixer works properly for the embedded soundcard. It fails (with the same error) when I try to control the levels of the USB DAC.

          I tried to solve it, but couldn’t find any solution that works for me. I could not even tell exactly what the problem is.

          The good thing is that the DAC is playing, and is controllable by PulseAudio controls anyway. For MPD/Alsa I actually work-around it with MPD mixer_type “software”, but it is still.. Annoying.

          Thanks

          1. Still some things left to check (I don’t like loose ends ;) :

            1. Does the character device for the mixer control exists (like `/dev/snd/controlC1`):
              find /dev/snd -type l -iname "*usb*" -exec readlink -f "{}" \;
              
            2. does running `amixer` (instead of `alsamixer`) as root produce the same error:
              pasuspender -- sudo amixer -c 2 scontrols
              
            3. does `alsactl` produce output when setting the volume through pulseaudio or mpd:
              pasuspender -- sudo alsactl monitor hw:2
              
            1. Hello Ronald,

              The first one:

              find /dev/snd -type l -iname "*usb*" -exec readlink -f "{}" \;
              

              returns this:

              /dev/snd/controlC2
              /dev/snd/controlC2
              

              Next one:

              pasuspender -- sudo amixer -c 2 scontrols
              

              returns kind of the same error:

              amixer: Mixer hw:2 load error: Invalid argument
              

              And the third:

              pasuspender -- sudo alsactl monitor hw:2
              

              just returns nothing, no matter what I do (increasing or decreasing volume in PulseAudio or MPD). It just holds the sound card busy..

              Thanks for your help. :)

            2. So the mixer device exists, and you have access to it. Curious. I’m out of ideas.

              Seeing the impact of your problem, it seems worthwhile to give the appropriate alsa mailing list a shot. If you do, it would help if you provide them with the output created by alsa-info.sh.

              Good luck,
              Ronald

      1. For those experiencing the same problem, this is the result of the communication of Blum with Clemens Ladisch (the main `snd-usb-audio` developer) on the alsa mailing list:

        “Hello, just a note to everyone interested in running Dr. DAC nano on Linux
        and ALSA. I wrote to ESI about this issue and got this answer:

        > Dr. DAC nano does not have any volume control or mixing functionality as it provides a digital S/PDIF
        output mainly. The only way to control the volume is on application level. So it is all clear now, thank you all.”

      1. Hi Rulet,

        If you mean “can you use mpd as an audio output for vlc?” the answer is: you can’t. mpd is not a magic “audio over the network” tool, but simply a daemon (like a webserver) which can be controlled over the network using the mpd protocol.

        So I’m afraid your question is beyond the scope of this blog.

        Your goal is achievable however, by installing an extra software package called upmpdcli on the host running mpd. This turns that host into an upnp media renderer using mpd as it’s backend. On the client (on which you run vlc) you should configure pulseaudio with an extra virtual upnp output interface, pointing it at the upnp renderer exposed by `upmpdcli` on the mpd host. On the other hand, you don’t really need mpd for that purpose. Another option is using jack2 over the network.

        I hope you understand this has nothing to do with the notion of bit perfectness.

        Regards,
        Ronald

        1. Hmm… thanks for answer. It’s pretty complex. I heard about mpd , but haven’t read much about it. So, if I understand right, mpd is only for audio files not videos(with a sound)?

          1. Indeed. mpd is not a virtual (remote) audio interface. The upnp solution I suggested earlier does work however.

            Through input plugins mpd is able to accept commands to playback `http` and `mms` audio streams besides playing audio files from local storage or over cifs/smb and nfs. Besides that one can use an alsa input interface (line in or microphone in) as an input source for mpd.

            No video though.

            Regards,
            Ronald

            1. Rulet,

              Your gmpc settings seem correct for a normal local installation of mpd.

              So first you should check if mpd itself is running correctly using the command:

              sudo systemctl status mpd

              This should reveal the line:

              Active: active (running)

              But in your case it probably will display something else, like

              Active: inactive (dead)

              In that case, please paste the full output of `sudo systemctl status mpd` in a comment.

              If mpd is running though, we would have to check its configuration and the network configuration of your computer.

              Good luck,
              Ronald

    7. r@prime:~$ sudo systemctl start mpd
      r@prime:~$ sudo systemctl status mpd
      ? mpd.service - Music Player Daemon
         Loaded: loaded (/lib/systemd/system/mpd.service; enabled)
         Active: failed (Result: exit-code) since ??? 2016-03-09 16:53:23 EET; 3s ago
        Process: 3448 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
       Main PID: 3448 (code=exited, status=1/FAILURE)
      
      ??? 09 16:53:23 prime mpd[3448]: errno: failed to open log file "/root/....ry
      ??? 09 16:53:23 prime systemd[1]: mpd.service: main process exited, code...RE
      ??? 09 16:53:23 prime systemd[1]: Unit mpd.service entered failed state.
      Hint: Some lines were ellipsized, use -l to show in full.
      r@prime:~$
      
      1. So mpd is misconfigured. Could you please paste the complete output of the following commands:

        sudo systemctl status -l mpd
        cat /etc/default/mpd
        

        Thanks,
        Ronald

        1. r@prime:~$ sudo systemctl status -l mpd
          [sudo] password for r: 
          ? mpd.service - Music Player Daemon
             Loaded: loaded (/lib/systemd/system/mpd.service; enabled)
             Active: failed (Result: exit-code) since ??? 2016-03-09 16:53:23 EET; 1h 28min ago
            Process: 3448 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
           Main PID: 3448 (code=exited, status=1/FAILURE)
          
          ??? 09 16:53:23 prime mpd[3448]: errno: failed to open log file "/root/.config/mpd/mpd.log" (config line 23): No such file or directory
          ??? 09 16:53:23 prime systemd[1]: mpd.service: main process exited, code=exited, status=1/FAILURE
          ??? 09 16:53:23 prime systemd[1]: Unit mpd.service entered failed state.
          
          r@prime:~$ cat /etc/default/mpd
          ## Defaults for the MPD init script, sourced by /etc/init.d/mpd on Debian
          ## systems.  Uncomment (remove the leading '#') and change values as needed.
          
          ## If you don't want MPD to be started as a system service (for example, if
          ## you want to run it from a regular user account), disable it using the
          ## command 'update-rc.d mpd disable'
          
          ## The configuration file location for mpd:
          # MPDCONF=/etc/mpd.conf
          
          1. So the target mpd configuration directory /root/.config/mpd does not exist. The `mpd-configure` script should have created that directory for you if it didn’t exist when running the script.

            Please try to run it again using the following commands, replacing `/usr/share/music` with the path to where your music files are stored:

            ## install git
            sudo apt-get install git
            ## change to a temporary directory
            cd /tmp
            # download the latest source files for the script
            git clone https://github.com/ronalde/mpd-configure.git
            # change to the directory where you've downloaded the sources
            cd mpd-configure
            sudo CONF_MPD_MUSICDIR=/usr/share/music CONF_MPD_HOMEDIR=/var/lib/mpd bash mpd-configure -o /etc/mpd.conf
            

            This will store the mpd configuration file in the (default) path `/etc/mpd.conf`. In the configuration file, the mpd data directory is set to `/var/lib/mpd` (which the script should create if neccessary) and the directory where mpd scans for music files to `/usr/share/music`.

            After that restart the mpd daemon and try to connect:

            sudo systemctl restart mpd
            sudo systemctl status -l mpd && echo version | telnet localhost 6600
            

            Good luck,
            Ronald

            1. seems like it connected:

              r@prime:~$ cd /tmp
              r@prime:/tmp$ git clone https://github.com/ronalde/mpd-configure.git
              Cloning into 'mpd-configure'...
              remote: Counting objects: 963, done.
              remote: Total 963 (delta 0), reused 0 (delta 0), pack-reused 963
              Receiving objects: 100% (963/963), 299.29 KiB | 314.00 KiB/s, done.
              Resolving deltas: 100% (600/600), done.
              Checking connectivity... done.
              r@prime:/tmp$ cd mpd-configure
              r@prime:/tmp/mpd-configure$ sudo CONF_MPD_MUSICDIR=/home/r/?????? CONF_MPD_HOMEDIR=/var/lib/mpd bash mpd-configure -o /etc/mpd.conf
              error: unsupported SysV option
              
              Usage:
               ps [options]
              
               Try 'ps --help '
                or 'ps --help '
               for additional help text.
              
              For more details see ps(1).
               0) Analog alsa audio output interface `hw:0,0'
               - device name       = Xonar DX                                                    
               - interface name    = Multichannel                                                
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC0D0p                                           
               - encoding formats  = can't detect formats or rates because device is locked      
                                                                                                 
               - monitor file      = /proc/asound/card0/pcm0p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
               1) Digital alsa audio output interface `hw:0,1'
               - device name       = Xonar DX                                                    
               - interface name    = Digital                                                     
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC0D1p                                           
               - encoding formats  = S16_LE, S32_LE                                              
               - monitor file      = /proc/asound/card0/pcm1p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
               2) Digital alsa audio output interface `hw:1,3'
               - device name       = HDA NVidia                                                  
               - interface name    = HDMI 0                                                      
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC1D3p                                           
               - encoding formats  = S16_LE, S32_LE                                              
               - monitor file      = /proc/asound/card1/pcm3p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
               3) Digital alsa audio output interface `hw:1,7'
               - device name       = HDA NVidia                                                  
               - interface name    = HDMI 0                                                      
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC1D7p                                           
               - encoding formats  = S16_LE, S32_LE                                              
               - monitor file      = /proc/asound/card1/pcm7p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
               4) Digital alsa audio output interface `hw:1,8'
               - device name       = HDA NVidia                                                  
               - interface name    = HDMI 0                                                      
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC1D8p                                           
               - encoding formats  = S16_LE, S32_LE                                              
               - monitor file      = /proc/asound/card1/pcm8p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
               5) Digital alsa audio output interface `hw:1,9'
               - device name       = HDA NVidia                                                  
               - interface name    = HDMI 0                                                      
               - usb audio class   = (n/a)                                                       
               - character device  = /dev/snd/pcmC1D9p                                           
               - encoding formats  = S16_LE, S32_LE                                              
               - monitor file      = /proc/asound/card1/pcm9p/sub0/hw_params                     
               - stream file       = (n/a)                                                       
              
                Multiple interfaces found:
                   specify the hardware address of the interface you wish to use
                   for mpd and press [ENTER] to confirm: hw:0,0
               - existing mpd configuration file found in `/etc/mpd.conf',
                   overwrite it (while making a backup of the original)?: Yes
               - backup of existing mpd configuration file created in `/tmp/mpd.conf.UwTu'
               - mpd-configure succesfully created a mpd configuration file in:
              /etc/mpd.conf
              
              r@prime:/tmp/mpd-configure$ sudo systemctl restart mpd
              r@prime:/tmp/mpd-configure$ sudo systemctl status -l mpd && echo version | telnet localhost 6600
              ? mpd.service - Music Player Daemon
                 Loaded: loaded (/lib/systemd/system/mpd.service; enabled)
                 Active: active (running) since ??? 2016-03-09 19:01:59 EET; 10s ago
               Main PID: 5005 (mpd)
                 CGroup: /system.slice/mpd.service
                         ??5005 /usr/bin/mpd --no-daemon
              
              Trying ::1...
              Connected to localhost.
              Escape character is '^]'.
              Connection closed by foreign host.
              r@prime:/tmp/mpd-configure$
              
    8. So the execution of `mpd-configure` succeeded (apart from the `ps` error, for which I created issue #28) and resulted in a running mpd daemon. Though executing a mpd command using telnet failed.

      It seems the hostname `localhost` is pointing to the ipv6 address `::1` instead of the ipv4 address `127.0.0.1`. Could you try the following:

      echo version | telnet -h 127.0.0.1 6600
      
      1. r@prime:~$ echo version | telnet -h 127.0.0.1 6600
        telnet: invalid option -- 'h'
        Usage: telnet [-4] [-6] [-8] [-E] [-L] [-a] [-d] [-e char] [-l user]
        	[-n tracefile] [ -b addr ] [-r] [host-name [port]]
        
        1. The `-h` option is invalid … my bad.

          It should be:

          echo version | telnet 127.0.0.1 6600
          
          1. r@prime:~$ echo version | telnet 127.0.0.1 6600
            Trying 127.0.0.1...
            Connected to 127.0.0.1.
            Escape character is '^]'.
            Connection closed by foreign host.
            
    9. r@prime:~$ telnet 127.0.0.1 6600
      Trying 127.0.0.1...
      Connected to 127.0.0.1.
      Escape character is '^]'.
      OK MPD 0.19.0
      
      1. r@prime:~$ telnet 127.0.0.1 6600
        Trying 127.0.0.1...
        Connected to 127.0.0.1.
        Escape character is '^]'.
        OK MPD 0.19.0
        Connection closed by foreign host.
        
          1. So all is OK.

            The right mpd command was:

            echo "mpc version" | telnet 127.0.0.1 6600
            

            Sorry for that confusion.

            Now please fire up gmpc, change the hostname to `127.0.0.1`, play some music and enjoy!

            Regards,
            Ronald

    10. That’s another problem.

      The alsa interface you configured (`hw:0,0` aka “Xonar DX – Multichannel “) is in use exclusively by another process. Unfortunately my script didn’t show you which process, as it should (remember the `ps` error?).

      So now you should identify which process is locking the card. 99% change it’s pulseaudio:

      sudo lsof | grep '/dev/snd'
      
      1. Pulseaudio is deleted. Here is output:

        r@prime:~$ sudo lsof | grep '/dev/snd'
        [sudo] password for r: 
        plugin-co 5077                r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077                r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077                r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        Chrome_Ch 5077 5078           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        Chrome_Ch 5077 5078           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        Chrome_Ch 5077 5078           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5082           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5082           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 5082           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5083           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5083           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 5083           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5585           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 5585           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 5585           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6317           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6317           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6317           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6320           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6320           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6320           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6321           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6321           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6321           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6322           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6322           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6322           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6323           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6323           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6323           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6493           r  mem       CHR             116,12                   11145 /dev/snd/pcmC0D0p
        plugin-co 5077 6493           r   24r      CHR             116,33          0t0       9453 /dev/snd/timer
        plugin-co 5077 6493           r   25u      CHR             116,12          0t0      11145 /dev/snd/pcmC0D0p
        
        1. So the flash-plugin of chrome (or chromium) is using alsa. Kill chrome (or chromium).

          Next stop and restart playback using gmpc.

          1. …And, by the way, why do you use wordpress? — it’s a crap. The comment system is terrible, why you don’t use that system like f.e. debian forums?

            1. Hi Rulet,

              Better late than never (I hope).

              I dislike wordpress too. I even have some articles (in an almost complete jekyll tree in markdown managed with git) on my computer which are worth publishing. The problem is that I have to focus and as such I can’t win them all.

              So, if you know of any good commenting system which is free and open software and can be run on my own webserver, I promise I’ll get rid of wordpress as soon as possible.

              Regards,
              Ronald


              BTW: still enjoying music through mpd?

        2. That was flashplayer playing in firefox. When I closed firefox mpd could start playing. So if I understand right mpd uses audio device exclusively that no other player can use it at the same time?

          1. Rulet,

            Nice to see you got mpd running. I’ll use your questions to enhance the article, so that its purpose (and that of the script) become more clear.

            Regarding your latest question; like stated in the introduction of this page, the script favors sound quality over convenience. The script therefore configures mpd to use alsa’s (unfiltered) `hw:x,y` interface, which only accepts a single (exclusive) audiostream.

            Regards,
            Ronald

    11. I tried to install and configure MPD with the help of several guides, but none of them was working,
      so then i removed MPD and tried to reinstall the program….

      But then i got an error message saying:

      (synaptic:2895): GLib-CRITICAL **: g_child_watch_add_full: assertion 'pid > 0' failed
      dpkg: unrecoverable fatal error, aborting:
       syntax error: unknown user 'mpd' in statoverride file
      E: Sub-process /usr/bin/dpkg returned an error code
      

      I could not find a solution anymore and i’m afraid i have to reinstall Linux Mint Cinnamon all over again :-(
      So i hope anyone here can help me?

      1. Hi Urquanenator,

        First of all sorry for this late reply.

        It seems you suffer from remains of a previous installation. To really start fresh, you should first “purge” the previous installation(s) of mpd.

        It’s been 15 years since I last used synaptic for package management, but using a terminal screen, this is as easy as running:

        ## 1. remove the mpd package and all files installed
        ## and modifications to the system
        dpkg --purge mpd 
        ## 2. make sure the mpd user account is removed 
        ## (should normally be handled by step 1.)
        deluser mpd
        # 3. (re)install the mpd package
        apt-get install mpd
        

        If one of the steps fail, just carry on with the next.

        Hope this helps.

        Regards,
        Ronald

    12. Greetings,

      Your webpage is one of the most detailed resources I’ve found for mpd. I have tried to use your script to configure my usbaudio output but it does not work. I suspect the problem is due to the fact that my output is to a “usbstreamer” unit (from the miniDSP company). This puts out a Toslink signal, which is on the channel 9 and 10. Your script seems to not be sensitive to this, so I suspect it is putting the signal out on a more sensible channel number scheme. For example, my .jack-plumbing file for connecting MPlayer to this unit is:

      (connect "MPlayer \[[0-9]+\]:out_0" "system:playback_9")
      (connect "MPlayer \[[0-9]+\]:out_1" "system:playback_10")
      

      My .jackdrc file:

      /usr/bin/jackd -v -dalsa -dhw:USBStreamer -r44100 -p1024 -n2
      

      I can play music locally on my laptop with mpd. I can stream to my usbstreamer unit using jack. But I have not found a way to combine mpd with the usbstreamer. Ideally I could get mpd to use jack but I’ve found very little documentation on how to do this.

      1. Hi Ryan,

        From the available alsa audio interfaces, the script lets the user choose which one he/she wants to use for mpd. When there’s a single interface, the scripts will use that (without questions asks).

        This seems to be the case with your MiniDSP USBStreamer, as it –from an alsa point of view– has only a single audio output interface (of type “USB Audio Class 2”). So you’ll end up with a valid mpd configuration file in which the `device` parameter of the `audio_output` section will point to the alsa hardware address of your USB device (eg `”hw:1,0″`).

        From googling around, it seems to be a (known) problem in alsa, and more specifically in the way alsa handles the multi-channel mixer controls for your device.

        Jack somehow manages to get things right, but unfortunately, jack is not capable of bit perfect operation, which is the purpose of my scripts and information.

        You might try the (rather dirty) workaround described in Ubuntu bug #1526569, in which the user deletes the `state` section for `USBStreamer` in alsa’s state file (`/var/lib/alsa/asound.state`), and then reloads `alsa-state`. With fairly recent Linux distributons you could achieve this manually using:

        sudo rm /var/lib/alsa/asound.state && sudo systemctl restart alsa-state.service
        

        But it’s not a fix. I’m afraid I can’t help you to achieve that. Maybe you could fix this using `man alsactl`. On the other hand I would advice you to incourage the hardware manufacturer to work together with alsa’s dev team to get alsa and `snd-usb-audio` patched for this specific device.

        If you’re are after a bit-perfect setup, avoid “solutions” using jack, or alsa’s dmix interfaces, as both will set the sample rate and resolution of the output to fixed values (thereby converting all incoming sound to that fixed format).

        Good luck,
        Ronald

        1. Thanks, I did not know about the asound.state file. I’ve found the usbstreamer section in the file. . . and there is information about the 10 channels there. It looks like the relevant channels might simply be muted. Okay, this gives me a lead. . .

        2. Deleting the asound.state file did not solve the problem. It did change things, though. After asking alsactl to write the asound.state file, the USBStreamer part changed:

          state.USBStreamer {
                  control.1 {
                          iface PCM
                          name 'Playback Channel Map'
                          value.0 3
                          value.1 4
                          value.2 7
                          value.3 8
                          value.4 5
                          value.5 6
                          value.6 12
                          value.7 13
                          value.8 11
                          value.9 9
                          comment {
                                  access read
                                  type INTEGER
                                  count 10
                                  range '0 - 36'
                          }
                  }
          

          which is interesting. I found the relevant documentation for the speaker-positions for ALSA here: https://www.kernel.org/doc/Documentation/sound/alsa/Channel-Mapping-API.txt

          and in the channel-position enum, 3 and 4 are front left and front right. So ?perhaps? this setting is closer to correct. I am not certain.

    13. FYI, here is the usbstreamer part of my asound.state file:

      state.USBStreamer {
      	control.1 {
      		iface PCM
      		name 'Playback Channel Map'
      		value.0 0
      		value.1 0
      		value.2 0
      		value.3 0
      		value.4 0
      		value.5 0
      		value.6 0
      		value.7 0
      		value.8 0
      		value.9 0
      		comment {
      			access read
      			type INTEGER
      			count 10
      			range '0 - 36'
      		}
      	}
      	control.2 {
      		iface PCM
      		name 'Capture Channel Map'
      		value.0 0
      		value.1 0
      		value.2 0
      		value.3 0
      		value.4 0
      		value.5 0
      		value.6 0
      		value.7 0
      		value.8 0
      		value.9 0
      		comment {
      			access read
      			type INTEGER
      			count 10
      			range '0 - 36'
      		}
      	}
      	control.3 {
      		iface MIXER
      		name 'USBStreamer Output Playback Switch'
      		value.0 true
      		value.1 true
      		value.2 true
      		value.3 true
      		value.4 true
      		value.5 true
      		value.6 true
      		value.7 true
      		value.8 true
      		value.9 true
      		comment {
      			access 'read write'
      			type BOOLEAN
      			count 10
      		}
      	}
      	control.4 {
      		iface MIXER
      		name 'USBStreamer Output Playback Switch'
      		index 1
      		value true
      		comment {
      			access 'read write'
      			type BOOLEAN
      			count 1
      		}
      	}
      	control.5 {
      		iface MIXER
      		name 'USBStreamer Output Playback Volume'
      		value.0 255
      		value.1 255
      		value.2 255
      		value.3 255
      		value.4 255
      		value.5 255
      		value.6 255
      		value.7 255
      		value.8 255
      		value.9 255
      		comment {
      			access 'read write'
      			type INTEGER
      			count 10
      			range '0 - 255'
      			dbmin -12750
      			dbmax 0
      			dbvalue.0 0
      			dbvalue.1 0
      			dbvalue.2 0
      			dbvalue.3 0
      			dbvalue.4 0
      			dbvalue.5 0
      			dbvalue.6 0
      			dbvalue.7 0
      			dbvalue.8 0
      			dbvalue.9 0
      		}
      	}
      	control.6 {
      		iface MIXER
      		name 'USBStreamer Output Playback Volume'
      		index 1
      		value 152
      		comment {
      			access 'read write'
      			type INTEGER
      			count 1
      			range '0 - 255'
      			dbmin -12750
      			dbmax 0
      			dbvalue.0 -5150
      		}
      	}
      	control.7 {
      		iface MIXER
      		name 'USBStreamer Clock Selector'
      		value 'USBStreamer Internal Clock'
      		comment {
      			access 'read write'
      			type ENUMERATED
      			count 1
      			item.0 'USBStreamer Internal Clock'
      			item.1 'USBStreamer TOSLINK Clock'
      		}
      	}
      	control.8 {
      		iface MIXER
      		name 'Mic Capture Switch'
      		value.0 true
      		value.1 true
      		value.2 true
      		value.3 true
      		value.4 true
      		value.5 true
      		value.6 true
      		value.7 true
      		value.8 true
      		value.9 true
      		comment {
      			access 'read write'
      			type BOOLEAN
      			count 10
      		}
      	}
      	control.9 {
      		iface MIXER
      		name 'Mic Capture Switch'
      		index 1
      		value true
      		comment {
      			access 'read write'
      			type BOOLEAN
      			count 1
      		}
      	}
      	control.10 {
      		iface MIXER
      		name 'Mic Capture Volume'
      		value.0 255
      		value.1 255
      		value.2 255
      		value.3 255
      		value.4 255
      		value.5 255
      		value.6 255
      		value.7 255
      		value.8 255
      		value.9 255
      		comment {
      			access 'read write'
      			type INTEGER
      			count 10
      			range '0 - 255'
      			dbmin -12750
      			dbmax 0
      			dbvalue.0 0
      			dbvalue.1 0
      			dbvalue.2 0
      			dbvalue.3 0
      			dbvalue.4 0
      			dbvalue.5 0
      			dbvalue.6 0
      			dbvalue.7 0
      			dbvalue.8 0
      			dbvalue.9 0
      		}
      	}
      	control.11 {
      		iface MIXER
      		name 'Mic Capture Volume'
      		index 1
      		value 255
      		comment {
      			access 'read write'
      			type INTEGER
      			count 1
      			range '0 - 255'
      			dbmin -12750
      			dbmax 0
      			dbvalue.0 0
      		}
      	}
      }
      

      The channel map might be the thing that needs modification. Channels 8 and 9 are the ones that are relevant for a toslink signal.

    14. I might have figured out my main ALSA problem. In the control.1 settings, I converted:

      value.8 0
      value.9 0
      

      to

      value.8 3
      value.9 4
      

      and now I can get playback from MPlayer, direct to ALSA.

      One problem I have is that ALSA sees my usb audio device as taking only S32_LE. Is there a sensible way to convert S16_LE and S24_LE to S32_LE and not lose information?

      1. Hi Ryan,

        Great to see you’re solving the problem!

        On your question regarding `S32_LE` there’s good news as well. Modern UAC2-receivers and `snd-usb-audio` pad the original 16 or 24 bit samples with (16 or 8) zeroes. No translation takes place, so nothing is lost!

        Congratulations on your bit-perfect setup!

        Regards,
        Ronald

    15. Hi Ronald

      Thank’s a lot for your script (works great!) and efforts to helps us.
      I’ll suggest add to mpd a native SACD and DSD support. All that I found there, makes me errors at compile.
      I’ll wish contribute with this issue, but sadly my knowledges are very limited.

      Best regards

      1. Hi Mistic0,

        I’m glad my script helped you.

        Regarding (native) support for SACD and DSD: maybe you could try voyage mpd, a complete distribution with built-in DSD/DOP support, or archphile, which has (experimental) built-in support for both DSD/DOP and SACD.

        Good luck,
        Ronald

    16. Hi Ronald

      Thank’s a lot for your quick reply, suggestions, and overall share us your knowledge, a certain know how…,
      not only great scripts…

      I’m triying to compile these mpd forks to my Archlinux, at moment not a dedicated audiophile os
      ( with many compilation errors, even though I’d all needed dependences)

      https://github.com/lintweaker/xmos-native-dsd
      http://git.musicpd.org/cgit/manisiutkin/mpd.git
      https://github.com/hicaoc

      * noob at working :D))

      Best regards and excuse my terrible English

      Mistic0

      1. Hello Cosas,

        Thanks again.

        Regarding your failing compilations:

        1. https://github.com/lintweaker/xmos-native-dsd: didn’t try ;)
        2. http://git.musicpd.org/cgit/manisiutkin/mpd.git: fails because this repository uses outdated mpd source files, like `src/decoder/plugins/WildmidiDecoderPlugin.cxx` that fails to compile (original@2016-08-15, patched@2016-02-26):

        sudo pacman -S glib2
        git clone git://git.musicpd.org/manisiutkin/mpd.git
        cd mpd
        ./autogen.sh
        ./configure
        LANG=C make CPPFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"
        ## (error compiling src/decoder/plugins/WildmidiDecoderPlugin.cxx)
        ##
        ## now with upstream changes merged
        git pull git://git.musicpd.org/master/mpd.git master
        ./autogen.sh
        ./configure
        LANG=C make CPPFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"
        ## (successfully builds)
        

        3. https://github.com/hicaoc: if this about his Volumio2 fork; that did build succesfully (also after merging in the 526 commits it lags behind upstream):

        git clone https://github.com/hicaoc/Volumio2.git
        cd Volumio2
        npm install
        ## (successfully builds)
        ##
        ## now with the upstream commits merged:
        git pull https://github.com/volumio/Volumio2.git master
        npm install
        ## (again a successfull build)
        

        Hope this helps you further.

        Regards,
        Ronald

    17. Hi, I already installed your script on Lubuntu pc and it works beautiful :)
      Now I would like to try it on a RaspberryPi with Raspbian distribution, but it seems the wget command didn’t find the script :(

      1. Hi Arturo,

        Thanks for your kind words and sorry for messing up my web server.

        I fixed those issues and now wget should work as expected again.

        Sorry for the inconvenience.

        Regards,
        Ronald

    18. Thank you so much for your effort to make this, it looks like it’s exactly what I was looking for.
      I’m planning to buy a I2S DAC on top of my raspberry pi but in the mean time I would like to use the headphone plug from the pi.
      Can I use your script now and run it again when I installed the DAC ?

      1. Hi Maikel,

        You can run the scripts as often as you like or need.

        Good luck and happy listening,
        Ronald

        1. Cool, then I can compare too. Thanks for the quick reply and all your effort. I read your other articles too, easy to grasp and very complete.

        2. Hi Ronald,
          I would hereby like to let you know I succesfully generated the mpd.conf file, however, i needed to change the following directories from incorrect:

          ## start processing `02_paths.conf'
          music_directory                   "/root"
          db_file                           "/root/.config/mpd/tag_cache"
          log_file                          "/root/.config/mpd/mpd.log"
          playlist_directory                "/root/.config/mpd/playlists"
          pid_file                          "/root/.config/mpd/pid"
          state_file                        "/root/.config/mpd/state"
          sticker_file                      "/root/.config/mpd/sticker"
          save_absolute_paths_in_playlists  "no"
          ## done processing
          

          To working:

          ## start processing `02_paths.conf'                                                                                                           music_directory                   "/mnt/usbdrive/music"
          db_file                           "/mnt/usbdrive/var/lib/mpd/tag_cache"
          log_file                          "/var/log/mpd/mpd.log"
          playlist_directory                "/mnt/usbdrive/var/lib/mpd/playlists"
          pid_file                          "/run/mpd/pid"
          state_file                        "/var/lib/mpd/state"
          sticker_file                      "/mnt/usbdrive/var/lib/mpd/sticker.sql"
          save_absolute_paths_in_playlists  "no"
          ## done processing
          

          The changes are very clearly noticeable, even on the pi-jack-output
          Thanks again, if you have any questions, please let me know.

          1. Hi Maikel,

            Great to hear you hear the difference!

            Regarding your remarks about the conf file; all of them determine how mpd should work … according to you! So there is no ‘best’ or ‘right’ setting. You just have to make sure the paths are accessible and make sense.

            Regards,
            Ronald

            1. Hi Ronald,
              Ah, ok, sorry for my confusion. I’m still relatively new to Linux.
              I still keep wondering how nice it already sounds, can’t wait until I have the DAC card.
              Greetings Maikel

          2. Hi Maikel,

            After re-reading your previous message I was wondering if you edited the paths manually, or specified them like explained in the fully automated example in the README.md file?

            In short, running the following command would produce your wanted setup, where path/to/your/musicdirectory should be replaced by the real path of the directory which contains your music files:

            CONF_MPD_MUSICDIR="" \
            CONF_MPD_HOMEDIR="/mnt/usbdrive/var/lib/mpd" \
            CONF_MPD_LOGFILE="/var/log/mpd/mpd.log" \
            CONF_MPD_PIDFILE="/run/mpd/pid" \
            CONF_MPD_STATEFILE="/var/lib/mpd/state" \
            bash mpd-configure -o "/etc/mpd.conf"
            

            Although I must say I don’t quite understand your choices; why wouldn’t you store the mpd state and log files beneath the mpd ‘home’ dir (`/mnt/usbdrive/var/lib/mpd` in your case)?

            Then the command would be simplified to:

            CONF_MPD_MUSICDIR="" \
            CONF_MPD_HOMEDIR="/mnt/usbdrive/var/lib/mpd" \
            CONF_MPD_PIDFILE="/run/mpd/pid" \
            bash mpd-configure -o "/etc/mpd.conf"
            

            Regards,
            Ronald

            1. Thank you again Ronald,

              I used the simple version of the script, so that’s the reason I think. I’m going to try your approach soon and will report back later. Sounds logical but I’m a bit of a Linux-noob so it will take me some time.

              Greetings Maikel

    19. Thanxks, very nice – I set it up on a CuBox-i4PRO with armbian.
      Without your script I got crazy about it.
      Only one thing – autoupdate the Music Directory seems not to work, maybe only before creating the database. I set autoupdate to “No” and refresh the database with Cantata(works only with Keyboard Shortcut you have to define before)
      Thanks again (for my little Music Server in my bedroom)

      1. Thanks PHG for your feedback and nice to hear that the script helps you out.

        About the auto_update mpd conf setting; by default the script used to set the auto_update_depth parameter to 0, which means only the directory specified in music_directory itself is auto updated. When you use separate (sub) directories for artists and/or albums (like I do), you should set auto_update_depth to the proper value; ie. something like 1 or 2.

        This actually made me aware of a bug in ./confs-available/general.conf, in which I remarked that a value of 0 meant it should scan all sub directories for new files, which isn’t right.

        I fixed this bug in commit a6400dc.

        So if you update the script (using either git pull or a normal download) the script generates the proper setting; ie auto update everything in your music directory.

        Thanks,
        Ronald

        1. The sound is remarkable good – I tried Volumio and some other Distros for the CuBox-I, but no chance to get them playing or the sound was to “HiFi (to smooth!)”.
          I think arm based boards with armbian OS, mpd and your autoMpdSetup brings up a real nice Audio Player, I am really surprised about the sound! So big thanks to you and of course to the armbian developer(the only OS that’s good working on the CuBox-I!). When I see the cpu load and the memory usage with mpd running, I shall make a little NAS with it too. I don’t think that the auto_update_depth was the problem, to test it i had only some files(no folders) in my music folder. But maybe 0 means 0? That would be a bit strange because that means autoupdate= NO(?)
          The problem was to initialize the mpd database – I think mpd changed there something in the newer versions.
          So, keep on – your efforts have been a great help for me!

          1. Maybe it’s worth for someone – I read it on “MPD / Debian / Realtime Kernel……”
            Edit the file “/etc/security/limits.conf” with sudo and add the following lines:
            @audio – rtprio 99
            @audio – memlock unlimited
            @audio – nice -10
            Should give more priority to audio.

            1. and to optimize a bit more you should disable all powersaving settings.
              With Linux (Ubuntu + Debian, otherwise similiar):
              Install cpufrequtils:
              sudo apt-get install cpufrequtils
              Then edit the following file (if it doesn’t exist, create it):
              sudo nano /etc/default/cpufrequtils
              And add the following line to it:
              GOVERNOR=”performance”
              Save and exit.
              Now you need to disable ondemand daemon, otherwise after you reboot the settings will be overwritten.
              sudo update-rc.d ondemand disable

              reboot

              And you are done!
              You can check your settings with:
              cpufreq-info

            2. Hi PHG,
              Thanks again for these settings. I just tried them but i didn’t install the realtime kernel (yet). I occasionally also use the pi as a plex- and download server.
              Do you think plex and downloading and unpacking is still workable on an rt-kernel? Sorry to ask you but I cannot find any information about it. It should be relatively easy to switch back to previous kernel if I understood correctly, could you confirm that?
              Greetings Maikel

    20. Ronald,
      Yesterday I uninstalled all X11 packages and dependencies on my headless raspbian (pi) and also my mpd was uninstalled;

      sudo apt-get remove --auto-remove --purge 'libx11-.*'
      sudo apt-get autoremove --purge
      

      I installed it again ofcourse and also used your newest script again. I explored the advanced options but decided to use my old settings. The reason is that I use a package called log2ram which reduces read and write cycles on my memory card.
      Because of this I use the following specific path-configuration (maybe interesting for someone else);

      music_directory        "/mnt/usbmusic/music"                                                          
      db_file                           "/mnt/usbmusic/var/lib/mpd/tag_cache"                                          log_file                          "/var/log/mpd/mpd.log"                                                         playlist_directory     "/mnt/usbmusic/var/lib/mpd/playlists"                                          
      pid_file                          "/run/mpd/pid"                                                                 
      state_file                       "/var/lib/mpd/state"                                                           
      sticker_file                   "/mnt/usbmusic/var/lib/mpd/sticker.sql"
      

      @PHG;
      Thank you so much for this information about RT settings. I tried to find out info about for a long time. These settings I definitely will try.

    21. Ronald, seems like a great tool but I’m stuck already downloading it with a 401 Unauthorized error from gitlab.com. Can you fix that? Thanks.

      1. Hi Atarax,

        Nice to hear you’re interested in the script and thanks for your remark.

        It seems I was a bit too hasty in migrating from github to gitlab. Fixed that, so all should be well now!

        Regards,
        Ronald

    22. Hi, any possibility to get the same simple roadmap but with details for setting up of stereo to be output to multichannel DAC (for active multiway speaker arrange). Not converting to any 5.1 formay etc, but just duiplicating left-right, left right for miltiplle DAC channels with possibility to integrate than digital crossovers (like BruteFIR) on each channel?

      1. Hi VVS,

        I think your setup should be doable by assigning an output plugin in the mpd configuration together with alsa’s `multi slave` feature. This maps each of the two channels in the stereo signal that mpd sends to alsa to it’s own dac while keeping their clocks in sync.

        Something like the following (adapted from https://alsa.opensrc.org/TwoCardsAsOne):

        In `/etc/asound.rc`:

        ## used to get a 'wordclock pipe'
        pcm_slave.slavecombineddacs {
        	pcm leftdac
        }
        
        ## the first dac used for the left channel
        pcm.leftdac {
        	type hw
        	card 0
        }
        ctl.leftdac {
        	type hw
        	card 0
        }
        
        ## the second dac used for the right channel
        pcm.rightdac {
        	type hw
        	card 1
        }
        ctl.rightdac {
        	type hw
        	card 1
        }
        
        ## virtual single stereo device
        pcm.virt_stereo_dac {
        	type multi;
        	slaves.left.pcm leftdac;
        	slaves.left.channels 1;
        	slaves.right.pcm rightdac;
        	slaves.right.channels 1;
        
        	# Use leftdac ch 0 mapped to ALSA ch 0
        	bindings.0.slave left;
        	bindings.0.channel 0;
        
        	# Use rightdac ch 0 mapped to ALSA ch 1
        	bindings.1.slave right;
                bindings.1.channel 0;
        }
        ctl.virt_stereo_dac {
        	type hw
        	card 0
        }
        

        In `mpd.conf`:

        audio_output {
        	type             "alsa"
        	name             "Virtual Stereo DAC (built from separate DAC's for left and right)"
        	device           "hw:virt_stereo_dac"
        	auto_resample    "no"
        	auto_format      "no"
        	auto_channels    "no"
        	replay_gain_handler "none"
        	mixer_type         "none"
        }
        

        Of course this setup would go way beyond the purpose of the script. Although I would be tempted to modify if you would supply me with a pair of your beautiful speakers and accompanying DAC’s ;)

        Regards,
        Ronald

    23. Not sure why you need all this when there’s DLNA standard and plenty of DLNA clients for every OS. And most modern receivers and standalone players have networking capabilities and DLNA client – so all music is “bit perfect” anyway.

      1. Dear Paul,

        Thanks for your response but you’re wrong; DLNA is all about interoperatibility. So client, controllers and renderers (which perform the actual playback) can –and will– pretty much do whatever is needed to the audio.

        So it’s targeted towards a perfect user-experience, as long as those users are not concerned about the bit-perfect playback of the audio sources.

        Regards,
        Ronald

    24. Hi

      your config script seems to generate an empty configuration

      ############################################################################
      ### begin of mpd configuration file
      ### created by `mpd-configure' (version 0.9.8) on 2019-01-09T15:58:18+02:00.
      ### see: https://gitlab.com/ronalde/mpd-configure/
      ############################################################################
      ## start processing `01_output-audio-alsa.conf'
      ## done processing

      ## start processing `02_paths.conf'
      ## done processing

      ## start processing `03_general.conf'
      ## done processing

      ## start processing `04_client-limits.conf'
      ## done processing

      ## start processing `05_network.conf'
      ## done processing

      ## start processing `06_zeroconf.conf'
      ## done processing

      ############################################################################
      ### end of mpd configuration file
      ############################################################################

      My alsa config (motherboard + Fiia DAC)


      1) Analog alsa audio output interface `hw:0,0'
      - device name = SB
      - interface name = ALC892 Analog
      - usb audio class = (n/a)
      - character device = /dev/snd/pcmC0D0p
      - encoding formats = S16_LE, S32_LE
      - monitor file = /proc/asound/card0/pcm0p/sub0/hw_params
      - stream file = (n/a)

      2) Analog alsa audio output interface `hw:0,1'
      - device name = SB
      - interface name = ALC892 Digital
      - usb audio class = (n/a)
      - character device = /dev/snd/pcmC0D1p
      - encoding formats = S16_LE, S32_LE
      - monitor file = /proc/asound/card0/pcm1p/sub0/hw_params
      - stream file = (n/a)

      3) Analog alsa audio output interface `hw:1,3'
      - device name = HDMI
      - interface name = HDMI 0
      - usb audio class = (n/a)
      - character device = /dev/snd/pcmC1D3p
      - encoding formats = S16_LE, S32_LE
      - monitor file = /proc/asound/card1/pcm3p/sub0/hw_params
      - stream file = (n/a)

      4) Analog alsa audio output interface `hw:1,7'
      - device name = HDMI
      - interface name = HDMI 1
      - usb audio class = (n/a)
      - character device = /dev/snd/pcmC1D7p
      - encoding formats = S16_LE, S32_LE
      - monitor file = /proc/asound/card1/pcm7p/sub0/hw_params
      - stream file = (n/a)

      5) USB Audio Class Digital alsa audio output interface `hw:2,0'
      - device name = DAC
      - interface name = USB Audio
      - usb audio class = 2 - isochronous asynchronous
      - character device = /dev/snd/pcmC2D0p
      - encoding formats = S32_LE
      - monitor file = /proc/asound/card2/pcm0p/sub0/hw_params
      - stream file = /proc/asound/card2/stream0

      I was interested to check what would be the recommendation for me … without pre re sampling my audio library (needed if hw/ALSA)

      1. I will look in the empty output of the script later on; anyway, you should use the hardware address of your USB DAC (`hw:2,0`) in `/etc/mpd.conf`:


        audio_output {
        type "alsa"
        name "USB Audio DAC"
        device "hw:2,0"
        auto_resample "no"
        auto_format "no"
        auto_channels "no"
        replay_gain_handler "none"
        mixer_type "none"
        }

        Hope this helps.

        Regards,
        Ronald

    Leave a Reply

    Your email address will not be published. Required fields are marked *