Delay - shorter than one sample ?

DSP related issues, mathematics, processing and techniques
Post Reply
Rocko
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Delay - shorter than one sample ?

Post by Rocko »

Hi,

Playing around with very short delays and came up with an intrguing question.
At 48KHz sample rate, a single sample time span is (1/48,000 sec) = 20.833 uSec [micro seconds].

So, using the stock DELAY module, I can add a single delay of 20.833 uSec and next step would be 41.667 (2x20.833).
But, what if I needed a delay of 30 uSec, just between these two values. Is this possible? Can I delay a signal by 1.5 samples or does it have to be an integer?

Is there some kind of technique to achieve such a thing?

Thanks,
Rocko
Last edited by Rocko on Wed Feb 22, 2017 10:31 am, edited 1 time in total.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Delay - shorter than one sample ?

Post by martinvicanek »

There is a thing called fractional delay which does what you describe. It uses some sort of interpolation to produce intersample values. The simplest interpolation would be linear, but there are more sophisticated ones. It depends on your application which one is appropriate.
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Delay - shorter than one sample ?

Post by Spogg »

martinvicanek wrote:There is a thing called fractional delay which does what you describe. It uses some sort of interpolation to produce intersample values. The simplest interpolation would be linear, but there are more sophisticated ones. It depends on your application which one is appropriate.


Since Flowstone processes the stream elements just once per sample period how could the fractional thing work?

I expect some sort of Martinmagic to follow...

Cheers

Spogg
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Delay - shorter than one sample ?

Post by tulamide »

Wouldn't it be easier to use latency to be ahead of time and then do your work on fractions after they have happened?
"There lies the dog buried" (German saying translated literally)
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Delay - shorter than one sample ?

Post by martinvicanek »

Tulamide, you are right, of course processing can only be on samples in the past, including the current sample. (Maybe we should put a time travel prim on the wishlist :lol:)

No magic, seek for "Interpolated Delay" in your toolbox and you shall find:

Code: Select all

streamin in;
streamout out;
streamin delay;

float index;
float intdelay,frac;
float temp1,temp2;
float out1;

float mem[44100];
float MAXDELAY=44100;

stage(2)
{
   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];

   out =  temp1 + frac * (temp2 - temp1);
   out1 = out;
   
   index=index+1;
   index=(index<MAXDELAY)&index;
}


Basically you take a weighted average as the value between two samples (linear interpolation).
User avatar
mHz
Posts: 19
Joined: Sun Sep 05, 2010 6:01 pm
Location: Eindhoven, Nederland

Re: Delay - shorter than one sample ?

Post by mHz »

Eventually in the spectrum the comb filter effect is similar to just a low- or highpass filter.
So interpolating it really helps.
Rocko
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: Delay - shorter than one sample ?

Post by Rocko »

Hi,

Thanks.

any idea why I couldn't find the 'interpolated delay' prim in my toolbox?
Using FlowStone 3.0.8.1 ...

Thanks,
Rocko
User avatar
nix
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Delay - shorter than one sample ?

Post by nix »

Have you got the audio pack and the dsp pack?
Here is the delay->
interpolated delay.fsm
(2.07 KiB) Downloaded 1544 times
Post Reply