/********************************************************************** * Demonstration of a bandpass numerical filter using Module filter_r * * ------------------------------------------------------------------- * * SAMPLE RUN: * * Input file 'input.txt' contains: * * * * Input Signal * * 200 * * 0.00000000000000E+0000 0.00000000000000E+0000 * * 2.51256700736135E-0003 1.40504705905914E+0000 * * 5.02513401472271E-0003 1.39680230617523E+0000 * * 7.53770102208762E-0003 3.99903088808060E-0001 * * 1.00502680294454E-0002 0.00000000000000E+0000 * * 1.25628350368032E-0002 7.07106769084930E-0001 * * 1.50754020441752E-0002 1.26007354259491E+0000 * * 1.75879690515330E-0002 4.31350797414780E-0001 * * 2.01005360588908E-0002 -1.17557048797607E+0000 * * --/-- * * 4.77387731398721E-0001 1.00000000000000E+0000 * * 4.79900298405937E-0001 1.84206306934357E+0000 * * 4.82412865413608E-0001 1.17557048797607E+0000 * * 4.84925432420823E-0001 -4.31350797414780E-0001 * * 4.87437999428039E-0001 -1.26007354259491E+0000 * * 4.89950566435709E-0001 -7.07106769084930E-0001 * * 4.92463133442925E-0001 1.78893358460108E-0018 * * 4.94975700450141E-0001 -3.99903088808060E-0001 * * 4.97488267457811E-0001 -1.39680230617523E+0000 * * 5.00000834465027E-0001 -1.40504705905914E+0000 * * * * Output file 'output.txt' contains (lowpass - Fc=60): * * * * Filtered Signal (lowpass) * * 200 * * 0.000000 0.000000 * * 0.002513 0.123316 * * 0.005025 0.430956 * * 0.007538 0.637626 * * 0.010050 0.575908 * * 0.012563 0.480040 * * --/-- * * 0.487439 0.387428 * * 0.489952 -0.018459 * * 0.492464 -0.186481 * * 0.494977 -0.193248 * * 0.497489 -0.317190 * * 0.500002 -0.591049 * * * * Output file 'output1.txt' contains (highpass - Fc=60): * * * * Filtered Signal (highpass) * * 200 * * 0.000000 0.134854 * * 0.002513 -0.020172 * * 0.005025 -0.467873 * * 0.007538 -0.571431 * * 0.010050 -0.153637 * * 0.012563 0.212561 * * --/-- * * 0.489952 0.367969 * * 0.487439 -0.048799 * * 0.492464 0.229072 * * 0.494977 -0.204981 * * 0.497489 -0.270452 * * 0.500002 0.168433 * * ------------------------------------------------------------------- * * References: * * * * http://en.wikipedia.org/wiki/Digital_biquad_filter * * http://www.musicdsp.org/archive.php?classid=3#225 * * http://www.musicdsp.org/showone.php?id=197 * * http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt * * http://www.musicdsp.org/archive.php?classid=3#225 * * http://www.musicdsp.org/showArchiveComment.php?ArchiveID=225 * * * * Visual C++ Release By J-P Moreau, Paris. * * (www.jpmoreau.fr) * *********************************************************************** Note: Here, only the lowpass and highpass options are demonstrated. ------------------------------------------------------------------ */ // *** To link with files basis_r.cpp, vmblock.cpp and filter_r.cpp. #include "filter_r.h" FILE *fp1, *fp2; TRbjEqFilter lRGJFilter; // see module filter_r.cpp int i; float *lIn; // input table of float char title[80]; // caption int kSamples; // number of points float kSamplesPerSec; // sample rate float t,ti,tf,dt; // t = current time, ti = starting time // tf = ending time, dt = time increment float Fc; // cut-off frequency void *vmblock; // see file vmblock.h void main() { fp1 = fopen("input.txt","read"); fscanf(fp1,"%s", title); fscanf(fp1,"%d", &kSamples); // Allocate memory for vectors lIn and lOut vmblock = vminit(); lIn = (float *) vmalloc(vmblock, VEKTOR, kSamples, 0); fscanf(fp1,"%f %f", &ti, &lIn[0]); for (i=1; i