Output upsampling distorts, 44.1k to 96k

Bug #1959055 reported by Attila Schler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Confirmed
Wishlist
Unassigned

Bug Description

Using Mixxx with 96000Hz sample rate the upsampled 44100Hz audio becomes quite distorted and also sounds dull.

See more on the issue here:
https://mixxx.discourse.group/t/resampling-distortion-bug/24073/3

Revision history for this message
Daniel Schürmann (daschuer) wrote :

This is a known issue of our linear resampling. It replaces the gap between two 44.1 samples with an artificial sample at the linear average between the both. There is no algorithm in place that recreated the sine wave and puts the sample on that. This is why you and see random above the 22 kHz and occasionally on other frequencies.

Mixxx is using this by default, because it gives the best performance when scratching where we have a different tempo each buffer, in that case the recreation of the sine waves is difficult.
If you enable key lock, other more CPU intensive resamplers are used, but once you are scratching it falls back to the linear type.

But that should be no reason to not use other resample algorithm. We have a pending bug to fix this by using a Sinc algorithm: https://bugs.launchpad.net/mixxx/+bug/1775164
Unfortunately no one has found time to look into that. Do you have interest?

Changed in mixxx:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Attila Schler (atskler) wrote :

The issue is about the resampling for the output, not for the decks for scratching, etc.

The free high quality r8brain resampler could be possibly implemented in Mixxx?

Unfortunately programming is not in my skill set.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Mixxx engine is running with the output sample rate. So there is no extra resampling stage.

r8brain: Probably yes, it has MIT license, but it is not afaik part of any Linux disto
https://www.voxengo.com/product/r8brain/

zita: might work as well with GPL3 license:
http://kokkinizita.linuxaudio.org/linuxaudio/zita-resampler/resampler.html

Revision history for this message
Be (be.ing) wrote :

Is libsamplerate not suitable?

Revision history for this message
Be (be.ing) wrote :

Nevermind, I see that zita-resampler is faster than libsamplerate.

Revision history for this message
Attila Schler (atskler) wrote :

(Reaper just implemented the free r8brain with varispeed support, and with the help of Aleksey Vaneev, and it works with the Linux version.)

Revision history for this message
Be (be.ing) wrote :

I see that resampling for files of sample rates different from the output sample rate is handled together with the tempo fader and scratching: https://github.com/mixxxdj/mixxx/blob/ca1e3246c4b24b73919fd81d12b3b3bbcd323fdf/src/engine/enginebuffer.cpp#L819

Without keylock on, Mixxx uses a simple Hermite interpolation function for resampling:
https://github.com/mixxxdj/mixxx/blob/ca1e3246c4b24b73919fd81d12b3b3bbcd323fdf/src/engine/bufferscalers/enginebufferscalelinear.cpp#L46

According to the comment, that comes from:
https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html

Replacing that with a high quality resampling library would likely be worthwhile.

Revision history for this message
Be (be.ing) wrote :

As far as I can tell there is no upstream source repository for zita-resampler, just a tarball: https://kokkinizita.linuxaudio.org/linuxaudio/downloads/index.html

Also unfortunately it uses a Unix Makefile for its build system and has no pkg-config file. This would need to be replaced with CMake (or Meson) to package in vcpkg. I do not know if Fons Adriaensen would be amenable to that, but if not, a CMakeLists.txt could live in the vcpkg port.

Revision history for this message
Be (be.ing) wrote :

r8brain apparently has no build system at all, so that would have to be fixed.

Revision history for this message
Attila Schler (atskler) wrote :

Now, after Daniel mentioned that the decks are also using the same resampler I tested it with speed +5.02% and -5.02% and compared it with Reaper’s results and Mixxx is terrible. It is clearly audible: the sound is muddier, boxier, and stereo clarity is decreased towards mono, the life becomes sucked out of the music. More with the + speed.

At least now I know why Mixxx and my mix recordings sounded kind of dull and kind of lifeless. I thought it is my interface, my mixer, my headphones, my amp, the PA system, but it comes from this.

In my opinion this is more than just a ”wishlist” thing, it is a serious issue. A deal-breaker one.

Could this be fixed or corrected in the foreseeable future?

Revision history for this message
Be (be.ing) wrote (last edit ):

This is a nice resource for comparing the quality of different resampling algorithms: http://src.infinitewave.ca/

Revision history for this message
Be (be.ing) wrote :

> Without keylock on, Mixxx uses a simple Hermite interpolation function for resampling:
https://github.com/mixxxdj/mixxx/blob/ca1e3246c4b24b73919fd81d12b3b3bbcd323fdf/src/engine/bufferscalers/enginebufferscalelinear.cpp#L46

Huh, actually that function is unused. EngineBufferScaleLinear::do_scale implements its own simple linear resampler.

Revision history for this message
Be (be.ing) wrote :

> Mixxx is using this by default, because it gives the best performance when scratching where we have a different tempo each buffer, in that case the recreation of the sine waves is difficult.

Has this actually been tested by anyone comparing with any resampling libraries? All I could find was this old comment:

https://github.com/mixxxdj/mixxx/pull/525#issuecomment-84217817

but that was comparing the changes in that pull request to what Mixxx had before. I am not aware of any comparisons testing scratching with an external resampling library. If it turns out that Mixxx's linear resampler is indeed best for scratching, perhaps that could be switched to dynamically when scratching but use a higher quality library without scratching.

Revision history for this message
Be (be.ing) wrote :

Pipewire also has a resampling algorithm in it which may be worth considering. Unfortunately it looks like it is coupled to Pipewire APIs and would take some work to split it out to a standalone C library: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/fd1112c4e24423233c3b7acda33b67f84168ea6f/spa/plugins/audioconvert/resample.h

Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/10646

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.