More MPD soxr selective resample modes

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:

SELECTIVE_RESAMPLE_MODE = ADHERE_BASE_CLOCK and [UPSAMPLE_ALL | UPSAMPLE_ONLY_48 | UPSAMPLE_ONLY_44]

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:

  • ADHERE_BASE_CLOCK = 0x08
  • 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.

Use

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.

Leave a Reply

Your email address will not be published.