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

Interpolation Classes #56

Closed tap closed 8 years ago

tap commented 8 years ago

In the design of interpolation classes, the class should include a query-able constant that defines the number of samples required to perform said interpolation.

This is in addition to the obvious algorithm and potential member vars.

tap commented 8 years ago

We also need to consider #43 in the implementation of the interpolation classes -- though I don't really understand the underlying concern of that issue very well. Likely need to have a conversation with @nwolek to iron this out.

tap commented 8 years ago

Hi Nathan -- I did the initial port from Jamoma1 (see commit above). A couple of the interpolation types are not currently tested. Also I didn't scrutinize the comments and it could use review as well.

In Jamoma1 these were implemented as templated functions. For Jamoma2 I have implemented them as templated classes.

Because classes have the function operator defined, they can be called as functions. However, they can also have state now (see the Hermite interpolation) and you pass instances of the interpolation around. Also, since it is a class, you can also use it's type to specialize template -- which I've demonstrated in the unit tests.

nwolek commented 8 years ago

OK, thanks Tim. I was trying to make some progress on #35 today, but will give this an initial look today too. I feel like both are going to be necessary for #41 where I need a modulating allpass filter.

nwolek commented 8 years ago

Looked at these again today. It took me a while to figure out how the test was working because of the template function and such. I am not sure we want our tests to be so obtuse. I am going to work toward simplification so that the code is more readable. That might mean violating the DRY principle in testing, but it will help the code serve as examples for others.

nwolek commented 8 years ago

Bookmarking these. Likely source of my targets for testing:

https://www.gnu.org/software/octave/doc/interpreter/One_002ddimensional-Interpolation.html

nwolek commented 8 years ago

Tests show pretty definitively that our algorithms for Hermite and Spline are not producing the same results as those from the similar named options for the Octave interp1 function. I will need to some more research on the source of these algorithms.

I found a few hits here: http://musicdsp.org/archive.php?classid=5

@tap did you have a common source for these interpolation algorithms initially?

tap commented 8 years ago

If you export code from gen~ and then look at the exported code I think you will find something comparable.

best, Tim

On Wed, Dec 2, 2015 at 11:02 AM, Nathan Wolek notifications@github.com wrote:

Tests show pretty definitively that our algorithms for Hermite and Spline are not producing the same results as those from the similar named options for the Octave interp1 function. I will need to some more research on the source of these algorithms.

I found a few hits here: http://musicdsp.org/archive.php?classid=5

@tap https://github.com/tap did you have a common source for these interpolation algorithms initially?

— Reply to this email directly or view it on GitHub https://github.com/jamoma/jamoma2/issues/56#issuecomment-161365167.

nwolek commented 8 years ago

Found examples for linear, cosine, cubic, spline and hermite in the gen~.interpolation example. Working to migrate into Octave.

nwolek commented 8 years ago

Some simple explanations and code examples for interpolation methods here.

Two observations from today's testing: 1) Our cubic and spline algorithms produce identical output. Looking at the code shows why. I plan to fix this. 2) Setting the bias and tension settings both to zero results in identical output from spline and hermite. This should be documented.

tap commented 8 years ago

Thanks for all your work on this Nathan! It's great that we are applying this level of rigor to the stuff we bring over from Jamoma1. In the process we are definitively improving things!

That's a great interpolation article too -- thanks for including it here!

nwolek commented 8 years ago

Thanks Tim! I am glad you appreciate the work that went into this code review. I have merged it back into master now, and am calling this issue done. Feel free to re-open if you think I missed something.