-
Notifications
You must be signed in to change notification settings - Fork 9
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
Consider pluggable interpolation #12
Comments
I did an extended test of higher-order polynomial interpolation. I tested some polynominals proposed by Olli Niemitalo in "Polynomial Interpolators for High-Quality Resampling of Oversampled Audio". In general polynomial interpolation can't compete with polyphase based solutions like SOX. But we can do better than the current linear interpolation. The polynomials I experimented with always had tradeoffs in compute complexity, distortion or attenuation in higher frequencies, meaning that for example 4th order b-splines had very good intermodular distortion, but attenuated higher frequences very aggresively. A replacement or alternative for the linear interpolation should not be worse in either distortion or in attenuation of higher frequences. Only a higher compute complexity should be acceptable. I don't have access to the Audio Precision software suite (the "standard"), so I used Right Mark Audio to compare the resampling quality when resampling a 44.1 kHz test sound to 48 kHz. I included SOX in the test as the "gold standard" to beat. "Linear" is the current linear interpolation. We can clearly see that Lagrange 4p and 6p would be an upgrade to the linear filter. For example the THD: The frequency response is better than linear, but we still attenuate before reaching 20 kHz. There is also no low pass filter: The IMD sweep test is also better, but still not great. The curves look awfully similar for all polynomial interpolations, so this is maybe an artifact of geometric interpolation. I did a quick benchmark comparing the runtime of Linear: Lagrange 4 point: Lagrange 6 point: I created a branch with the test code and the Lagrange 6 point interpolation: |
Thanks for this investigation! Sounds like the perf impact is significant, but not exactly debilitating considering the low absolute cost. I think there's a good case for moving ahead with a pluggable interpolator, though I'm not immediately certain what the trait should look like. If only associated constants worked in array lengths...
How does this compare to cubic (or is it a synonym?) |
As far as I understand, "cubic" interpolation is called every interpolation that is using third-degree polynomial to interpolate. Olli Niemitalo says in the paper, that linear and cubic interpolations are all piece-wise polynomial interpolators. He than compares different polynomial interpolators in the paper and Lagrange is one of the polynomial that he uses. 4p uses four points and is a third-degree polynomial. 6p uses five points and is a four-degree polynomial. More common cubic interpolators use the cubic Hermite interpolator and / or it's special case the Catmull–Rom spline. It has to be said that the paper analyses the usage of those interpolators on oversamples data (using a FIR filter). |
Resampling in
stream::Receiver
andSamplesSource
is currently hardcoded to use linear interpolation. Higher quality might be obtained by using higher-order polynomial interpolation, at a latency and CPU time cost. It's unclear if the quality difference would be meaningful.The text was updated successfully, but these errors were encountered: