Home Page or Table of Contents

## A Scrapbook of Digital Signal Processing

### Quick Frequency-Domain Window

Windowing in the time domain can be either computationally intensive if the window is generated during the computation or storage intensive if the window is pre-generated before computation. A simple, but effective frequency-domain window uses a 3-point sliding function equal to [-1/2, 1, -1/2]. Sample C code looks as follows, where a and b are the real and imaginary parts of the voltage spectrum and n is the size of the frequency-domain array:

void window(float a, float b, int n)
{
a_old=a[0]-a[1];
b_old=b[0]-b[1];
for(i=1; i lt n-1; i++)
{ a_new=-a[i-1]/2+a[i]-a[i+1]/2;
b_new=-b[i-1]/2+b[i]-b[i+1]/2;
a[i-1]=a_old;
b[i-1]=b_old;
a_old=a_new;
b_old=b_new;
}
a[n-1]=a[n-2]-a[n-1];
b[n-1]=b[n-2]-b[n-1];
}

When implemented using integer arithmeic in machine code, the divide-by-two functions can be implemented as binary shifts, requiring no multiplies.

Home Page or Table of Contents