From 9db640f51b3af0cc73a94471a623b4d394ec2aab Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Sat, 11 Dec 2010 14:42:57 -0800 Subject: Create method to set rate on pfb_arb_resamp after it has been created. Allow it to be called from GRC. --- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc | 3 +-- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h | 6 +++++- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc index 59b76a6f0..2136dd843 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc @@ -58,8 +58,7 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, process. */ d_int_rate = filter_size; - d_dec_rate = (unsigned int)floor(d_int_rate/rate); - d_flt_rate = (d_int_rate/rate) - d_dec_rate; + set_rate(rate); // Store the last filter between calls to work d_last_filter = 0; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h index cf5a79d4e..44dd202b9 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h @@ -161,7 +161,11 @@ public: * Print all of the filterbank taps to screen. */ void print_taps(); - + void set_rate (float rate) { + d_dec_rate = (unsigned int)floor(d_int_rate/rate); + d_flt_rate = (d_int_rate/rate) - d_dec_rate; + } + int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i index 4f07af861..77f28acdf 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i @@ -38,4 +38,5 @@ class gr_pfb_arb_resampler_ccf : public gr_block //void set_taps (const std::vector<float> &taps); void print_taps(); + void set_rate (float rate); }; -- cgit From c75950bd5babfcab323b29b956fa0b620c3c19da Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 12 Dec 2010 13:09:32 -0500 Subject: resampler PFB: Sets relative rate when rate is changed. --- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc | 3 --- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc index 2136dd843..35455aa12 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc @@ -80,8 +80,6 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, create_diff_taps(taps, dtaps); create_taps(taps, d_taps, d_filters); create_taps(dtaps, d_dtaps, d_diff_filters); - - set_relative_rate(rate); } gr_pfb_arb_resampler_ccf::~gr_pfb_arb_resampler_ccf () @@ -179,7 +177,6 @@ gr_pfb_arb_resampler_ccf::general_work (int noutput_items, // produce output as long as we can and there are enough input samples while((i < noutput_items) && (count < ninput_items[0]-1)) { - // start j by wrapping around mod the number of channels while((j < d_int_rate) && (i < noutput_items)) { // Take the current filter and derivative filter output diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h index 44dd202b9..2c36c95f9 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h @@ -164,6 +164,7 @@ public: void set_rate (float rate) { d_dec_rate = (unsigned int)floor(d_int_rate/rate); d_flt_rate = (d_int_rate/rate) - d_dec_rate; + set_relative_rate(rate); } int general_work (int noutput_items, -- cgit From 7e21f9ad055bb646b22edb462112443bab670b4e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 12 Dec 2010 13:22:40 -0500 Subject: PFB resampler: fixes bug where filter could be looking past the number of inputs. --- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc index 35455aa12..320568bc3 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc @@ -176,7 +176,7 @@ gr_pfb_arb_resampler_ccf::general_work (int noutput_items, j = d_last_filter; // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < ninput_items[0]-1)) { + while((i < noutput_items) && (count < ninput_items[0]-d_taps_per_filter)) { // start j by wrapping around mod the number of channels while((j < d_int_rate) && (i < noutput_items)) { // Take the current filter and derivative filter output -- cgit From a151e3e1ba2409b44fd2af8ba1f9bfbf3f0dbf25 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 12 Dec 2010 13:39:06 -0500 Subject: PFB resampler: fix it this way to avoid the signed/unsigned warning. --- gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib') diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc index 320568bc3..834450436 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc @@ -176,7 +176,8 @@ gr_pfb_arb_resampler_ccf::general_work (int noutput_items, j = d_last_filter; // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < ninput_items[0]-d_taps_per_filter)) { + int max_input = ninput_items[0]-(int)d_taps_per_filter; + while((i < noutput_items) && (count < max_input)) { // start j by wrapping around mod the number of channels while((j < d_int_rate) && (i < noutput_items)) { // Take the current filter and derivative filter output -- cgit