Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / filter / gr_fft_filter_ccc.cc @ 0f73b099

History | View | Annotate | Download (3.2 kB)

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