Question
How to change the following floating pomint FFT.c into a fixed point FFT.c? fft.h is provided. fft.h: /* This function calculates the Fourier Transform of
How to change the following floating pomint FFT.c into a fixed point FFT.c? fft.h is provided.
fft.h:
/*
This function calculates the Fourier Transform of the sampled input using the Cooley-Tukey algorithm.
before this function is entered,
the static array q must be filled with the floating point values of the sampled input;
w must be a static zero filled array of size samples;
new_ and new_im must be static arrays of size samples;
the functions mult_re, mult_im, sine and cosine must be defined;
Inputs
q - the real part of the sampled input
w - zero filled array used for the imaginary part of the input
n - the number of samples
m - the power of 2 that equals n
f_sample - the sampling frequency
after the function has completed,
q will contain the real parts of the Fourier Transformed values of the input;
w will contain the imaginary parts of the Fourier Transformed values of the input;
the begining half of new_ will contain the squared magnitudes of the first half of the output;
place will contain the bin number containing the greatest squared magnitude;
max will contain the value of the largest squared magnitude;
Returns
frequency - the frequency of the input
*/
#ifndef FFT_H
#define FFT_H
#define PI 3.141592//65358979323846
float fft(float* q, float* w, int n, int m, float sample_f);
#endif
fft.c:
#include "fft.h"
#include "complex.h"
#include "trig.h"
static float new_[128];
static float new_im[128];
float fft(float* q, float* w, int n, int m, float sample_f) {
int a,b,r,d,e,c;
int k,place;
a=n/2;
b=1;
int i,j;
float real=0,imagine=0;
float max,frequency;
// ORdering algorithm
for(i=0; i<(m-1); i++){
d=0;
for (j=0; j
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started