DISCRETE FOURIER TRANSFORM DSP C Program - Computer Programming

# Computer Programming

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

## Thursday, November 10, 2011

DISCRETE FOURIER TRANSFORM
AIM
To find the Fast Fourier Transform for the realtime  samples.
HARDWARE REQUIREMENTS
TMS320C6713 DSK.
USB Cable.
Power Cord
1.      THEORY
The Transform Domain Technique involves the transformation of the time domain signal into a frequency domain one. The available methods of implementing the transformation are
·         Discrete Fourier Transform
·         Fast Fourier Transform

PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
#define PTS 64
float X[PTS];
main()
{
float xr[PTS],xi[PTS],k,n,N=PTS;
float XR[PTS],XI[PTS];
for(i=0;i<PTS-1;++)
{
xr[i]=sin(2*pi*10*i/64.0);
xi[i]=0;
}
for (k=0;k<N;k++)
{
Xr[k]=0;
Xi[k]=0;
for (n=0; <N; n++)
{
XR[k]+=(xr[n]*cos(2*pi*k*n/N))+(xi[n]*sin(2*pi*k*n/N));
XI[k]+=(xi[n]*sin(2*pi*k*n/N))-(xr[n]*cos(2*pi*k*n/N));
}

X[k]=sqrt((XR[k]*XR[k])+(XI[k]*XI[k]));
printf("%f\n",X[k]);
}