From 958bc6f7365a19b42b0acc98e4c082eee6cf6e51 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Wed, 20 Jun 2012 11:01:54 -0400
Subject: filter: adding set/get for phase of arb resampler.

---
 gr-filter/include/filter/pfb_arb_resampler_ccf.h | 13 ++++++++
 gr-filter/include/filter/pfb_arb_resampler_fff.h | 13 ++++++++
 gr-filter/lib/pfb_arb_resampler_ccf_impl.cc      | 41 ++++++++++++++++++------
 gr-filter/lib/pfb_arb_resampler_ccf_impl.h       |  3 ++
 gr-filter/lib/pfb_arb_resampler_fff_impl.cc      | 21 ++++++++++++
 gr-filter/lib/pfb_arb_resampler_fff_impl.h       |  3 ++
 6 files changed, 85 insertions(+), 9 deletions(-)

diff --git a/gr-filter/include/filter/pfb_arb_resampler_ccf.h b/gr-filter/include/filter/pfb_arb_resampler_ccf.h
index cf5fa4a3b7..397ac25ea5 100644
--- a/gr-filter/include/filter/pfb_arb_resampler_ccf.h
+++ b/gr-filter/include/filter/pfb_arb_resampler_ccf.h
@@ -129,7 +129,20 @@ namespace gr {
        */
       virtual void print_taps() = 0;
 
+      /*!
+       * Sets the resampling rate of the block.
+       */
       virtual void set_rate (float rate) = 0;
+
+      /*!
+       * Sets the current phase offset in radians (0 to 2pi).
+       */
+      virtual void set_phase(float ph) = 0;
+
+      /*!
+       * Gets the current phase of the resampler in radians (2 to 2pi).
+       */
+      virtual float phase() const = 0;
     };
 
   } /* namespace filter */
diff --git a/gr-filter/include/filter/pfb_arb_resampler_fff.h b/gr-filter/include/filter/pfb_arb_resampler_fff.h
index 2504c92ec2..b6623b028e 100644
--- a/gr-filter/include/filter/pfb_arb_resampler_fff.h
+++ b/gr-filter/include/filter/pfb_arb_resampler_fff.h
@@ -130,7 +130,20 @@ namespace gr {
        */
       virtual void print_taps() = 0;
 
+      /*!
+       * Sets the resampling rate of the block.
+       */
       virtual void set_rate (float rate) = 0;
+
+      /*!
+       * Sets the current phase offset in radians (0 to 2pi).
+       */
+      virtual void set_phase(float ph) = 0;
+
+      /*!
+       * Gets the current phase of the resampler in radians (2 to 2pi).
+       */
+      virtual float phase() const = 0;
     };
 
   } /* namespace filter */
diff --git a/gr-filter/lib/pfb_arb_resampler_ccf_impl.cc b/gr-filter/lib/pfb_arb_resampler_ccf_impl.cc
index bb0906aa54..5480366de2 100644
--- a/gr-filter/lib/pfb_arb_resampler_ccf_impl.cc
+++ b/gr-filter/lib/pfb_arb_resampler_ccf_impl.cc
@@ -78,10 +78,8 @@ namespace gr {
       }
 
       // Now, actually set the filters' taps
-      std::vector<float> dtaps;
-      create_diff_taps(taps, dtaps);
-      create_taps(taps, d_taps, d_filters);
-      create_taps(dtaps, d_dtaps, d_diff_filters);
+      set_taps(taps);
+      d_updated = false;
     }
 
     pfb_arb_resampler_ccf_impl::~pfb_arb_resampler_ccf_impl()
@@ -122,11 +120,6 @@ namespace gr {
 	// Build a filter for each channel and add it's taps to it
 	ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]);
       }
-
-      // Set the history to ensure enough input items for each filter
-      set_history (d_taps_per_filter + 1);
-
-      d_updated = true;
     }
 
     void
@@ -148,6 +141,13 @@ namespace gr {
     pfb_arb_resampler_ccf_impl::set_taps(const std::vector<float> &taps)
     {
       gruel::scoped_lock guard(d_mutex);
+
+      std::vector<float> dtaps;
+      create_diff_taps(taps, dtaps);
+      create_taps(taps, d_taps, d_filters);
+      create_taps(dtaps, d_dtaps, d_diff_filters);
+      set_history(d_taps_per_filter + 1);
+      d_updated = true;
     }
  
     std::vector<std::vector<float> >
@@ -172,17 +172,40 @@ namespace gr {
     void
     pfb_arb_resampler_ccf_impl::set_rate(float rate)
     {
+      gruel::scoped_lock guard(d_mutex);
+
       d_dec_rate = (unsigned int)floor(d_int_rate/rate);
       d_flt_rate = (d_int_rate/rate) - d_dec_rate;
       set_relative_rate(rate);
     }
 
+    void
+    pfb_arb_resampler_ccf_impl::set_phase(float ph)
+    {
+      gruel::scoped_lock guard(d_mutex);
+      if((ph < 0) || (ph >= 2.0*M_PI)) {
+	throw std::runtime_error("pfb_arb_resampler_ccf: set_phase value out of bounds [0, 2pi).\n");
+      }
+      
+      float ph_diff = 2.0*M_PI / (float)d_filters.size();
+      d_last_filter = static_cast<int>(ph / ph_diff);
+    }
+
+    float
+    pfb_arb_resampler_ccf_impl::phase() const
+    {
+      float ph_diff = 2.0*M_PI / static_cast<float>(d_filters.size());
+      return d_last_filter * ph_diff;
+    }
+
     int
     pfb_arb_resampler_ccf_impl::general_work(int noutput_items,
 					     gr_vector_int &ninput_items,
 					     gr_vector_const_void_star &input_items,
 					     gr_vector_void_star &output_items)
     {
+      gruel::scoped_lock guard(d_mutex);
+
       gr_complex *in = (gr_complex*)input_items[0];
       gr_complex *out = (gr_complex*)output_items[0];
 
diff --git a/gr-filter/lib/pfb_arb_resampler_ccf_impl.h b/gr-filter/lib/pfb_arb_resampler_ccf_impl.h
index 8e7e993cb7..891e601e09 100644
--- a/gr-filter/lib/pfb_arb_resampler_ccf_impl.h
+++ b/gr-filter/lib/pfb_arb_resampler_ccf_impl.h
@@ -74,6 +74,9 @@ namespace gr {
       void print_taps();
       void set_rate(float rate);
 
+      void set_phase(float ph);
+      float phase() const;
+
       int general_work(int noutput_items,
 		       gr_vector_int &ninput_items,
 		       gr_vector_const_void_star &input_items,
diff --git a/gr-filter/lib/pfb_arb_resampler_fff_impl.cc b/gr-filter/lib/pfb_arb_resampler_fff_impl.cc
index 79c19655a3..6aff374fdd 100644
--- a/gr-filter/lib/pfb_arb_resampler_fff_impl.cc
+++ b/gr-filter/lib/pfb_arb_resampler_fff_impl.cc
@@ -172,11 +172,32 @@ namespace gr {
     void
     pfb_arb_resampler_fff_impl::set_rate(float rate)
     {
+      gruel::scoped_lock guard(d_mutex);
+
       d_dec_rate = (unsigned int)floor(d_int_rate/rate);
       d_flt_rate = (d_int_rate/rate) - d_dec_rate;
       set_relative_rate(rate);
     }
 
+    void
+    pfb_arb_resampler_fff_impl::set_phase(float ph)
+    {
+      gruel::scoped_lock guard(d_mutex);
+      if((ph < 0) || (ph >= 2.0*M_PI)) {
+	throw std::runtime_error("pfb_arb_resampler_ccf: set_phase value out of bounds [0, 2pi).\n");
+      }
+      
+      float ph_diff = 2.0*M_PI / (float)d_filters.size();
+      d_last_filter = static_cast<int>(ph / ph_diff);
+    }
+
+    float
+    pfb_arb_resampler_fff_impl::phase() const
+    {
+      float ph_diff = 2.0*M_PI / static_cast<float>(d_filters.size());
+      return d_last_filter * ph_diff;
+    }
+
     int
     pfb_arb_resampler_fff_impl::general_work(int noutput_items,
 					     gr_vector_int &ninput_items,
diff --git a/gr-filter/lib/pfb_arb_resampler_fff_impl.h b/gr-filter/lib/pfb_arb_resampler_fff_impl.h
index 54e01375ac..5889627114 100644
--- a/gr-filter/lib/pfb_arb_resampler_fff_impl.h
+++ b/gr-filter/lib/pfb_arb_resampler_fff_impl.h
@@ -73,6 +73,9 @@ namespace gr {
       void print_taps();
       void set_rate(float rate);
 
+      void set_phase(float ph);
+      float phase() const;
+
       int general_work(int noutput_items,
 		       gr_vector_int &ninput_items,
 		       gr_vector_const_void_star &input_items,
-- 
cgit v1.2.3


From 52bda3a2504638f3c0cc832b141dc138dfcd4800 Mon Sep 17 00:00:00 2001
From: Nicholas Corgan <nick.corgan@ettus.com>
Date: Wed, 20 Jun 2012 22:11:46 -0400
Subject: filter: adding stdint.h fixes Fedora 17/GCC 4.7.0 build.

---
 gr-filter/lib/qa_mmse_fir_interpolator_cc.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gr-filter/lib/qa_mmse_fir_interpolator_cc.cc b/gr-filter/lib/qa_mmse_fir_interpolator_cc.cc
index 5850cb86c2..02e0b32fe4 100644
--- a/gr-filter/lib/qa_mmse_fir_interpolator_cc.cc
+++ b/gr-filter/lib/qa_mmse_fir_interpolator_cc.cc
@@ -30,6 +30,7 @@
 #include <cstdio>
 #include <cmath>
 #include <stdexcept>
+#include <stdint.h>
 
 namespace gr {
   namespace filter {
-- 
cgit v1.2.3