3 * Copyright 2003 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
24 * WARNING: This file is automatically generated by
25 * generate_gr_freq_xlating_fir_filter_XXX.py
26 * Any changes made to this file will be overwritten.
33 #include <gr_freq_xlating_fir_filter_scf.h>
34 #include <gr_fir_scc.h>
35 #include <gr_fir_util.h>
36 #include <gr_io_signature.h>
38 gr_freq_xlating_fir_filter_scf_sptr
39 gr_make_freq_xlating_fir_filter_scf (int decimation, const std::vector<float> &taps,
40 double center_freq, double sampling_freq)
42 return gr_freq_xlating_fir_filter_scf_sptr (new gr_freq_xlating_fir_filter_scf (decimation, taps, center_freq, sampling_freq));
46 gr_freq_xlating_fir_filter_scf::gr_freq_xlating_fir_filter_scf (
49 const std::vector<float> &taps,
53 : gr_sync_decimator ("freq_xlating_fir_filter_scf",
54 gr_make_io_signature (1, 1, sizeof (short)),
55 gr_make_io_signature (1, 1, sizeof (gr_complex)),
57 d_proto_taps (taps), d_center_freq (center_freq), d_sampling_freq (sampling_freq),
60 std::vector<gr_complex> dummy_taps;
61 d_composite_fir = gr_fir_util::create_gr_fir_scc (dummy_taps);
63 set_history (d_proto_taps.size ());
64 build_composite_fir ();
67 gr_freq_xlating_fir_filter_scf::~gr_freq_xlating_fir_filter_scf ()
69 delete d_composite_fir;
73 gr_freq_xlating_fir_filter_scf::build_composite_fir ()
75 std::vector<gr_complex> ctaps (d_proto_taps.size ());
77 float fwT0 = 2 * M_PI * d_center_freq / d_sampling_freq;
78 for (unsigned int i = 0; i < d_proto_taps.size (); i++)
79 ctaps[i] = d_proto_taps[i] * exp (gr_complex (0, i * fwT0));
81 d_composite_fir->set_taps (gr_reverse(ctaps));
82 d_r.set_phase_incr (exp (gr_complex (0, fwT0 * decimation ())));
86 gr_freq_xlating_fir_filter_scf::set_center_freq (double center_freq)
88 d_center_freq = center_freq;
93 gr_freq_xlating_fir_filter_scf::set_taps (const std::vector<float> &taps)
100 gr_freq_xlating_fir_filter_scf::work (int noutput_items,
101 gr_vector_const_void_star &input_items,
102 gr_vector_void_star &output_items)
104 short *in = (short *) input_items[0];
105 gr_complex *out = (gr_complex *) output_items[0];
107 // rebuild composite FIR if the center freq has changed
110 set_history (d_proto_taps.size ());
111 build_composite_fir ();
113 return 0; // history requirements may have changed.
117 for (int i = 0; i < noutput_items; i++){
118 out[i] = d_r.rotate (d_composite_fir->filter (&in[j]));
122 return noutput_items;