Help with interpolation


#1

Hello everyone, i feel i'm stumbling over a pebble and i might need some advice.

I'm making a mandelbrot inspired oscillator (basically it iterates over the fundamental equation z' = z^2 + c and outputs the result).

I also found a way to make it tuned (iterating with a certain frequency). To do this i just copied the osc/phasor code and tweaked it to my needs. With this implementation the result looks like a wavetable fed into a sample/hold module (or maybe table/read with no interpolation and a low number of samples).

Similarly with table/read objects, i'd like to implement some way to interpolate between two consecutive values (and this should be easy, since i already have a phasor that drives the pitch)
See the image for some reference

i tried to write some code, but it just does not work like i want, no matter how much tweaking i do (here you have it:)

Phase = uint32_t
phase_t = int32_t 
re, im ,re_interp, im_interp = int32_t

int32_t phase_t=Phase>>6; // make the phase variable signed int (so i can use it inside SMMUL) - Also, i'm making it smaller
outlet_Re=(___SMMUL((re>>1)-(re_interp>>1),phase_t)) +(re_interp)<<5;
outlet_Im=(___SMMUL((im>>1)-(im_interp>>1),phase_t)) +(im_interp)<<5;

If you feel it you can try the object here: test_fractal.axp (11.7 KB)

Any advice on how to fix this?


#2

Couldn't you just apply a small amount of lag/slew? Or low-pass filter it.
Amounts to the same thing, I think.

a|x


#3

Slew is definitely not what i need. A filter might be a solution, but what i want to do is interpolate between samples (Which does not sound like a filter, take for example a filtered square wave and a triangle, they sound vaguely similar but not the same)

Also i want everything inside one object.


#4

I'm a DSP noob, so yes, probably silly suggestions, sorry.

a|x


#5

You should be able to use a bit of bit-shifting to calculate the current position between two fixed points, and the relative distances to them, then interpolate between the values at those points.

If you evaluate the value at the next point every time you reach a new point and store that in a variable, that should be all you need, provided you keep moving in the same direction.

a|x


#6

Well, that was the idea: the relative distance is calculated with re - re_interp (new value - old value), and this number is multiplied by the phasor.
Add this to the old value and (at least in theory) i should obtain a linear interpolation. It does not work, however.