Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / filter / gri_mmse_fir_interpolator.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 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 2, 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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 #include <gri_mmse_fir_interpolator.h>
27 #include <gr_fir_util.h>
28 #include <gr_fir_fff.h>
29 #include <assert.h>
30 #include <cmath>
31 #include "interpolator_taps.h"
32
33 gri_mmse_fir_interpolator::gri_mmse_fir_interpolator ()
34 {
35   filters.resize (NSTEPS + 1);
36   
37   for (int i = 0; i < NSTEPS + 1; i++){
38     std::vector<float> t (&taps[i][0], &taps[i][NTAPS]);
39     filters[i] = gr_fir_util::create_gr_fir_fff (t);
40   }
41 }
42
43 gri_mmse_fir_interpolator::~gri_mmse_fir_interpolator ()
44 {
45   for (int i = 0; i < NSTEPS + 1; i++)
46     delete filters[i];
47 }
48
49 unsigned
50 gri_mmse_fir_interpolator::ntaps () const
51 {
52   return NTAPS;
53 }
54
55 unsigned
56 gri_mmse_fir_interpolator::nsteps () const
57 {
58   return NSTEPS;
59 }
60
61 float
62 gri_mmse_fir_interpolator::interpolate (const float input[], float mu) const
63 {
64   int   imu = (int) rint (mu * NSTEPS);
65
66   assert (imu >= 0);
67   assert (imu <= NSTEPS);
68
69   float r = filters[imu]->filter (input);
70   return r;
71 }