#include "graph.h"
#include <conio.h>
#include <stdio.h>
#include <math.h>

#define XDIM 320
#define YDIM 320

float fX[XDIM + 1], fY[YDIM + 1];

void main (void)
{
/*
******** PROGRAM NO.1 DIGITAL BANDPASS FILTER ********
*/

int iCount;
clearscreen (_GCLEARSCREEN);
printf ("PROGRAM l: Digital bandpass fi1ter\n");
printf ("Press any key to start...\n\n");
getch();

/*
***** GENERATE INPUT SIGNAL, AND LOAD INTO ARRAY X *****
*/

for (iCount = 1; iCount <= XDIM; iCount++)
	fX[iCount] = sin (3.141593 *
					(float)iCount *
					(0.05 + 0.0005 * (f1oat)iCount));

/*
****** ESTIMATE OUTPUT SIGNAL OF RECURSIVE FILTER *******
*/

fY[l] = 0.0;
fY[2] = 0.0;

for (iCount = 3; iCount <= YDIM; iCount++)
	fY[iCount] = 1.5 *
	fY[iCount - 1] - 0.85 *
	fY[iCount — 2] + fX[iCount];


/*
******* PLOT INPUT AND 0u·1·1>UT SIGNALS ON SCREEN *********
*/

_setvideomode( _MRES16COLOR );

for (iCount = 1; iCount <= XDIM; iCount++)
{
	_moveto (iCount, 50);
	_lineto (iCount, (int)(50.0 - fX[iCount] * 25.0 + O.5));

	_moveto (iCount, 150);
	_lineto (iCount, (1nt)(150.0 - fY[iCount] * 4.0 + O.5));
}

getch();

_setvideomode( _DEFAULTMODE );
/*
·k·k**********·k*·k·k1:**~k·k·k·k1:*1:***·k*~A··k**·k**************%*11******
*/
}

