please explain how it works
-
could anyone tell me briefly how this code is working?please help me.
// nonrec_t.spc -- test program for non-recursive filter design #include "tools.h" #include "ltisys.h" #include "nonrec.h" int main() { Graph gr(3,2,"Non-Recursive Filter Design"); // calculate low-pass filter and plot LTISystem lp = NRLowPass(0.1,63); lp.a.plot(gr,1,"Low-pass at 0.1","Samples","Amp"); // calculate frequency response and plot Spectrum lpf(500,1000); for (int i=0;i<500;i++) lpf[i] = lp.response(i/1000.0); lpf.plotLogMag(gr,2,"Frequency Response"); // calculate high-pass filter and plot LTISystem hp = NRHighPass(0.4,63); hp.a.plot(gr,3,"High-pass at 0.4","Samples","Amp"); // calculate frequency response and plot Spectrum hpf(500,1000); for (int i=0;i<500;i++) hpf[i] = hp.response(i/1000.0); hpf.plotLogMag(gr,4,"Frequency Response"); // calculate band-pass filter and plot LTISystem bp = NRBandPass(0.2,0.3,63); bp.a.plot(gr,5,"Band-pass at 0.2-0.3","Samples","Amp"); // calculate frequency response and plot Spectrum bpf(500,1000); for (int i=0;i<500;i++) bpf[i] = bp.response(i/1000.0); bpf.plotLogMag(gr,6,"Frequency Response"); gr.close(); }
// kaiser_t.cpp -- test program for Kaiser window design #include "tools.h" #include "ltisys.h" #include "nonrec.h" #include "kaiser.h" const int MAXKAISERWIN=256; // maximum window length // Create non-recursive low-pass filter using Kaiser window LTISystem KaiserLowPass( double freq, // corner freq // (fraction of sampling rate) double ripple, // allowed ripple (dB) double twidth // transition width // (fraction of sampling rate) } ) // returns LTI System { int i; // get (half-)Kaiser window Waveform kwin = Kaiser(ripple,twidth,MAXKAISERWIN); int nhalf = kwin.count()-1; // generate one half of coefficients from // windowed sinc() function double omega = 2*PI*freq; for (i=0;i<=nhalf;i++) kwin[i+1] *= omega*sinc(i*omega)/PI; // copy into LT
-
could anyone tell me briefly how this code is working?please help me.
// nonrec_t.spc -- test program for non-recursive filter design #include "tools.h" #include "ltisys.h" #include "nonrec.h" int main() { Graph gr(3,2,"Non-Recursive Filter Design"); // calculate low-pass filter and plot LTISystem lp = NRLowPass(0.1,63); lp.a.plot(gr,1,"Low-pass at 0.1","Samples","Amp"); // calculate frequency response and plot Spectrum lpf(500,1000); for (int i=0;i<500;i++) lpf[i] = lp.response(i/1000.0); lpf.plotLogMag(gr,2,"Frequency Response"); // calculate high-pass filter and plot LTISystem hp = NRHighPass(0.4,63); hp.a.plot(gr,3,"High-pass at 0.4","Samples","Amp"); // calculate frequency response and plot Spectrum hpf(500,1000); for (int i=0;i<500;i++) hpf[i] = hp.response(i/1000.0); hpf.plotLogMag(gr,4,"Frequency Response"); // calculate band-pass filter and plot LTISystem bp = NRBandPass(0.2,0.3,63); bp.a.plot(gr,5,"Band-pass at 0.2-0.3","Samples","Amp"); // calculate frequency response and plot Spectrum bpf(500,1000); for (int i=0;i<500;i++) bpf[i] = bp.response(i/1000.0); bpf.plotLogMag(gr,6,"Frequency Response"); gr.close(); }
// kaiser_t.cpp -- test program for Kaiser window design #include "tools.h" #include "ltisys.h" #include "nonrec.h" #include "kaiser.h" const int MAXKAISERWIN=256; // maximum window length // Create non-recursive low-pass filter using Kaiser window LTISystem KaiserLowPass( double freq, // corner freq // (fraction of sampling rate) double ripple, // allowed ripple (dB) double twidth // transition width // (fraction of sampling rate) } ) // returns LTI System { int i; // get (half-)Kaiser window Waveform kwin = Kaiser(ripple,twidth,MAXKAISERWIN); int nhalf = kwin.count()-1; // generate one half of coefficients from // windowed sinc() function double omega = 2*PI*freq; for (i=0;i<=nhalf;i++) kwin[i+1] *= omega*sinc(i*omega)/PI; // copy into LT
Try reading the article you copied this from: http://www.phon.ucl.ac.uk/courses/spsci/dsp/lpc.html[^] If you don't understand digital signal processing, learn that first.
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
could anyone tell me briefly how this code is working?please help me.
// nonrec_t.spc -- test program for non-recursive filter design #include "tools.h" #include "ltisys.h" #include "nonrec.h" int main() { Graph gr(3,2,"Non-Recursive Filter Design"); // calculate low-pass filter and plot LTISystem lp = NRLowPass(0.1,63); lp.a.plot(gr,1,"Low-pass at 0.1","Samples","Amp"); // calculate frequency response and plot Spectrum lpf(500,1000); for (int i=0;i<500;i++) lpf[i] = lp.response(i/1000.0); lpf.plotLogMag(gr,2,"Frequency Response"); // calculate high-pass filter and plot LTISystem hp = NRHighPass(0.4,63); hp.a.plot(gr,3,"High-pass at 0.4","Samples","Amp"); // calculate frequency response and plot Spectrum hpf(500,1000); for (int i=0;i<500;i++) hpf[i] = hp.response(i/1000.0); hpf.plotLogMag(gr,4,"Frequency Response"); // calculate band-pass filter and plot LTISystem bp = NRBandPass(0.2,0.3,63); bp.a.plot(gr,5,"Band-pass at 0.2-0.3","Samples","Amp"); // calculate frequency response and plot Spectrum bpf(500,1000); for (int i=0;i<500;i++) bpf[i] = bp.response(i/1000.0); bpf.plotLogMag(gr,6,"Frequency Response"); gr.close(); }
// kaiser_t.cpp -- test program for Kaiser window design #include "tools.h" #include "ltisys.h" #include "nonrec.h" #include "kaiser.h" const int MAXKAISERWIN=256; // maximum window length // Create non-recursive low-pass filter using Kaiser window LTISystem KaiserLowPass( double freq, // corner freq // (fraction of sampling rate) double ripple, // allowed ripple (dB) double twidth // transition width // (fraction of sampling rate) } ) // returns LTI System { int i; // get (half-)Kaiser window Waveform kwin = Kaiser(ripple,twidth,MAXKAISERWIN); int nhalf = kwin.count()-1; // generate one half of coefficients from // windowed sinc() function double omega = 2*PI*freq; for (i=0;i<=nhalf;i++) kwin[i+1] *= omega*sinc(i*omega)/PI; // copy into LT
ashwiny wrote:
could anyone tell me briefly how this code is working?
Which part exactly?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne