[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11311 - in gnuradio/branches/developers/trondeau/pfb/
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11311 - in gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src: lib/filter python/gnuradio/blks2impl |
Date: |
Mon, 29 Jun 2009 20:23:33 -0600 (MDT) |
Author: trondeau
Date: 2009-06-29 20:23:33 -0600 (Mon, 29 Jun 2009)
New Revision: 11311
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
Log:
Adding a polyphase filterbank 1-to-M upsampler.
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
(rev 0)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
2009-06-30 02:23:33 UTC (rev 11311)
@@ -0,0 +1,134 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_pfb_interpolator_ccf.h>
+#include <gr_fir_ccf.h>
+#include <gr_fir_util.h>
+#include <gr_io_signature.h>
+
+gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int
interp,
+ const
std::vector<float> &taps)
+{
+ return gr_pfb_interpolator_ccf_sptr (new gr_pfb_interpolator_ccf (interp,
taps));
+}
+
+
+gr_pfb_interpolator_ccf::gr_pfb_interpolator_ccf (unsigned int interp,
+ const std::vector<float>
&taps)
+ : gr_sync_interpolator ("pfb_interpolator_ccf",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ interp),
+ d_updated (false)
+{
+ d_rate = interp;
+ d_filters = std::vector<gr_fir_ccf*>(d_rate);
+
+ // Create an FIR filter for each channel and zero out the taps
+ std::vector<float> vtaps(0, d_rate);
+ for(unsigned int i = 0; i < d_rate; i++) {
+ d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
+ }
+
+ // Now, actually set the filters' taps
+ set_taps(taps);
+}
+
+gr_pfb_interpolator_ccf::~gr_pfb_interpolator_ccf ()
+{
+ for(unsigned int i = 0; i < d_rate; i++) {
+ delete d_filters[i];
+ }
+}
+
+void
+gr_pfb_interpolator_ccf::set_taps (const std::vector<float> &taps)
+{
+ unsigned int i,j;
+
+ unsigned int ntaps = taps.size();
+ d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate);
+
+ // Create d_numchan vectors to store each channel's taps
+ //std::vector< std::vector<float> > vtaps(d_rate);
+ d_taps.resize(d_rate);
+
+ // Partition the filter
+ for(i = 0; i < d_rate; i++) {
+ // Each channel uses all d_taps_per_filter with 0's if not enough taps to
fill out
+ d_taps[i] = std::vector<float>(d_taps_per_filter, 0);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ d_taps[i][j] = taps[i + j*d_rate]; // add taps to channels in reverse
order
+ }
+
+ // Build a filter for each channel and add it's taps to it
+ d_filters[i]->set_taps(d_taps[i]);
+ }
+
+ // Set the history to ensure enough input items for each filter
+ set_history (d_taps_per_filter);
+
+ d_updated = true;
+}
+
+void
+gr_pfb_interpolator_ccf::print_taps()
+{
+ unsigned int i, j;
+ for(i = 0; i < d_rate; i++) {
+ printf("filter[%d]: [", i);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ printf(" %.4e", d_taps[i][j]);
+ }
+ printf("]\n");
+ }
+}
+
+int
+gr_pfb_interpolator_ccf::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *in = (gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+
+ if (d_updated) {
+ d_updated = false;
+ return 0; // history requirements may have changed.
+ }
+
+ int i = 0, count = 0;
+
+ while(i < noutput_items) {
+ for(int j = 0; j < d_rate; j++) {
+ out[i] = d_filters[j]->filter(&in[count]);
+ i++;
+ }
+ count++;
+ }
+
+ return i;
+}
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
(rev 0)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
2009-06-30 02:23:33 UTC (rev 11311)
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef INCLUDED_GR_PFB_INTERPOLATOR_CCF_H
+#define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H
+
+#include <gr_sync_interpolator.h>
+
+class gr_pfb_interpolator_ccf;
+typedef boost::shared_ptr<gr_pfb_interpolator_ccf>
gr_pfb_interpolator_ccf_sptr;
+gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int
interp,
+ const
std::vector<float> &taps);
+
+class gr_fir_ccf;
+
+/*!
+ * \brief FIR filter with gr_complex input, gr_complex output and float taps
+ * \ingroup filter_blk
+ */
+class gr_pfb_interpolator_ccf : public gr_sync_interpolator
+{
+ private:
+ friend gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned
int interp,
+ const
std::vector<float> &taps);
+
+ std::vector<gr_fir_ccf*> d_filters;
+ std::vector< std::vector<float> > d_taps;
+ unsigned int d_rate;
+ unsigned int d_taps_per_filter;
+ bool d_updated;
+
+ /*!
+ * Construct a Polyphase filterbank for channelization with the given
+ * number of channels and taps
+ */
+ gr_pfb_interpolator_ccf (unsigned int interp,
+ const std::vector<float> &taps);
+
+public:
+ ~gr_pfb_interpolator_ccf ();
+
+ void set_taps (const std::vector<float> &taps);
+ void print_taps();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i
(rev 0)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i
2009-06-30 02:23:33 UTC (rev 11311)
@@ -0,0 +1,39 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,pfb_interpolator_ccf);
+
+gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp,
+ const
std::vector<float> &taps);
+
+class gr_pfb_interpolator_ccf : public gr_sync_interpolator
+{
+ private:
+ gr_pfb_interpolator_ccf (unsigned int interp,
+ const std::vector<float> &taps);
+
+ public:
+ ~gr_pfb_interpolator_ccf ();
+
+ void set_taps (const std::vector<float> &taps);
+ void print_taps();
+};
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
(rev 0)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
2009-06-30 02:23:33 UTC (rev 11311)
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr
+
+class pfb_interpolator_ccf(gr.hier_block2):
+ '''
+ Make a Polyphase Filter interpolator (complex in, complex out,
floating-point taps)
+ This interface is very simple, but the block is made here to keep it
consistent with
+ the other PFB filter implementations.
+ '''
+ def __init__(self, interp, taps):
+ gr.hier_block2.__init__(self, "pfb_interpolator_ccf",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex), #
Input signature
+ gr.io_signature(1, 1, gr.sizeof_gr_complex)) #
Output signature
+
+ self._interp = interp
+ self._taps = taps
+
+ self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps)
+
+ self.connect(self, self.pfb)
+ self.connect(self.pfb, self)
+
+
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11311 - in gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src: lib/filter python/gnuradio/blks2impl,
trondeau <=