for(i LÀ1; i > 0; iÀÀ)
{
x[i] x[iÀ1];
/* Shift old data x(nÀi)
*/
}
}
return;
}
Simulation and emulation methods are commonly used in DSP software develop-
ment. They are particularly useful for the study and analysis of DSP algorithms. By
using a software signal generator, we can produce the exact same signals repeatedly
during the debug and analysis processes. Table 5.1 lists the example of sinusoid signal
generator, signal_gen.c that is used to generate the experimental data input5.dat
for experiments in this section.
Table 5.1 List of sinusoid signal generator for the experiments
/*
signal_gen.c À Generate sinewaves as testing data in Q15 format
Prototype: void signal_gen(int *, int)
arg0: À data buffer pointer for output
arg1: À number of samples
*/
#include <math.h>
#define T 0.000125
/* 8000 Hz sampling frequency */
#define f1 800
/* 800 Hz frequency
*/
#define f2 1800
/* 1800 Hz frequency
*/
#define f3 3300
/* 3300 Hz frequency
*/
#define PI 3.1415926
#define two_pi_f1_T(2*PI*f1*T) /* 2*pi*f1/Fs
*/
#define two_pi_f2_T(2*PI*f2*T) /* 2*pi*f2/Fs
*/
#define two_pi_f3_T(2*PI*f3*T) /* 2*pi*f3/Fs
*/
#define a1 0.333
/* Magnitude for wave 1
*/
#define a2 0.333
/* Magnitude for wave 2
*/
#define a3 0.333
/* Magnitude for wave 3
*/
static unsigned int n 0;
void signal_gen(int *x, int N)
{
float temp;
int i;
for(i 0; i < N; i)
{
temp a1*cos((double)two_pi_f1_T*n);
temp a2*cos((double)two_pi_f2_T*n);
temp a3*cos((double)two_pi_f3_T*n);
226
DESIGN AND IMPLEMENTATION OF FIR FILTERS