commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] gnuradio-core/src/lib/filter gr_goertzel_fc.cc ...


From: Johnathan Corgan
Subject: [Commit-gnuradio] gnuradio-core/src/lib/filter gr_goertzel_fc.cc ...
Date: Sat, 01 Jul 2006 10:28:29 +0000

CVSROOT:        /sources/gnuradio
Module name:    gnuradio-core
Changes by:     Johnathan Corgan <jcorgan>      06/07/01 10:28:29

Modified files:
        src/lib/filter : gr_goertzel_fc.cc gr_goertzel_fc.h 
                         gr_goertzel_fc.i gri_goertzel.cc gri_goertzel.h 

Log message:
        Modifications to gri_goertzel for ctcss squelch operation:
        
        * Renamed 'points' parameter to 'len' to make more sense
        * Renamed 'dft' method to 'batch' to make more sense
        * Added sample by sample processing with 'input' and 'output' methods.
        
        First two items also apply to gr_goertzel_fc block.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc?cvsroot=gnuradio&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_goertzel_fc.h?cvsroot=gnuradio&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gr_goertzel_fc.i?cvsroot=gnuradio&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gri_goertzel.cc?cvsroot=gnuradio&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/filter/gri_goertzel.h?cvsroot=gnuradio&r1=1.2&r2=1.3

Patches:
Index: gr_goertzel_fc.cc
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gr_goertzel_fc.cc   25 Jun 2006 20:28:33 -0000      1.3
+++ gr_goertzel_fc.cc   1 Jul 2006 10:28:29 -0000       1.4
@@ -29,35 +29,31 @@
 
 // public constructor
 gr_goertzel_fc_sptr 
-gr_make_goertzel_fc(int rate, int points, float freq) 
+gr_make_goertzel_fc(int rate, int len, float freq) 
 {
-  return gr_goertzel_fc_sptr (new gr_goertzel_fc(rate, points, freq));
+  return gr_goertzel_fc_sptr (new gr_goertzel_fc(rate, len, freq));
 }
 
-gr_goertzel_fc::gr_goertzel_fc(int rate, int points, float freq)
+gr_goertzel_fc::gr_goertzel_fc(int rate, int len, float freq)
   : gr_sync_decimator("goertzel_fc",
                      gr_make_io_signature (1, 1, sizeof (float)),
                      gr_make_io_signature (1, 1, sizeof (gr_complex)),
-                     points),
-    d_goertzel(rate, points, freq)
+                     len),
+    d_goertzel(rate, len, freq)
 {
-  d_points = points;
+  d_len = len;
 }
 
-gr_goertzel_fc::~gr_goertzel_fc ()
-{
-}
-
-int gr_goertzel_fc::work (int noutput_items,
+int gr_goertzel_fc::work(int noutput_items,
                          gr_vector_const_void_star &input_items,
                          gr_vector_void_star &output_items)
 {
-  float *in = (float *) input_items[0];
-  gr_complex *out = (gr_complex *) output_items[0];
+  float *in = (float *)input_items[0];
+  gr_complex *out = (gr_complex *)output_items[0];
 
   for (int i = 0; i < noutput_items; i++) {
-    *out++ = d_goertzel.dft(in);
-    in += d_points;
+    *out++ = d_goertzel.batch(in);
+    in += d_len;
   }
 
   return noutput_items;

Index: gr_goertzel_fc.h
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/gr_goertzel_fc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gr_goertzel_fc.h    25 Jun 2006 19:36:58 -0000      1.2
+++ gr_goertzel_fc.h    1 Jul 2006 10:28:29 -0000       1.3
@@ -30,7 +30,7 @@
 typedef boost::shared_ptr<gr_goertzel_fc> gr_goertzel_fc_sptr;
 
 // public constructor
-gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int points, float freq);
+gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq);
 
 /*!
  * \brief Goertzel single-bin DFT calculation.
@@ -39,15 +39,13 @@
 class gr_goertzel_fc : public gr_sync_decimator
 {
 private:
-  friend gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int points, float 
freq);
+  friend gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int len, float 
freq);
 
-  gr_goertzel_fc(int rate, int points, float freq);
+  gr_goertzel_fc(int rate, int len, float freq);
   gri_goertzel d_goertzel;
-  int          d_points;
+  int          d_len;
 
 public:
-  ~gr_goertzel_fc();
-
   int work(int noutput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);

Index: gr_goertzel_fc.i
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/gr_goertzel_fc.i,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gr_goertzel_fc.i    25 Jun 2006 19:36:58 -0000      1.2
+++ gr_goertzel_fc.i    1 Jul 2006 10:28:29 -0000       1.3
@@ -22,11 +22,10 @@
 
 GR_SWIG_BLOCK_MAGIC(gr,goertzel_fc);
 
-gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int points, float freq);
+gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq);
 
 class gr_goertzel_fc : public gr_sync_decimator
 {
 private:
   gr_goertzel_fc();
 };
-

Index: gri_goertzel.cc
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/gri_goertzel.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gri_goertzel.cc     25 Jun 2006 19:36:58 -0000      1.2
+++ gri_goertzel.cc     1 Jul 2006 10:28:29 -0000       1.3
@@ -25,7 +25,7 @@
 
 #include <gri_goertzel.h>
 
-gri_goertzel::gri_goertzel(int rate, int points, float freq)
+gri_goertzel::gri_goertzel(int rate, int len, float freq)
 {
   d_d1 = 0.0;
   d_d2 = 0.0;
@@ -34,19 +34,34 @@
   d_wr = 2.0*std::cos(w);
   d_wi = std::sin(w);
 
-  d_n = points;
+  d_len = len;
+  d_processed = 0;
 }
 
-gr_complex gri_goertzel::dft(float *input)
+gr_complex gri_goertzel::batch(float *in)
 {
   d_d1 = 0.0;
   d_d2 = 0.0;
 
-  for(int i = 0; i < d_n; i++) {
-    float y = input[i] + d_wr*d_d1 - d_d2;
+  for(int i = 0; i < d_len; i++)
+    input(in[i]);
+
+  return output();
+}
+
+void gri_goertzel::input(const float &input)
+{
+  float y = input + d_wr*d_d1 - d_d2;
     d_d2 = d_d1;
     d_d1 = y;
-  }
+  d_processed++;
+}
 
-  return gr_complex((0.5*d_wr*d_d1-d_d2)/d_n, (d_wi*d_d1)/d_n);
+gr_complex gri_goertzel::output()
+{
+  gr_complex out((0.5*d_wr*d_d1-d_d2)/d_len, (d_wi*d_d1)/d_len);
+  d_d1 = 0.0;
+  d_d2 = 0.0;
+  d_processed = 0;
+  return out;
 }

Index: gri_goertzel.h
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/filter/gri_goertzel.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gri_goertzel.h      25 Jun 2006 19:36:58 -0000      1.2
+++ gri_goertzel.h      1 Jul 2006 10:28:29 -0000       1.3
@@ -32,16 +32,24 @@
 class gri_goertzel
 {
 public:
-  gri_goertzel(int rate, int points, float freq);
+  gri_goertzel() {}
+  gri_goertzel(int rate, int len, float freq);
 
-  gr_complex dft(float *input);
+  // Process a input array
+  gr_complex batch(float *in);
+
+  // Process sample by sample
+  void input(const float &in);
+  gr_complex output();
+  bool ready() const { return d_processed == d_len; }
 
 private:
   float d_d1;
   float d_d2;
   float d_wr;
   float d_wi;
-  int   d_n;
+  int   d_len;
+  int   d_processed;
 };
 
 #endif /* INCLUDED_GRI_GOERTZEL_H */




reply via email to

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