3c92c6a258ab9185635ffedc544b9ed3c2deca8c
[debian/gnuradio] / gnuradio-core / src / lib / filter / gr_fft_filter_ccc.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 /*
24  * WARNING: This file is automatically generated by generate_gr_fft_filter_XXX.py
25  * Any changes made to this file will be overwritten.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include <gr_fft_filter_ccc.h>
33 #include <gri_fft_filter_ccc_sse.h>
34 #include <gri_fft_filter_ccc_generic.h>
35 #include <gr_io_signature.h>
36 #include <gri_fft.h>
37 #include <math.h>
38 #include <assert.h>
39 #include <stdexcept>
40 #include <gr_firdes.h>
41
42 #include <cstdio>
43 #include <iostream>
44 #include <string.h>
45
46 gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps)
47 {
48   return gr_fft_filter_ccc_sptr (new gr_fft_filter_ccc (decimation, taps));
49 }
50
51
52 gr_fft_filter_ccc::gr_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps)
53   : gr_sync_decimator ("fft_filter_ccc",
54                        gr_make_io_signature (1, 1, sizeof (gr_complex)),
55                        gr_make_io_signature (1, 1, sizeof (gr_complex)),
56                        decimation),
57     d_updated(false)
58 {
59   set_history(1);
60 #if 0
61   d_filter = new gri_fft_filter_ccc_generic(decimation, taps);
62 #else
63   d_filter = new gri_fft_filter_ccc_sse(decimation, taps);
64 #endif
65   d_nsamples = d_filter->set_taps(taps);
66   set_output_multiple(d_nsamples);
67 }
68
69 gr_fft_filter_ccc::~gr_fft_filter_ccc ()
70 {
71   delete d_filter;
72 }
73
74 void
75 gr_fft_filter_ccc::set_taps (const std::vector<gr_complex> &taps)
76 {
77   d_new_taps = taps;
78   d_updated = true;
79 }
80
81 int
82 gr_fft_filter_ccc::work (int noutput_items,
83                          gr_vector_const_void_star &input_items,
84                          gr_vector_void_star &output_items)
85 {
86   const gr_complex *in = (const gr_complex *) input_items[0];
87   gr_complex *out = (gr_complex *) output_items[0];
88
89   if (d_updated){
90     d_nsamples = d_filter->set_taps(d_new_taps);
91     d_updated = false;
92     set_output_multiple(d_nsamples);
93     return 0;                           // output multiple may have changed
94   }
95
96   assert(noutput_items % d_nsamples == 0);
97
98   d_filter->filter(noutput_items, in, out);
99
100   //assert((out - (gr_complex *) output_items[0]) == noutput_items);
101
102   return noutput_items;
103 }