SynthMaker

3th order interpolated delay updated

Archive · 2006 15 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

luisi ·

3th order interpolated delay, good for effects and physical modelling, enjoy

updated: thanks to sambean and ROMplERbuDE for the fixes to the script

//3th order interpolated Fractional Delay copyleft by nusofting.com streamin in; streamout out; streamin delay;

float index; float intdelay,frac; float temp1,temp2,temp3,temp4,xm1,x0,x1,x2,a,b,c;

float mem[44101]; float MAXDELAY=44101; float mask=44100;

stage(1) { intdelay = delay - 0.499998; intdelay = rndint(intdelay); frac = delay - intdelay;

temp1 = index - intdelay; temp2 = temp1 + 1; temp3 = temp1 - 1; temp4 = temp1 - 2;

temp1 = temp1 + (temp1 < 0)&mask; temp2 = temp2 + (temp2 < 0)&mask; temp3 = temp3 + (temp3 < 0)&mask; temp4 = temp4 + (temp4 < 0)&mask;

xm1 = mem[temp2]; x0 = mem[temp1]; x1 = mem[temp3]; x2 = mem[temp4]; a = (3 * (x0 - x1) - xm1 + x2) / 2; b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; c = (x1 - xm1) / 2;

out = (((a * frac) + b) * frac + c) * frac + x0;

index = index + 1; // Start the buffer first index = (index < MAXDELAY) & index; mem[index] = in; // then record into the buffer , but in physical modelling may be better to record as first, to check this

}

sambean ·

Hey Luisi,

Thanks for sharing! I think there may be a slight flaw in the implementation though.. If you hook it up to an analyser with 10 or so samples analysed, feed an impulse for input, and control the delay with a knob in the range 0-10, you'll see that the impulse does not move 'smoothly' from one sample to the next..

I think this section should be:

temp1 = index - intdelay; temp2 = temp1 + 1; temp3 = temp1 - 1; temp4 = temp1 - 2;

Also setting delay to zero, you get no output, you should write to the table first, then read to solve this...

If you're interested here's my own fractional delay using allpass filters:

stage(1) { mem[index]=in;

intdelay = delay - 0.499999; intdelay = rndint(intdelay); frac = delay - intdelay;

temp1 = index - intdelay; temp2 = temp1 - 1;

temp1 = temp1 + (temp1 < 0)&MAXDELAY; temp1 = mem[temp1];

temp2 = temp2 + (temp2 < 0)&MAXDELAY; temp2 = mem[temp2];

frac = (1 - frac)/(1 + frac); out = temp2 + frac * (temp1 - out1); out1 = out;

index=index+1; index=(index<MAXDELAY)&index; }

Cheers

Sam

luisi ·

I think this section should be:

temp1 = index - intdelay; temp2 = temp1 + 1; temp3 = temp1 - 1; temp4 = temp1 - 2;

I didn't try that but I think that you could be right since in my C code I scan the buffer in reversed mode where in the SM code I don't,

thanks for pointing that!

thanks also for your delay with allpass filters, I've found it in the examples, <wink>

about the delay to zero, if you write to the table first your delay is delay lenght + 1 sample always, wrong?

ROMplERbuDE ·

Hy, //del

//del

I has made an (4Point) example that has fixup that .... It is not the best but it works for delay modulation (flanger with < 10 & > 600 smpls).

[old link]

infuzion ·

neat little flange ROMplERbuDE, thanks!

ROMplERbuDE ·

Yeah thank you infuzion for Feedback...

luisi ·

Hi ROMplERbuDE,

many thank for for your nice 4P delay!

may you please tell me more about the usage of stage(2) and stage (4), why you chose that?

ROMplERbuDE ·

Hy luisi, No probs i will share more ideas. stage(4) ???? I never heard before..... stage(2,3) delays a signal by one samp I think. The once info that I have seen is @: [old link]

luisi ·

ROMplERbuDE wrote: Hy luisi, No probs i will share more ideas. stage(4) ???? I never heard before..... stage(2,3) delays a signal by one samp I think. The once info that I have seen is @: [old link]

yes 2 and 3, but still I don't get why you used them, <grin>

ROMplERbuDE ·

I have tried to reduce clicks by less delay times <4smpls... 🙂

luisi ·

ROMplERbuDE wrote: I have tried to reduce clicks by less delay times <4smpls... 🙂

ah, thanks, <grin>

sambean ·

Stages 1,2 and 3 all get calculated in the same sample period but in that order. So calculation is all stage 1 then all stage 2 then all stage 3, if you get my drift..

The reason for the different stages is to make sure that schematics with delays and feedback are calculated correctly.. I'm not sure of the exact details but I think it should be as follows:

stage 1 calculate all schematic 'maths' stage 2 calculate all delay outputs stage 3 calculate all delay inputs

When you have a feedback path, this will stop ambiguities in the order of the calculation.

Here's a link to a topic which illustrates why there are stages 2&3 with an explanation by Jorge..

[old link]

Excuse my ignorance half way through the discussion 😊

Sam

ROMplERbuDE ·

Hy Sam, thanks for the info.

Did you mean for a smpl. feedback that first the signal goes in stage(3) then calculate in (1) then go out in (2)?

jorge ·

Stages are just a way of grouping compiled code. For example if you have 2 code components let's say CCA and CCB and you use stages 1 2 and 3 on both, the resulting compiled code will be the following:

CCA stage 1 CCB stage 1 CCA stage 2 CCB stage 2 CCA stage 3 CCB stage 3

In most cases only stage 1 is needed. When you're using delays to create digital filters, in order to avoid different results depending on the order that you insert the components, stage 1 can be used to do all the calculations and stages 2 and 3 to move data in and out of the internal memory of the delays. That's the only reason I've needed stage 2 and 3 so far and the reason they were implemented although there might be other uses for them.

ROMplERbuDE ·

Ok, Thank you jorge. I will understand it now!

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.