Ultimately everything you need to know was in my first post to this thread. If you're unable to conceptualize and/or visualize what is going on it is no surprise you won't be able to get it to work correctly. You need to understand 100% of the problem before you can attempt to solve it, let alone write an algorithm to solve every possible variation of the problem.

If the triangle is 0 to 1 in 1/2 cycle it means the delta is 2 for the first half, then switches to -2. That sudden switch to -2 must be filtered.

You'll need to ensure your impulses have identical latency (often by delaying the first order to make up for higher order latencies) or you'll need to mix them into distinct buffers and apply delay lines to line them up correctly.

So at each "point" / "vector" in the waveform you need:

- Code: Select all
`// the event happened "age" samples ago`

age = (phase - step.phase) / phase_delta;

delta[1] = step.y - last.y;

if (delta[1] != 0) {

amplitude = delta[1];

insert(amplitude, age, impulses.order[1]);

}

delta[2] = (step.y_delta - last.y_delta) * pow(phase_delta, 1);

if (delta[2] != 0) {

amplitude = delta[2];

insert(amplitude, age, impulses.order[2]);

}

Obviously you can do this in a loop:

for (order = 0; order < max_order; order++) { ... }

You'll also need to ensure you normalize your impulses correctly or apply re-normalization to the amplitude factor upon insertion.

The code I've posted here is to get you thinking about the problem: it won't work. The event you're interpolating is always at an arbitrary position. For example during a sync event you're filtering the difference between the source phase and target phase parameters. This is always the case because during a sample period you'll never move exactly one step in your table of vector points. (Although it can happen by chance: that corner-case will lead to a division by zero and needs to be handled.)