commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11615 - gnuradio/branches/developers/n4hy/pfb_iir/gnu


From: n4hy
Subject: [Commit-gnuradio] r11615 - gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general
Date: Wed, 19 Aug 2009 20:06:57 -0600 (MDT)

Author: n4hy
Date: 2009-08-19 20:06:56 -0600 (Wed, 19 Aug 2009)
New Revision: 11615

Added:
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.i
Modified:
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/Makefile.am
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/general.i
Log:
working with iir in latest trunk

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/Makefile.am
 2009-08-20 02:02:33 UTC (rev 11614)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/Makefile.am
 2009-08-20 02:06:56 UTC (rev 11615)
@@ -86,6 +86,7 @@
        gr_glfsr_source_b.cc            \
        gr_glfsr_source_f.cc            \
        gr_head.cc                      \
+       gr_iirdes.cc                    \
        gr_interleave.cc                \
        gr_interleaved_short_to_complex.cc \
        gr_iqcomp_cc.cc                 \
@@ -240,6 +241,7 @@
        gr_glfsr_source_b.h             \
        gr_glfsr_source_f.h             \
        gr_head.h                       \
+       gr_iirdes.h                     \
        gr_interleave.h                 \
        gr_interleaved_short_to_complex.h \
        gr_iqcomp_cc.h                  \
@@ -403,6 +405,7 @@
        gr_glfsr_source_b.i             \
        gr_glfsr_source_f.i             \
        gr_head.i                       \
+       gr_iirdes.i                     \
        gr_interleave.i                 \
        gr_interleaved_short_to_complex.i \
        gr_iqcomp_cc.i                  \

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/general.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/general.i
   2009-08-20 02:02:33 UTC (rev 11614)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/general.i
   2009-08-20 02:06:56 UTC (rev 11615)
@@ -54,6 +54,7 @@
 #include <gr_complex_to_interleaved_short.h>
 #include <gr_interleaved_short_to_complex.h>
 #include <gr_endianness.h>
+#include <gr_iirdes.h>
 #include <gr_firdes.h>
 #include <gr_interleave.h>
 #include <gr_deinterleave.h>
@@ -174,6 +175,7 @@
 %include "gr_complex_to_interleaved_short.i"
 %include "gr_endianness.i"
 %include "gr_interleaved_short_to_complex.i"
+%include "gr_iirdes.i"
 %include "gr_firdes.i"
 %include "gr_interleave.i"
 %include "gr_deinterleave.i"

Added: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
                                (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
        2009-08-20 02:06:56 UTC (rev 11615)
@@ -0,0 +1,470 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Derived from Octave functions butterord, butter, chebord1, chebord2,
+ * cheby1, cheby2, ellipord, ellip, freqz, sos2tf, sos2zp, tf2sos,zp2sos,
+ * These functions are, primarily, copyright Julius O. Smith III and
+ * Paul Kienzle.
+ * The octave files used for the derivation are released under GPL v2.
+ */
+
+#include <gr_iirdes.h>
+#include <stdexcept>
+#include <malloc.h>
+
+using std::vector;
+
+#define IIReps 2.2e-14 /* threshold for zero or integer taken from Octave
+                         iir filter design (JOS) */
+
+
+
+vector<double>
+gr_iirdes::iirdes(gr_iirdes::filter_design_type fdtype,
+                 vector<double> Wpassband,
+                 vector<double> Wstopband,
+                 double RipplePassband,
+                 double RippleStopband)
+{
+  int frqsize = Wpassband.size();
+  gr_iirdes::filter_response d_filter_response;
+  bool error = true;
+  double Rp = RipplePassband;
+  double Rs = RippleStopband;
+  vector<double> Wc_n;
+
+  if (Wpassband.size() != Wstopband.size()|| (frqsize <1) || (frqsize>2))
+    throw std::invalid_argument ("size of Wpassband and Wstopband must be 
equal and 1 or 2\n");
+
+  
+  if (frqsize == 1) {
+    // is it high pass or lowpass? 
+    if (Wpassband[1] < Wstopband[1] && (Wstopband[1]<= 0.5))
+      d_filter_response = LOWPASS, error=false; //We are a low pass filter 
request
+
+    else if (Wstopband[1] < Wpassband[1])
+      d_filter_response = HIGHPASS, error=false; //We are a high pass filter 
request
+    else 
+      throw std::invalid_argument ("passband frequencies must be distinct from 
stopband frequencies and <= 0.5\n");
+  } else {
+
+    // freq vectors are 2 long
+    // is it bandpass or bandstop ?
+    if ((Wstopband[1]<Wpassband[1]) &&
+       (Wpassband[1]<Wpassband[2]) &&
+       (Wpassband[2]<Wstopband[2]) &&
+       (Wstopband[2] <= 0.5))
+      // We are a bandpass filter request
+      d_filter_response = BANDPASS,error=false,Wc_n.resize(3);
+    else 
+      if ((Wpassband[1]<Wstopband[1]) &&
+         (Wstopband[1]<Wstopband[2]) &&
+         (Wstopband[2]<Wpassband[2]) &&
+         (Wpassband[2] <= 0.5))
+        // We are a bandstop filter request
+       d_filter_response = BANDSTOP,error=false,Wc_n.resize(3);
+      else throw std::invalid_argument ("For bandpass, stop band surround 
passband frequencies,\n For bandstop, passband freqs surround stopband,\n and 
in both cases, highest frequency is <= 0.5\n");
+  }
+  if (error) throw std::invalid_argument ("Wpassband or Wstopband out of range 
or out of order");
+
+  switch (fdtype) {
+  case BUTTER: {
+    Wc_n=butterord(d_filter_response,Wpassband,Wstopband,Rp,Rs);
+    return butter_tf(d_filter_response,Wc_n);
+  }
+  case CHEBYSHEV: {
+    Wc_n=chebyshevord(d_filter_response,Wpassband,Wstopband,Rp,Rs);
+    return chebyshev_tf(d_filter_response,Wc_n);
+  }
+  case INVCHEBYSHEV:{
+    Wc_n=invchebyshevord(d_filter_response,Wpassband,Wstopband,Rp,Rs);
+    return invchebyshev_tf(d_filter_response,Wc_n);
+  }
+  case ELLIPTICAL:{
+    Wc_n=ellipord(d_filter_response,Wpassband,Wstopband,Rp,Rs);
+    return ellip_tf(d_filter_response,Wc_n);
+  }
+  case BESSEL:{
+    Wc_n= besselord(d_filter_response,Wpassband,Wstopband,Rp,Rs);
+    return bessel_tf(d_filter_response,Wc_n);
+  }
+  default:
+    throw std::out_of_range ("Allowable filter types are BUTTER(0), 
CHEBYSHEV(1), INVCHEBYSHEV(2), ELLIPTICAL(3), BESSEL(4)");
+  }
+
+}
+
+vector<double>
+gr_iirdes::butterord(gr_iirdes::filter_response fresp,
+         vector<double> Wp,
+         vector<double> Ws,
+         double Rp,
+         double Rs)
+{
+  double  qs = log(pow(10.,(Rs/10.0)) - 1.0);
+  double  qp = log(pow(10.,(Rp/10.0)) - 1.0);
+  switch (fresp) {
+  case gr_iirdes::LOWPASS: {
+    vector<double> rtn(2);
+    if (Wp[0]>=Ws[0])
+      throw std::invalid_argument ("For lowpass filter Wp < Ws");
+
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    rtn[0] = ceil(0.5*(qs - qp)/log(Ws[0]/Wp[0]));
+    rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);    
+    rtn[1] = atan(rtn[1])/M_PI;
+    return rtn;
+  }
+  case gr_iirdes::HIGHPASS: {
+    vector<double> rtn(2);
+    if (Ws[0]>=Wp[0]) throw std::invalid_argument ("For highpass filter Wp > 
Ws");
+    Ws[0]= 0.5-Ws[0];
+    Wp[0]= 0.5-Wp[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    rtn[0] = ceil(0.5*(qs - qp)/log(Ws[0]/Wp[0]));
+    rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);    
+    rtn[1] = 0.5-atan(rtn[1])/M_PI;
+    return rtn;
+  }
+  case gr_iirdes::BANDPASS: {
+    vector<double> rtn(3);
+    if ((Ws[0]>=Wp[0]) ||
+       (Wp[0]>=Wp[1]) ||
+       (Wp[1]>=Ws[1])) throw std::invalid_argument
+                         ("For bandpass filter Ws[0]<Wp[0]<Wp[1]<Ws[1]");
+    Ws[0] = tan(M_PI*(0.5-Ws[0]));
+    Ws[1] = tan(M_PI*Ws[1]);
+    Wp[0] = tan(M_PI*(0.5-Wp[0]));
+    Wp[1] = tan(M_PI*Wp[1]);
+    rtn[0] = ceil(fmax(0.5*(qs - qp)/log(Ws[0]/Wp[0]),
+                      0.5*(qs - qp)/log(Ws[1]/Wp[1]))/2.0);
+
+    rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);    
+    rtn[2] = exp(log(Wp[1]) - qp/2/rtn[0]);
+
+    rtn[1] = 0.5-atan(rtn[1])/M_PI;
+    rtn[2] = atan(rtn[2])/M_PI;
+
+    return rtn;
+  }
+  case gr_iirdes::BANDSTOP: {
+    vector<double> rtn(3);
+    if ((Wp[0]>=Ws[0]) ||
+       (Ws[0]>=Ws[1]) ||
+       (Ws[1]>=Wp[1])) throw std::invalid_argument
+                         ("For bandstop filter Wp[0]<Ws[0]<Ws[1]<Wp[1]");
+
+    Ws[0] = tan(M_PI*Ws[0]);
+    Ws[1] = tan(M_PI*(0.5-Ws[1]));
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wp[1] = tan(M_PI*(0.5-Wp[1]));
+    rtn[0] = ceil(fmax(0.5*(qs - qp)/log(Ws[0]/Wp[0]),
+                      0.5*(qs - qp)/log(Ws[1]/Wp[1]))/2.0);
+
+    rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);    
+    rtn[2] = exp(log(Wp[1]) - qp/2/rtn[0]);
+
+    rtn[1] = atan(rtn[2])/M_PI;
+    rtn[2] = 0.5-atan(rtn[1])/M_PI;
+
+    return rtn;
+  }}
+  return (vector<double>) NULL;
+}
+
+vector<double>
+gr_iirdes::butter_tf(gr_iirdes::filter_response fresp,
+                    vector<double> Wc)
+{
+
+  vector<double> rtn;
+
+  switch (fresp) {
+  case gr_iirdes::LOWPASS:  {
+  }
+  case gr_iirdes::HIGHPASS: {
+  }
+  case gr_iirdes::BANDPASS: {
+  }
+  case gr_iirdes::BANDSTOP: {
+  }}
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::chebyshevord(gr_iirdes::filter_response fresp,
+            vector<double> Wp,
+            vector<double> Ws,
+            double Rp,
+            double Rs)
+{
+  double  qs = pow(10.,(fabs(Rs)/10.0));
+  double  qp = pow(10.,(fabs(Rp)/10.0));
+  switch (fresp) {
+  case gr_iirdes::LOWPASS: {
+    vector<double> rtn(2);
+    double Wa;
+    if (Wp[0]>=Ws[0])
+      throw std::invalid_argument ("For lowpass filter Wp < Ws");
+
+    rtn[1] = Wp[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Ws[0]/Wp[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa));
+    return rtn;
+  }
+  case gr_iirdes::HIGHPASS: {
+    double Wa;
+    vector<double> rtn(2);
+    if (Ws[0]>=Wp[0]) throw std::invalid_argument ("For highpass filter Wp > 
Ws");
+    rtn[1] = Wp[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Wp[0]/Ws[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa));
+    return rtn;
+  }
+  case gr_iirdes::BANDPASS: {
+    double Wa[2];
+    vector<double> rtn(3);
+    if ((Ws[0]>=Wp[0]) ||
+       (Wp[0]>=Wp[1]) ||
+       (Wp[1]>=Ws[1])) throw std::invalid_argument
+                         ("For bandpass filter Ws[0]<Wp[0]<Wp[1]<Ws[1]");
+
+    rtn[1] = Wp[0];
+    rtn[2] = Wp[1];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Ws[1] = tan(M_PI*Ws[1]);
+    Wp[1] = tan(M_PI*Wp[1]);
+    for (int i=0;i<2;i++)
+      Wa[i]=(Ws[i]*Ws[i]-Wp[0]*Wp[1])/(Ws[i]*(Wp[0]-Wp[1]));
+    Wa[0]=fmin(fabs(Wa[0]),fabs(Wa[1]));
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa[0]));
+    return rtn;
+  }
+  case gr_iirdes::BANDSTOP: {
+    vector<double> rtn(3);
+    throw std::invalid_argument
+                         ("bandstop filter not implemented yet");
+    return rtn;
+  }}
+  return (vector<double>) NULL;
+
+}
+
+vector<double>
+gr_iirdes::chebyshev_tf(gr_iirdes::filter_response fresp,
+         vector<double> Wc)
+{
+  vector<double> rtn;
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::invchebyshevord(filter_response fresp,
+               vector<double> Wp,
+               vector<double> Ws,
+               double Rp,
+               double Rs)
+{
+  double  qs = pow(10.,(fabs(Rs)/10.0));
+  double  qp = pow(10.,(fabs(Rp)/10.0));
+  switch (fresp) {
+  case gr_iirdes::LOWPASS: {
+    vector<double> rtn(2);
+    double Wa;
+    if (Wp[0]>=Ws[0])
+      throw std::invalid_argument ("For lowpass filter Wp < Ws");
+
+    rtn[1] = Ws[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Wp[0]/Ws[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa));
+    return rtn;
+  }
+  case gr_iirdes::HIGHPASS: {
+    double Wa;
+    vector<double> rtn(2);
+    if (Ws[0]>=Wp[0]) throw std::invalid_argument ("For highpass filter Wp > 
Ws");
+    rtn[1] = Ws[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Ws[0]/Wp[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa));
+    return rtn;
+  }
+  case gr_iirdes::BANDPASS: {
+    double Wa[2];
+    vector<double> rtn(3);
+    if ((Ws[0]>=Wp[0]) ||
+       (Wp[0]>=Wp[1]) ||
+       (Wp[1]>=Ws[1])) throw std::invalid_argument
+                         ("For bandpass filter Ws[0]<Wp[0]<Wp[1]<Ws[1]");
+
+    rtn[1] = Ws[0];
+    rtn[2] = Ws[1];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Ws[1] = tan(M_PI*Ws[1]);
+    Wp[1] = tan(M_PI*Wp[1]);
+    for (int i=0;i<2;i++)
+      Wa[i]=(Wp[i]*Wp[i]-Ws[0]*Ws[1])/(Wp[i]*(Ws[0]-Ws[1]));
+    Wa[0]=fmin(fabs(Wa[0]),fabs(Wa[1]));
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa[0]));
+    return rtn;
+  }
+  case gr_iirdes::BANDSTOP: {
+    vector<double> rtn(3);
+    throw std::invalid_argument
+                         ("bandstop filter not implemented yet");
+    return rtn;
+  }}
+  return (vector<double>) NULL;
+
+}
+
+vector<double>
+gr_iirdes::invchebyshev_tf(gr_iirdes::filter_response fresp,
+            vector<double> Wc)
+{
+  vector<double> rtn;
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::ellipord(gr_iirdes::filter_response fresp,
+        vector<double> Wp,
+        vector<double> Ws,
+        double Rp,
+        double Rs)
+{
+  vector<double> rtn(2);
+  if ((fresp == BANDPASS) || (fresp == BANDSTOP)) rtn.resize(3);
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::ellip_tf(gr_iirdes::filter_response fresp,
+      vector<double> Wc)
+{
+  vector<double> rtn;
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::besselord(gr_iirdes::filter_response fresp,
+         vector<double> Wp,
+         vector<double> Ws,
+         double Rp,
+         double Rs)
+{
+  vector<double> rtn(2);
+  if ((fresp == BANDPASS) || (fresp == BANDSTOP)) rtn.resize(3);
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::bessel_tf(gr_iirdes::filter_response fresp,
+                    vector<double> Wc)
+{
+  vector<double> rtn;
+  return rtn;
+}
+
+vector<double>
+gr_iirdes::tf2sos(vector<double> tf)
+{
+  vector<double> rtn;
+  return rtn;
+}
+
+int
+gr_iirdes::tf2order(vector<double> tf)
+{
+  int size = tf.size()/2;
+  return size;
+}
+
+vector<double>
+gr_iirdes::tf2zpg(vector<double> tf)
+{
+
+  int size = tf.size()/2;
+  double *a,*b,*z;
+  if (size < 2) throw std::invalid_argument
+   ("transfer function to pole, zero, gain calculation requires order 2 or 
greater");
+
+  gsl_poly_complex_workspace *w;
+  vector<double> rtn(4*size-3);
+
+  //  for(int i=0;i<4*size-3;i++) rtn[i]=0;
+  w = gsl_poly_complex_workspace_alloc(size);
+  a = (double *)malloc(size*sizeof(double));
+  b = (double *)malloc(size*sizeof(double));
+  for (int i=0;i<size;i++) {
+    a[i]=tf[i];
+    b[i]=tf[i+size];
+  }
+ 
+  z = (double *)malloc(2*(size-1)*sizeof(double));
+
+  for (int i=0;i<size-1;i++) {
+    z[2*i]=0;
+    z[2*i+1]=0;
+  }
+    
+  // compute zeros
+  gsl_poly_complex_solve (a, size, w, z);
+  // store them in the zeros in the zpk array
+  for (int i=0;i<size-1;i++)
+    rtn[2*i]=z[2*i],rtn[2*i+1]=z[2*i+1];
+
+  // compute poles
+  gsl_poly_complex_solve (b, size, w, z);
+  for (int i=0;i<size-1;i++)
+    rtn[2*i+2*size-2]=z[2*i],rtn[2*i+2*size-1]=z[2*i+1];
+
+  gsl_poly_complex_workspace_free(w);
+  rtn[4*size-4]=b[0]/a[0];
+  free(z);
+  free(a);
+  free(b);
+  return rtn;
+
+}
+
+vector<double>
+gr_iirdes::sftrans(gr_iirdes::filter_response ft,
+                  std::vector<double> zero,
+                  std::vector<double> pole,
+                  double k,
+                  std::vector<double> W,
+                  bool stop)
+{
+  vector<double> rtn;
+  return rtn;
+}

Added: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
 2009-08-20 02:06:56 UTC (rev 11615)
@@ -0,0 +1,157 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+
+#ifndef _GR_IIRDES_H_
+#define _GR_IIRDES_H_
+
+#include <cmath>
+#include <vector>
+#include <gr_complex.h>
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#include <gsl/gsl_poly.h>
+
+class gr_iirdes {
+
+ public:
+
+  // ... class types ... (public)
+
+  enum filter_response {
+    LOWPASS  = 0,        // Lowpass  filter, cutoff in (0,.5)
+    HIGHPASS = 1,        // Highpass filter, cutoff in (0,.5)
+    BANDPASS = 2,        // Bandpass filter, Ws(1)<Wp(1)<Wp(2)<Ws(2)
+    BANDSTOP = 3,        // Bandstop filter, Wp(1)<Ws(1)<Ws(2)<Wp(2)
+  };
+
+  enum filter_design_type {
+    BUTTER = 0,          // Butterworth design
+    CHEBYSHEV = 1,       // Chebyshev design
+    INVCHEBYSHEV = 2,    // Inverse Chebyshev or Chebyshev Type II
+    ELLIPTICAL = 3,      // Elliptical
+    BESSEL = 4,          // Bessel
+  };
+
+
+  // ... class methods ... (public)
+
+  /*!
+   * \brief using analog designs & bilinear transform for digital IIR filters
+   *
+   * \p fdtype:                filter design type (Butterworth, Elliptical,..
+   * \p Wp:                    Passband edges [0,.5)
+   * \p Ws:                    Stopband edges [0,.5)
+   * \p Rp:                    Passband ripple in dB
+   * \p Rs:                    Stopband rejection in dB
+   
+   */
+
+  static int
+  tf2order(std::vector<double> tf);
+
+  static std::vector<double>
+  tf2sos(std::vector<double> tf);
+
+
+  static std::vector<double>
+  tf2zpg(std::vector<double> tf);
+
+ 
+  static std::vector<double>
+  sftrans(filter_response ft,
+         std::vector<double> zero,
+         std::vector<double> pole,
+         double k,
+         std::vector<double> W,
+         bool stop);
+
+  static std::vector<double>
+  butterord(filter_response ft,
+           std::vector<double> Wp,
+           std::vector<double> Ws,
+           double Rp,
+           double Rs);
+
+  static std::vector<double>
+  butter_tf(filter_response ft,
+           std::vector<double> Wc);
+
+  static std::vector<double>
+  chebyshevord(filter_response ft,
+              std::vector<double> Wp,
+              std::vector<double> Ws,
+              double Rp,
+              double Rs);
+
+  static std::vector<double>
+  chebyshev_tf(filter_response ft,
+              std::vector<double> Wc);
+
+  static std::vector<double>
+  invchebyshevord(filter_response ft,
+                 std::vector<double> Wp,
+                 std::vector<double> Ws,
+                 double Rp,
+                 double Rs);
+
+  static std::vector<double>
+  invchebyshev_tf(filter_response ft,
+                 std::vector<double> Wc);
+
+  static std::vector<double>
+  ellipord(filter_response ft,
+          std::vector<double> Wp,
+          std::vector<double> Ws,
+          double Rp,
+          double Rs);
+
+  static std::vector<double>
+  ellip_tf(filter_response ft,
+          std::vector<double> Wc);
+
+  static std::vector<double>
+  besselord(filter_response ft,
+           std::vector<double> Wp,
+           std::vector<double> Ws,
+           double Rp,
+           double Rs);
+
+  static std::vector<double>
+  bessel_tf(filter_response ft,
+           std::vector<double> Wc);
+
+  static std::vector<double>
+  iirdes(filter_design_type fdtype,
+        std::vector<double> Wp,
+        std::vector<double> Ws,
+        double Rp,
+        double Rs);
+
+ // ... class members and methods ... (private)
+
+
+
+};
+#endif

Added: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.i
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.i
 2009-08-20 02:06:56 UTC (rev 11615)
@@ -0,0 +1,143 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*!
+ * \brief Infinite Impulse Response (IIR) filter design functions.
+ */
+
+%rename(iirdes) gr_iirdes;
+
+class gr_iirdes {
+
+
+ public:
+
+  // ... class types ... (public)
+
+  enum filter_response {
+    LOWPASS  = 0,        // Lowpass  filter, cutoff in (0,.5)
+    HIGHPASS = 1,        // Highpass filter, cutoff in (0,.5)
+    BANDPASS = 2,        // Bandpass filter, Ws(1)<Wp(1)<Wp(2)<Ws(2)
+    BANDSTOP = 3,        // Bandstop filter, Wp(1)<Ws(1)<Ws(2)<Wp(2)
+  };
+
+  enum filter_design_type {
+    BUTTER = 0,          // Butterworth design
+    CHEBYSHEV = 1,       // Chebyshev design
+    INVCHEBYSHEV = 2,    // Inverse Chebyshev or Chebyshev Type II
+    ELLIPTICAL = 3,      // Elliptical
+    BESSEL = 4,          // Bessel
+  };
+
+
+  // ... class methods ... (public)
+
+  /*!
+   * \brief using analog designs & bilinear transform for digital IIR filters
+   *
+   * \p fdtype:                filter design type (Butterworth, Elliptical,..
+   * \p Wp:                    Passband edges [0,.5)
+   * \p Ws:                    Stopband edges [0,.5)
+   * \p Rp:                    Passband ripple in dB
+   * \p Rs:                    Stopband rejection in dB
+   
+   */
+
+
+
+  static int
+  tf2order(std::vector<double> tf);
+
+  static std::vector<double>
+  tf2sos(std::vector<double> tf);
+
+
+  static std::vector<double>
+  tf2zpg(std::vector<double> tf);
+
+ 
+  static std::vector<double>
+  butterord(filter_response ft,
+           std::vector<double> Wp,
+           std::vector<double> Ws,
+           double Rp,
+           double Rs);
+
+  static std::vector<double>
+  butter_tf(filter_response ft,
+           std::vector<double> Wc);
+
+  static std::vector<double>
+  chebyshevord(filter_response ft,
+              std::vector<double> Wp,
+              std::vector<double> Ws,
+              double Rp,
+              double Rs);
+
+  static std::vector<double>
+  chebyshev_tf(filter_response ft,
+              std::vector<double> Wc);
+
+  static std::vector<double>
+  invchebyshevord(filter_response ft,
+                 std::vector<double> Wp,
+                 std::vector<double> Ws,
+                 double Rp,
+                 double Rs);
+
+  static std::vector<double>
+  invchebyshev_tf(filter_response ft,
+                 std::vector<double> Wc);
+
+  static std::vector<double>
+  ellipord(filter_response ft,
+          std::vector<double> Wp,
+          std::vector<double> Ws,
+          double Rp,
+          double Rs);
+
+  static std::vector<double>
+  ellip_tf(filter_response ft,
+          std::vector<double> Wc);
+
+  static std::vector<double>
+  besselord(filter_response ft,
+           std::vector<double> Wp,
+           std::vector<double> Ws,
+           double Rp,
+           double Rs);
+
+  static std::vector<double>
+  bessel_tf(filter_response ft,
+           std::vector<double> Wc);
+
+  static std::vector<double>
+  iirdes(filter_design_type fdtype,
+        std::vector<double> Wp,
+        std::vector<double> Ws,
+        double Rp,
+        double Rs);
+
+ // ... class members and methods ... (private)
+
+
+};





reply via email to

[Prev in Thread] Current Thread [Next in Thread]