Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. please explain how it works

please explain how it works

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasedesigndata-structurestools
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashwiny
    wrote on last edited by
    #1

    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

    J D 2 Replies Last reply
    0
    • A ashwiny

      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

      J Offline
      J Offline
      Joe Woodbury
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A ashwiny

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups