Page 1 of 1

cubic interpolation sophisticated example

Posted: Fri Sep 19, 2014 1:13 pm
by tulamide
interpolation_example.jpg
interpolation_example.jpg (133.46 KiB) Viewed 17292 times


Just as promised, here's a schematic that makes use of cubic interpolation (see http://www.dsprobotics.com/support/viewtopic.php?f=3&t=2769) in various ways:

    - cubic spline module renders it visible
    - wavetable synth renders it audible
    - cubic colored dBFS uses it to colorize in 2 different ways

The schematic is saved with volume set to zero. So make sure to turn on the volume in order to hear the synth. Things to meantion:

    - The spline module is completely size-independent. No matter the size of the view, the left and top edge represents -1, the right and bottom edge represents +1, the center represents 0
    - The spline itself is rendered with a resolution of 512 in order to have enough samples for a detailed waveform. You can change the resolution to any value you like, as long as it is equal to or greater than 4. To change it look into the module "cubic properties"
    - For this demo, it's only a one-segment spline. Extending it would be done by creating another segment in a way that the end-point of the previous segment is the same as the start point of the current one, and the end point of the current one equal to the start point of the next segment, etc.
    - The synth is just a very simple one, it shows the x-values, y-values and the multiplied values as seperate wavetables. When playing a note, all three wavetables are used to build the sound.
    - Note that no matter how short or long the spline is, you'll always get resolution amount of values. This behaviour could be changed to get more interesting wavetables, but for this example you have to live with it ;)
    - the level meter shows two peak bars. The first one picks the current interpolated color and draws it over its area, while the second one renders a gradient of the interpolated colors up until the current peak point.
    - Keep in mind that it's just an example, so no optimizations are done. You could speed it up a lot.
    - Thanks to those involved in solving the trigger switch issue: billv, tester and perfect.

Have fun exploring it! :?: :o :idea: :!:
:mrgreen:

Re: cubic interpolation sophisticated example

Posted: Fri Sep 19, 2014 7:40 pm
by Exo
Really great stuff thanks for sharing :)

Might be interesting to use that as a waveshaper too.

Re: cubic interpolation sophisticated example

Posted: Sat Sep 20, 2014 12:41 am
by tulamide
Exo wrote:Really great stuff thanks for sharing :)

Might be interesting to use that as a waveshaper too.

Indeed!
You can use it for pretty much everything, that's so great about it. In case you want to give it a try for whatever you're thinking of, here's a dsp version of all three interpolation methods (linear, quadratic and cubic).

interpolation_dsp.jpg
interpolation_dsp.jpg (140.02 KiB) Viewed 17255 times


Just remember, whatever you feed it with, it interpolates from a (t-value = 0) to d (t-value = 1), over b and c. So t-value = 0.5 means, all 4 inputs are present with all the same shares.

Would love to see something made from it :)

Re: cubic interpolation sophisticated example

Posted: Sat Sep 20, 2014 2:24 pm
by tulamide
And here is an animated gif I found on wikipedia, that visualizes perfectly what the cubic modules calculate:

Image

Re: cubic interpolation sophisticated example

Posted: Sat Sep 20, 2014 3:54 pm
by Exo
Cool!

I will try and knock together a quick waveshaper tomorrow if I get time.