summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc15
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h25
2 files changed, 38 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
index e13a933ea..824a78dd9 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
@@ -49,6 +49,17 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans,
gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))),
d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate)
{
+ // The over sampling rate must be rationally related to the number of channels
+ // in that it must be N/i for i in [1,N], which gives an outputsample rate
+ // of [fs/N, fs] where fs is the input sample rate.
+ // This tests the specified input sample rate to see if it conforms to this
+ // requirement within a few significant figures.
+ double intp = 0;
+ double x = (10000.0*rint(numchans / oversample_rate)) / 10000.0;
+ double fltp = modf(numchans / oversample_rate, &intp);
+ if(fltp != 0.0)
+ throw std::invalid_argument("gr_pfb_channelizer: oversample rate must be N/i for i in [1, N]");
+
d_filters = std::vector<gr_fir_ccf*>(d_numchans);
// Create an FIR filter for each channel and zero out the taps
@@ -68,7 +79,7 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans,
// performs the FFT shift operation on every other turn.
d_rate_ratio = (int)rintf(d_numchans / d_oversample_rate);
d_idxlut = new int[d_numchans];
- for(int i = 0; i < d_numchans; i++) {
+ for(unsigned int i = 0; i < d_numchans; i++) {
d_idxlut[i] = d_numchans - ((i + d_rate_ratio) % d_numchans) - 1;
}
@@ -175,7 +186,7 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items,
i--;
}
- n += (i+d_rate_ratio) >= d_numchans;
+ n += (i+d_rate_ratio) >= (int)d_numchans;
// despin through FFT
d_fft->execute();
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
index e33e1938e..d56ccdbc6 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
@@ -89,6 +89,19 @@ class gri_fft_complex;
* <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB,
* attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
*
+ * The filter output can also be overs ampled. The over sampling rate
+ * is the ratio of the the actual output sampling rate to the normal
+ * output sampling rate. It must be rationally related to the number
+ * of channels as N/i for i in [1,N], which gives an outputsample rate
+ * of [fs/N, fs] where fs is the input sample rate and N is the number
+ * of channels.
+ *
+ * For example, for 6 channels with fs = 6000 Hz, the normal rate is
+ * 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4,
+ * 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample
+ * ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2,
+ * so the output rate would be 1200 Hz.
+ *
* The theory behind this block can be found in Chapter 6 of
* the following book.
*
@@ -104,6 +117,18 @@ class gr_pfb_channelizer_ccf : public gr_block
* Build the polyphase filterbank decimator.
* \param numchans (unsigned integer) Specifies the number of channels <EM>M</EM>
* \param taps (vector/list of floats) The prototype filter to populate the filterbank.
+ * \param oversample_rate (float) The over sampling rate is the ratio of the the actual
+ * output sampling rate to the normal output sampling rate.
+ * It must be rationally related to the number of channels
+ * as N/i for i in [1,N], which gives an outputsample rate
+ * of [fs/N, fs] where fs is the input sample rate and N is
+ * the number of channels.
+ *
+ * For example, for 6 channels with fs = 6000 Hz, the normal
+ * rate is 6000/6 = 1000 Hz. Allowable oversampling rates
+ * are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output
+ * sample rate of a 6/1 oversample ratio is 6000 Hz, or
+ * 6 times the normal 1000 Hz.
*/
friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
const std::vector<float> &taps,