summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-06-21 08:29:37 -0400
committerTom Rondeau <trondeau@vt.edu>2012-06-21 08:29:37 -0400
commit9965c0a8d09dc905f7eca2ed05ffdc4a4c7dcc64 (patch)
tree8fbc3b01bfede2461f8341e26cb5023953875d09
parentc316e3088e96bd9623420e2a0399fa772c96ef49 (diff)
parent52bda3a2504638f3c0cc832b141dc138dfcd4800 (diff)
Merge branch 'master' into next
-rw-r--r--gr-filter/include/filter/pfb_arb_resampler_ccf.h13
-rw-r--r--gr-filter/include/filter/pfb_arb_resampler_fff.h13
-rw-r--r--gr-filter/lib/pfb_arb_resampler_ccf_impl.cc41
-rw-r--r--gr-filter/lib/pfb_arb_resampler_ccf_impl.h3
-rw-r--r--gr-filter/lib/pfb_arb_resampler_fff_impl.cc21
-rw-r--r--gr-filter/lib/pfb_arb_resampler_fff_impl.h3
-rw-r--r--gr-filter/lib/qa_mmse_fir_interpolator_cc.cc1
7 files changed, 86 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,
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 {