jamoma / jamoma2

A header-only C++ library for building dynamic and reflexive systems with an emphasis on audio and media.
MIT License
30 stars 6 forks source link

Factor interpolation out of `Delay` and `InterpolatingDelay` #60

Open tap opened 8 years ago

tap commented 8 years ago

Passing in the Interpolation implementation as template argument.

nwolek commented 8 years ago

With work on issue #56 done, it's time to work on this.

nwolek commented 8 years ago

These last three commits were super easy because of the tests in place. Good example of how testing benefits development.

Looking to @tap for guidance/input for other design work needed here. We still have separate Delay v DelayWithLinearInterpolation classes. I assume we would like one with the interpolation type as an option, right?

If so, we will need to reconcile the different number of samples require for individual interpolation types. Linear and Cosine require 2 samples, so it is possible for them to achieve zero sample delays. Cubic, Spline, and Hermite require 4 samples and will therefore create a minimum delay of one sample.

Maybe this is a situation where too many options is just a distraction? YAGNI?

nwolek commented 8 years ago

Reading some of Julius Smith on the topic. He mentions only linear and allpass methods while covering Delay-Line Interpolation.

Allpass would be another option that only requires 2 samples. I am going to create another issue to implement this.

tap commented 8 years ago

Cubic interpolation is quite important. A few familiar examples include the tapout~ and play~ objects in Max and tabread4 in Pd.

If you listen to the output of the wave~ object in Max and switch the @interp attribute you will hear a (in some cases tremendous) difference in sound quality.

nwolek commented 8 years ago

Did not mean to suggest that we did not need interpolation! I was just pondering whether some types are better suited for delay-lines versus wavetables. And if that is the case, pouring effort into implementation of a variable type interpolation may not be the best allocation of efforts at the moment.

Guess we need to clarify what is necessary to close this issue.

tap commented 8 years ago

"Discussion of delay accuracy with cubic interpolation":http://msp.ucsd.edu/techniques/v0.11/book-html/node114.html

"Linear and Allpass Interpolation @ McGill":http://www.music.mcgill.ca/~gary/618/week1/delayline.html

"PDF on Interpolation":http://home.deib.polimi.it/bestagini/_Slides/lesson_3.pdf -- might be able to step back from this and think not only of cubic interpolation on it's own, but Nth-order interpolation for which cubic is simply one case.

Also, here are "the delay implementations from SuperCollider":https://github.com/supercollider/supercollider/blob/master/server/plugins/DelayUGens.cpp, FWIW.