Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional Interpolation methods for resampling #9328

Open
mixxxbot opened this issue Aug 23, 2022 · 10 comments
Open

additional Interpolation methods for resampling #9328

mixxxbot opened this issue Aug 23, 2022 · 10 comments

Comments

@mixxxbot
Copy link
Collaborator

Reported by: kazakore
Date: 2018-06-05T11:32:00Z
Status: Confirmed
Importance: Wishlist
Launchpad Issue: lp1775164


Feature request:

I would like to see additional Interpolation options to increase the audio quality when not using Key Lock.

Currently there is no option for this, with Linear being the only possible choice. This may be good for low powered devices but does not provide overly good audio quality.

Minimum options I would like to see are:
None
Linear
Sinc

I can find a number of examples where these are provided, often with various different quality settings for Sinc (how many convolutions of the sinx/x curve it iterates over) if this might be of help (eg I believe the Audacious and its Plugins are written in C++ so be a possible source of inspiration if needed) but I feel the learning curve would be too high for me to attempt myself with any reasonable timeframe.

Additionally I would suggest a look into Cubic Spline Interpolation. I haven't really come across this so commonly in open source software but have seen it well used in propriety software and it gives a quality close to that of Sinc while being far easier on the processor.

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2018-06-05T13:06:59Z


We originally had a cubic interpolation in Mixxx which was considered as sound not better.
21c869c

The file of question now lives here:

// Perform linear interpolation

I think a good and easy to implement feature would be to add an option to use either rubber band or Soundtouch for the linear case as well.

Does anyone know what they do in the linear case (vinyl pitch) ?

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2018-06-05T13:55:39Z


Ok, Soundtouch uses it's own cubic interpolation.
Rubberband uses libsamplerate by default with a sinc interpolator. SRC_SINC_FASTEST.

@mixxxbot
Copy link
Collaborator Author

Commented by: kazakore
Date: 2018-06-05T14:02:13Z


SoundTouch, being a frames based method of timestrectch, I really don't think would work well at all. The only way I could imagine RubberBand doing it would be double processing, first timestretching as normal, then pitchshifting to the pitch it should be. I could well be wrong but if that's the case that would be an excessive amount of processing to achieve this!

And I've done quite a lot of comparison of Linear Vs Cubic Interpolation at the output of a DAW and Cubic has nearly always sounded far superior. If it didn't then my guess would be a faulty implementation previously.....

Is there a PR number or similar I can use to test myself? Or is it just a matter of copying over the file you have specified with the one with the same name in Master/2.1 and compiling?

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2018-06-05T14:03:18Z


The scalers are selected here:

m_pScaleLinear = new EngineBufferScaleLinear(m_pReadAheadManager);

@mixxxbot
Copy link
Collaborator Author

Commented by: kazakore
Date: 2018-06-05T14:08:27Z


"Ok, Soundtouch uses it's own cubic interpolation.
Rubberband uses libsamplerate by default with a sinc interpolator. SRC_SINC_FASTEST."

Happy to hear I'm wrong and they have included these use cases. So your solution sounds like it could be a good one.

@mixxxbot
Copy link
Collaborator Author

Commented by: kazakore
Date: 2018-06-05T14:21:21Z


Not managed to find the different Scalers, or not one that seems to use interpolation rather than change play_pos (probably due to not being used to the code and have zero C++ skills) but I did come across this comment:

"// When no time-stretching or pitch-shifting is needed we use our own linear
// interpolation code (EngineBufferScaleLinear). It is faster and sounds
// much better for scratching."

When talking about scratching I can fully believe that Linear will sound better than Cubic, I would ague that in this case it's very likely that Nearest Neighbour will sound even better than Linear. Scratching for digital DJs is a bit of a niche though really and I don't think a reason to lose a configurable option for modes that sounds better during normal playback....

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2018-06-05T17:49:25Z


There is also the question after group delay, that may be an issue when scratching.
I think we need to distinguish one case more in the future.

  • Scratching
  • Linear interpolation for sample rate adjusting and vinyl speed changes
  • Keylock/Keyschift

We may consider to use libsamplerate directly, to bypass the rubberband overhead when doing only interpolation.

@mixxxbot
Copy link
Collaborator Author

Commented by: kazakore
Date: 2018-06-05T20:08:26Z


DO you mean add an internal switch so that Mixxx will automatically switch between a method optimised for Scratching under certain conditions and then use the user selected mode at other times, which itself depends on whether Key Lock is active or not?

@mixxxbot
Copy link
Collaborator Author

Commented by: kazakore
Date: 2018-10-03T12:35:54Z


Have you considered trying libzita-resample? Their claims are to be faster and better quality than libsamplerate and on the whole my experience with all the Zita tools is pretty positive. Something makes me think you don't use single-precision floats in the audio engine though, so it might not be suitable at all.....

" Libzita-resampler is a C++ library for resampling audio signals. It is designed to be used within a real-time processing context, to be fast, and to provide high-quality sample rate conversion.

The library operates on signals represented in single-precision floating point format. For multichannel operation both the input and output signals are assumed to be stored as interleaved samples.

The API allows a trade-off between quality and CPU load. For the latter a range of approximately 1:6 is available. Even at the highest quality setting libzita-resampler will be faster than most similar libraries, e.g. libsamplerate. "

http://kokkinizita.linuxaudio.org/linuxaudio/zita-resampler/resampler.html

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2021-01-04T12:05:38Z


We may add a new comobox:

Vinyl-Pitch Engine: "Linear (faster) / Sinc (better)"

https://demonstrations.wolfram.com/SincInterpolationForSignalReconstruction/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant