Opening up channelizer to have different sampling rates out. This first pass produces...
authorTom Rondeau <trondeau@vt.edu>
Wed, 7 Apr 2010 22:25:46 +0000 (18:25 -0400)
committerTom Rondeau <trondeau@vt.edu>
Wed, 7 Apr 2010 22:25:46 +0000 (18:25 -0400)
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i
gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py

index 7e34551c8ed4ce8e62ed4f85f4d33ddb28dad349..4ba073efd2b01950129eac3c2d7c2853daf035d7 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 #include <cstring>
 
 gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, 
-                                                        const std::vector<float> &taps)
+                                                        const std::vector<float> &taps,
+                                                        float oversample_rate)
 {
-  return gr_pfb_channelizer_ccf_sptr (new gr_pfb_channelizer_ccf (numchans, taps));
+  return gr_pfb_channelizer_ccf_sptr (new gr_pfb_channelizer_ccf (numchans, taps,
+                                                                 oversample_rate));
 }
 
 
 gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, 
-                                     const std::vector<float> &taps)
+                                               const std::vector<float> &taps,
+                                               float oversample_rate)
   : gr_sync_block ("pfb_channelizer_ccf",
                   gr_make_io_signature (numchans, numchans, sizeof(gr_complex)),
                   gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))),
-    d_updated (false)
+    d_updated (false), d_oversample_rate(oversample_rate)
 {
   d_numchans = numchans;
   d_filters = std::vector<gr_fir_ccf*>(d_numchans);
@@ -133,7 +136,39 @@ gr_pfb_channelizer_ccf::work (int noutput_items,
     return 0;               // history requirements may have changed.
   }
 
-  for(int i = 0; i < noutput_items; i++) {
+  int M = d_oversample_rate;
+  int N = d_numchans;
+  int r = N / M;
+
+  int n=0, i=0, j=0;
+  
+  printf("\nnoutput_items = %d\n", noutput_items);
+  printf("N = %d   M  = %d   r = %d\n", N, M, r);
+
+  //for(int n = 1; n < noutput_items; n++) {
+  while(n < noutput_items) {
+    j = 0;
+    i = (i + r - 1) % N;
+    //printf("i = %d   i >= 0   n = %d\n", i, n);
+    while(i >= 0) {
+      in = (gr_complex*)input_items[j];
+      d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n]);
+      j++;
+      i--;
+    }
+
+    i = N;
+    //printf("i = %d   r = %d   i >= r\n", i, r);
+    while(i > r) {
+      i--;
+      in = (gr_complex*)input_items[j];
+      d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n-1]);
+      j++;
+    }
+
+    n += (i+r) >= N;
+
+    /*
     // Move through filters from bottom to top
     for(int j = d_numchans-1; j >= 0; j--) {
       // Take in the items from the first input stream to d_numchans
@@ -142,10 +177,12 @@ gr_pfb_channelizer_ccf::work (int noutput_items,
       // Filter current input stream from bottom filter to top
       d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]);
     }
+    */
 
     // despin through FFT
     d_fft->execute();
-    memcpy(&out[d_numchans*i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex));
+    memcpy(&out[d_numchans*n], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex));
+    //memcpy(&out[d_numchans*i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex));
   }
   
   return noutput_items;
index b2e67e8173a5558b16499698d4134d6da480c860..c7330045974fda8cb2d640ceae10782d59ad561d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -29,7 +29,8 @@
 class gr_pfb_channelizer_ccf;
 typedef boost::shared_ptr<gr_pfb_channelizer_ccf> gr_pfb_channelizer_ccf_sptr;
 gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, 
-                                                        const std::vector<float> &taps);
+                                                        const std::vector<float> &taps,
+                                                        float oversample_rate=1);
 
 class gr_fir_ccf;
 class gri_fft_complex;
@@ -105,7 +106,8 @@ class gr_pfb_channelizer_ccf : public gr_sync_block
    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
    */
   friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
-                                                                 const std::vector<float> &taps);
+                                                                 const std::vector<float> &taps,
+                                                                 float oversample_rate);
 
   std::vector<gr_fir_ccf*> d_filters;
   std::vector< std::vector<float> > d_taps;
@@ -113,6 +115,7 @@ class gr_pfb_channelizer_ccf : public gr_sync_block
   unsigned int             d_numchans;
   unsigned int             d_taps_per_filter;
   bool                    d_updated;
+  float                    d_oversample_rate;
 
   /*!
    * Build the polyphase filterbank decimator.
@@ -120,7 +123,8 @@ class gr_pfb_channelizer_ccf : public gr_sync_block
    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
    */
   gr_pfb_channelizer_ccf (unsigned int numchans, 
-                         const std::vector<float> &taps);
+                         const std::vector<float> &taps,
+                         float oversample_rate);
 
 public:
   ~gr_pfb_channelizer_ccf ();
index 4bef90e2222b2b0609489dbe3a0da4bcabd60324..d9c4581a2109e394eee2dc3d3e4d751eed03d516 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 GR_SWIG_BLOCK_MAGIC(gr,pfb_channelizer_ccf);
 
 gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
-                                                        const std::vector<float> &taps);
+                                                        const std::vector<float> &taps,
+                                                        float oversample_rate=1);
 
 class gr_pfb_channelizer_ccf : public gr_sync_block
 {
  private:
   gr_pfb_channelizer_ccf (unsigned int numchans,
-                         const std::vector<float> &taps);
+                         const std::vector<float> &taps,
+                         float oversample_rate);
 
  public:
   ~gr_pfb_channelizer_ccf ();
index c45ae4d1a95ced054a04ebdc37d72ae9d1097d1f..a479ed48ea9a357800fccd03dde273fccc3b69d3 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009,2010 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -29,16 +29,18 @@ class pfb_channelizer_ccf(gr.hier_block2):
     This simplifies the interface by allowing a single input stream to connect to this block.
     It will then output a stream for each channel.
     '''
-    def __init__(self, numchans, taps):
+    def __init__(self, numchans, taps, oversample_rate=1):
        gr.hier_block2.__init__(self, "pfb_channelizer_ccf",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature
 
         self._numchans = numchans
         self._taps = taps
+        self._oversample_rate = oversample_rate
 
         self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._numchans)
-        self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps)
+        self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps,
+                                          self._oversample_rate)
         self.v2s = gr.vector_to_streams(gr.sizeof_gr_complex, self._numchans)
 
         self.connect(self, self.s2ss)