wip
authorTom <trondeau@vt.edu>
Fri, 9 Oct 2009 18:10:15 +0000 (11:10 -0700)
committerTom <trondeau@vt.edu>
Fri, 9 Oct 2009 18:10:15 +0000 (11:10 -0700)
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i

index a75b20d3835ce1b5956a9321fdba8990f61054c0..08ab949d02924972cdbaf61793db8c20f80da212 100644 (file)
@@ -33,7 +33,7 @@
 #include <gr_io_signature.h>
 #include <gr_math.h>
 
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
                                                       const std::vector<float> &taps,
                                                       unsigned int filter_size,
                                                       float init_phase,
@@ -47,7 +47,7 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
 
 int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)};
 std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
-gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float gain,
                                              const std::vector<float> &taps,
                                              unsigned int filter_size,
                                              float init_phase,
@@ -58,6 +58,7 @@ gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
     d_updated (false), d_sps(sps), d_nfilters(filter_size),
     d_max_dev(max_rate_deviation), d_start_count(0)
 {
+  printf("SPS: %f\n", d_sps);
   d_nfilters = filter_size;
 
   // Store the last filter between calls to work
@@ -240,14 +241,6 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items,
 
   // produce output as long as we can and there are enough input samples
   while((i < noutput_items) && (count < nrequired)) {
-    out[i] = d_filters[d_filtnum]->filter(&in[count]);
-    gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]);
-    error_r  = out[i].real() * diff.real();
-    error_i  = out[i].imag() * diff.imag();
-    error = error_i + error_r;
-
-    d_k = d_k + d_alpha*error + d_rate;
-    d_rate = d_rate + d_beta*error;
     d_filtnum = (int)floor(d_k);
 
     // Keep the current filter number in [0, d_nfilters]
@@ -264,18 +257,32 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items,
       d_sample_num -= 1.0;
     }
     
+    out[i] = d_filters[d_filtnum]->filter(&in[count]);
+    gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]);
+    error_r  = out[i].real() * diff.real();
+    error_i  = out[i].imag() * diff.imag();
+    error = error_i + error_r;
+
+    d_k = d_k + d_alpha*error + d_rate;
+    d_rate = d_rate + d_beta*error;
+
     // Keep our rate within a good range
     d_rate = gr_branchless_clip(d_rate, d_max_dev);
 
     i++;
+    int a = (int)floor(d_sample_num);
     d_sample_num += d_sps;
+    int b = a + (int)floor(d_sps);
     count = (int)floor(d_sample_num);
 
     if(output_items.size() > 2) {
       err[i] = error;
-      outrate[i] = d_rate;
       outk[i] = d_k;
     }
+    if(b != count) {
+      outrate[i] = 1;
+    }
+
   }
 
   // Set the start index at the next entrance to the work function
index 84e174b198cf3489a6f87d3fdcc61bbbe09181d5..73bd7d6e6cb45854951ab19dcb3eccbc2b9ed537 100644 (file)
@@ -28,7 +28,7 @@
 
 class gr_pfb_clock_sync_ccf;
 typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr;
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
                                                       const std::vector<float> &taps,
                                                       unsigned int filter_size=32,
                                                       float init_phase=0,
@@ -51,17 +51,17 @@ class gr_pfb_clock_sync_ccf : public gr_block
   /*!
    * Build the polyphase filterbank timing synchronizer.
    */
-  friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+  friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
                                                                const std::vector<float> &taps,
                                                                unsigned int filter_size,
                                                                float init_phase,
                                                                float max_rate_deviation);
 
   bool                    d_updated;
-  float                    d_sps;
+  double                   d_sps;
+  double                   d_sample_num;
   float                    d_alpha;
   float                    d_beta;
-  float                    d_sample_num;
   int                      d_nfilters;
   std::vector<gr_fir_ccf*> d_filters;
   std::vector<gr_fir_ccf*> d_diff_filters;
@@ -77,7 +77,7 @@ class gr_pfb_clock_sync_ccf : public gr_block
   /*!
    * Build the polyphase filterbank timing synchronizer.
    */
-  gr_pfb_clock_sync_ccf (float sps, float gain,
+  gr_pfb_clock_sync_ccf (double sps, float gain,
                         const std::vector<float> &taps,
                         unsigned int filter_size,
                         float init_phase,
index 9957c33b759b4f075f5f312e9071c113e2775be9..197984287171a68ba2578a6a628800f9621d9e75 100644 (file)
@@ -22,7 +22,7 @@
 
 GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf);
 
-gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
                                                       const std::vector<float> &taps,
                                                       unsigned int filter_size=32,
                                                       float init_phase=0,
@@ -31,7 +31,7 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
 class gr_pfb_clock_sync_ccf : public gr_block
 {
  private:
-  gr_pfb_clock_sync_ccf (float sps, float gain,
+  gr_pfb_clock_sync_ccf (double sps, float gain,
                         const std::vector<float> &taps,
                         unsigned int filter_size,
                         float init_phase,