More MPD soxr selective resample modes

2020-09-14: The MPD soxr selective resample modes are part of the upcoming moOde 7.0.0 release. MoOde even provide a nice GUI for it.

Earlier I wrote about moOde with MPD Selective Resample about sox and resample. With selective resample takes in account if source sample rate is multiple of 44.1kHz or 48kHz. With selective resample the target sample rate is a integer multiply of source sample rate.

Sox with integer ratio only cost 50% of the CPU resource. Sound wise maybe less artifacts are introduced, but that is up to you and your ears to decide.

The selective resample could only be turned on or off. With a new patch some more flexibility is available.

The selective resample mode is set by combining several flags:


If non is set (0) then default scheme of sox is followed, resample (up and down) everything to the provided target rate.

If the resampled target rate should be a multiple of the source base rate can be set with the flag ADHERE_BASE_CLOCK.

When to resample a source:

  • UPSAMPLE_ALL- Only upsampling.
  • UPSAMPLE_ONLY_48 – only upsampling sources below 88.2kHz.
  • UPSAMPLE_ONLY_44 – only upsampling when source is 44.1kHz or below.

Where the flags have the following value:

  • UPSAMPLE_ALL = 0x03
  • UPSAMPLE_ONLY_48 = 0x02
  • UPSAMPLE_ONLY_44= 0x01

In table the behavior is shown for several source sample rates and target sample rate of 192kHz and 176.4kHz.

Selective Resample Modes

When resampling is used the output rate is shown bold.
Note that using a target rate as expressed in a multiple of 48kHz behaves more natural then express in a multiple of 44.1kHz.


To support this modes you need to patch your MPD executable. The patch is available for the latest 0.21.xx [24|25| and upcoming 26] releases and the 0.22~git development branch.

You can find the 0.21.xx patch here and the 0.22~git patch here.

Applying the to your MPD source tree:

cd MPD/src
patch -b -p2 < /path_to_the_patch/mpd_0.21.xx_selective_resample_mode.patch

After applying the patch, you can build your MPD executable.

If you have an MPD version with support for it, you need to add the following to the MPD configuration:

selective_resample_mode "4"

Note: If you switch back to a version with mode support remember to remove this line, else MPD will not start.

2 Replies to “More MPD soxr selective resample modes”

  1. Hi, I have following this development with interest, found your PR for mpd via the MoOde forum. Great to see this implemented; unfortunately, it does not help me as I have the exact opposite problem:
    I have a vintage DAC (Cambridge Audio DAC III) using Philips TDA 1305T chips. These support only 44.1 and 48 kHz sample rates. It is heavily modified and I like the sound a lot.
    I am driving the DAC running MoOde from a RbPi 3B+ via I2S on a Digiberry Pro + board, which has separate clocks for 44.1 and 48 kHz, and is capable of 192 kHz. I am playing mainly CD quality but also I have many hi-res sources which I would like to downsample on-the-fly.
    One problem is that the RbPi has no way of knowing the frequency limitations of the DAC chips and happily outputs up to 192 kHz. Of course I could instruct Sox to resample everything to 48 kHz but I would like to do that only for exact dividers of the base frequencies. So every multiple of 44.1 kHz should be downsampled to 44.1 kHz; similar for 48 kHz. I think linear interpolation would do fine in these cases.

    Seems to me that your code could easily be expanded to also cover this situation. Am I correct? If so, I should be able to build my own mpd and test it.

    Kind regards from the Netherlands, Nijs

  2. Yes that is no problem.
    Just modify one of the existing modes (new mode would require cahnge to moOde ui to make it selectable) to the behaviour you require. Place your own build in `/var/local/www/mpd_versions` with and own name like mpd-0.22.6custom_p0x3.
    Then add your version the text file `/var/local/www/mpd_versions.conf` with a line like
    0.22.6custom_p0x3;0.22.6csutom_p0x3 (My Custom build).

    After that you can select your own version of mpd from the moode mpd version selector (and easy switch back between the different versions).

Leave a Reply

Your email address will not be published.