[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11275 - gnuradio/branches/developers/trondeau/pfb/gnu
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11275 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter |
Date: |
Tue, 23 Jun 2009 21:02:07 -0600 (MDT) |
Author: trondeau
Date: 2009-06-23 21:02:06 -0600 (Tue, 23 Jun 2009)
New Revision: 11275
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/filter.i
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.i
Log:
wip: start of filterbank channelizer. Something is wrong with the indexing and
a lot of 0's get spit out.
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/filter.i
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/filter.i
2009-06-23 20:38:18 UTC (rev 11274)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/filter.i
2009-06-24 03:02:06 UTC (rev 11275)
@@ -32,6 +32,7 @@
#include <gr_fractional_interpolator_cc.h>
#include <gr_goertzel_fc.h>
#include <gr_cma_equalizer_cc.h>
+#include <gr_pfb_filter_ccf.h>
%}
%include "gr_iir_filter_ffd.i"
@@ -45,5 +46,6 @@
%include "gr_fractional_interpolator_cc.i"
%include "gr_goertzel_fc.i"
%include "gr_cma_equalizer_cc.i"
+%include "gr_pfb_filter_ccf.i"
%include "filter_generated.i"
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
2009-06-23 20:38:18 UTC (rev 11274)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
2009-06-24 03:02:06 UTC (rev 11275)
@@ -27,57 +27,121 @@
#include <gr_pfb_filter_ccf.h>
#include <gr_fir_ccf.h>
#include <gr_fir_util.h>
+#include <gri_fft.h>
#include <gr_io_signature.h>
-gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (int decimation, const
std::vector<float> &taps)
+gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps)
{
- return gr_pfb_filter_ccf_sptr (new gr_pfb_filter_ccf (decimation, taps));
+ return gr_pfb_filter_ccf_sptr (new gr_pfb_filter_ccf (numchans, taps));
}
-gr_pfb_filter_ccf::gr_pfb_filter_ccf (int decimation, const std::vector<float>
&taps)
- : gr_sync_decimator ("pfb_filter_ccf",
- gr_make_io_signature (1, 1, sizeof (gr_complex)),
- gr_make_io_signature (1, 1, sizeof (gr_complex)),
- decimation),
+gr_pfb_filter_ccf::gr_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps)
+ : gr_block ("pfb_filter_ccf",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))),
d_updated (false)
{
- d_fir = gr_fir_util::create_gr_fir_ccf (taps);
- set_history (d_fir->ntaps ());
+ unsigned int i,j;
+
+ unsigned int ntaps = taps.size();
+ d_numchans = numchans;
+ d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans);
+ d_filters = std::vector<gr_fir_ccf*>(d_numchans);
+ d_delay_line = std::vector<gr_complex*>(d_numchans);
+
+ // Create d_numchan vectors to store each channel's taps
+ std::vector< std::vector<float> > vtaps(d_numchans);
+
+ // Partition the filter
+ for(i = 0; i < d_numchans; i++) {
+ // Each channel uses all d_taps_per_filter with 0's if not enough taps to
fill out
+ vtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ vtaps[i][j] = taps[i + j*d_numchans]; // add taps to channels in
reverse order
+ }
+
+ // Build a filter for each channel and add it's taps to it
+ d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps[i]);
+ d_delay_line[i] = new gr_complex[d_taps_per_filter];
+ memset(d_delay_line[i], 0, d_taps_per_filter*sizeof(gr_complex));
+ }
+
+ // Create the FFT to handle the output de-spinning of the channels
+ d_fft = new gri_fft_complex (d_numchans, false);
+
+ set_history (d_taps_per_filter);
}
gr_pfb_filter_ccf::~gr_pfb_filter_ccf ()
{
- delete d_fir;
+ for(unsigned int i = 0; i < d_numchans; i++) {
+ delete d_filters[i];
+ }
}
void
gr_pfb_filter_ccf::set_taps (const std::vector<float> &taps)
{
- d_new_taps = taps;
+ // FIXME: implement this
+
d_updated = true;
}
int
-gr_pfb_filter_ccf::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+gr_pfb_filter_ccf::general_work (int noutput_items,
+ gr_vector_int &ninput_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_fir->set_taps (d_new_taps);
- set_history (d_fir->ntaps ());
+ //d_fir->set_taps (d_new_taps);
+ //set_history (d_fir->ntaps ());
d_updated = false;
return 0; // history requirements may have changed.
}
- if (decimation() == 1)
- d_fir->filterN (out, in, noutput_items);
+ printf("noutput_items: %d\n", noutput_items);
+ printf("ninput_items: %d\n", ninput_items[0]);
- else
- d_fir->filterNdec (out, in, noutput_items, decimation());
+ // FIXME: simple initial implementation
+ // yes, this will be optimized
+ unsigned int i = 0, count = 0;
+ gr_complex *flt_out = new gr_complex[d_numchans];
+ for(int i = 0; i < noutput_items; i++) {
+ // Move through filters from bottom to top
+
+ memset(flt_out, 0, d_numchans*sizeof(gr_complex));
+ for(int j = d_numchans-1; j >= 0; j--) {
+ // Move all values in delay line forward to make room for new value
+ for(unsigned int k = 0; k < d_taps_per_filter-1; k++) {
+ d_delay_line[j][k+1] = d_delay_line[j][k];
+ }
+ d_delay_line[j][0] = in[0]; // add new value to delay line
+ in++;
+ count++;
+
+ // Filter current delay line with its respective filter
+ flt_out[j] = d_filters[j]->filter(d_delay_line[j]);
+ }
+
+ // despin through FFT
+ memcpy(d_fft->get_inbuf(), &flt_out[0], d_numchans*sizeof(gr_complex));
+ d_fft->execute();
+ memcpy(&out[i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex));
+ //memcpy(&out[i], flt_out, d_numchans*sizeof(gr_complex));
+ i++;
+ }
+
+ delete flt_out;
+
+ printf("count: %d\n", count);
+ consume_each(count);
return noutput_items;
}
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
2009-06-23 20:38:18 UTC (rev 11274)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
2009-06-24 03:02:06 UTC (rev 11275)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,41 +24,48 @@
#ifndef INCLUDED_GR_PFB_FILTER_CCF_H
#define INCLUDED_GR_PFB_FILTER_CCF_H
-#include <gr_sync_decimator.h>
+#include <gr_block.h>
class gr_pfb_filter_ccf;
typedef boost::shared_ptr<gr_pfb_filter_ccf> gr_pfb_filter_ccf_sptr;
-gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (int decimation, const
std::vector<float> &taps);
+gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps);
class gr_fir_ccf;
+class gri_fft_complex;
/*!
* \brief FIR filter with gr_complex input, gr_complex output and float taps
* \ingroup filter_blk
*/
-class gr_pfb_filter_ccf : public gr_sync_decimator
+class gr_pfb_filter_ccf : public gr_block
{
private:
- friend gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (int decimation,
+ friend gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (unsigned int numchans,
const
std::vector<float> &taps);
- gr_fir_ccf *d_fir;
- std::vector<float> d_new_taps;
- bool d_updated;
+ std::vector<gr_fir_ccf*> d_filters;
+ std::vector<gr_complex*> d_delay_line;
+ gri_fft_complex *d_fft;
+ unsigned int d_numchans;
+ unsigned int d_taps_per_filter;
+ bool d_updated;
/*!
* Construct a FIR filter with the given taps
*/
- gr_pfb_filter_ccf (int decimation, const std::vector<float> &taps);
+ gr_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps);
public:
~gr_pfb_filter_ccf ();
void set_taps (const std::vector<float> &taps);
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
#endif
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.i
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.i
2009-06-23 20:38:18 UTC (rev 11274)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.i
2009-06-24 03:02:06 UTC (rev 11275)
@@ -20,14 +20,16 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(gr,pfb_filter_ccf)
+GR_SWIG_BLOCK_MAGIC(gr,pfb_filter_ccf);
-gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (int decimation, const
std::vector<float> &taps);
+gr_pfb_filter_ccf_sptr gr_make_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps);
-class gr_pfb_filter_ccf : public gr_sync_decimator
+class gr_pfb_filter_ccf : public gr_block
{
private:
- gr_pfb_filter_ccf (int decimation, const std::vector<float> &taps);
+ gr_pfb_filter_ccf (unsigned int numchans,
+ const std::vector<float> &taps);
public:
~gr_pfb_filter_ccf ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11275 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter,
trondeau <=