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”.


  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

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 -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:

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

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

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

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/ 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

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

    1. Pingback: How to setup a bit-perfect digital audio streaming client with free software (with LTSP and MPD)

    2. Pingback: Script to convert FLAC files using Shibatch SRC while preserving meta data

    3. 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!

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

      With a mpd audio output like this:

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

      1. Ronald van Engelen

        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,

    5. Pingback: How to turn Music Player Daemon (mpd) into an audiophile music player | Happy Family

    6. Pingback: UPDATED: Which digital audio formats does your USB DA-converter support and use?

    7. Pingback: Final Decision - Page 2

    8. Pingback: UPnP/DLNA renderer under linux that does gapless and dad

    9. Pingback: SQ comparison: roll-your-own vs. commercial servers

    10. Pingback: La cocina de la información | Tuning Linux towards a headless dedicated bit perfect music player

    11. 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:

      Thanks a lot!

      1. Ronald van Engelen

        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,

    12. 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 :(


      1. Ronald van Engelen

        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 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,

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

          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.


          1. Ronald van Engelen

            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):
            2. does running amixer (instead of alsamixer) as root produce the same error:
            3. does alsactl produce output when setting the volume through pulseaudio or mpd:
            1. Hello Ronald,

              The first one:

              returns this:

              Next one:

              returns kind of the same error:

              And the third:

              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. Ronald van Engelen

              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

              Good luck,

      1. Ronald van Engelen

        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. Ronald van Engelen

        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.


        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. Ronald van Engelen

            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.


            1. Ronald van Engelen


              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:

              This should reveal the line:

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

              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,

      1. Ronald van Engelen

        So mpd is misconfigured. Could you please paste the complete output of the following commands:


          1. Ronald van Engelen

            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:

            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:

            Good luck,

            1. seems like it connected:

    13. Ronald van Engelen

      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 Could you try the following:

        1. Ronald van Engelen

          The -h option is invalid … my bad.

          It should be:

          1. Ronald van Engelen

            So all is OK.

            The right mpd command was:

            Sorry for that confusion.

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


    14. Ronald van Engelen

      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:

      1. Pulseaudio is deleted. Here is output:

        1. Ronald van Engelen

          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. Ronald van Engelen

              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.


              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. Ronald van Engelen


            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.


    15. 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:

      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. Ronald van Engelen

        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:

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

        Hope this helps.


    16. 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:

      My .jackdrc file:

      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. Ronald van Engelen

        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:

        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,

        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:

          which is interesting. I found the relevant documentation for the speaker-positions for ALSA here:

          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.

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

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

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


      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. Ronald van Engelen

        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!


    19. Pingback: Sistema Hi-Fi digitale a basso costo, con software (quasi) totalmente libero – Linux Difficile?

    20. 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. Ronald van Engelen

        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,

    21. 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)

      * noob at working :D))

      Best regards and excuse my terrible English


      1. Ronald van Engelen

        Hello Cosas,

        Thanks again.

        Regarding your failing compilations:

        1. didn’t try ;)
        2. 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):

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

        Hope this helps you further.


    22. 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. Ronald van Engelen

        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.


    23. 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. 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:

          To working:

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

          1. Ronald van Engelen

            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.


            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. Ronald van Engelen

            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 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:

            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:


            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

    24. Pingback: Alix 2d2/1e , Sotm PCI to USB , RAVPower 12v LifePO4, Linux Voyage MPD

    25. 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. Ronald van Engelen

        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.


        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:
              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


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

            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

    26. 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"

      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.

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

      1. Ronald van Engelen

        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!


    28. 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. Ronald van Engelen

        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

        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; 0;
        	# Use rightdac ch 0 mapped to ALSA ch 1
        	bindings.1.slave right;
        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 ;)


    Leave a Reply

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