Revision 75f9f9c4
| b/gnuradio-core/src/lib/filter/Makefile.am | ||
|---|---|---|
| 1 | 1 |
# |
| 2 |
# Copyright 2001,2002,2004,2005,2006 Free Software Foundation, Inc. |
|
| 2 |
# Copyright 2001,2002,2004,2005,2006,2007 Free Software Foundation, Inc.
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This file is part of GNU Radio |
| 5 | 5 |
# |
| ... | ... | |
| 170 | 170 |
gr_fft_filter_fff.cc \ |
| 171 | 171 |
gr_goertzel_fc.cc \ |
| 172 | 172 |
gr_filter_delay_fc.cc \ |
| 173 |
gr_fractional_interpolator.cc \ |
|
| 173 |
gr_fractional_interpolator_ff.cc \ |
|
| 174 |
gr_fractional_interpolator_cc.cc \ |
|
| 174 | 175 |
gr_hilbert_fc.cc \ |
| 175 | 176 |
gr_iir_filter_ffd.cc \ |
| 176 | 177 |
gr_sincos.c \ |
| ... | ... | |
| 229 | 230 |
gr_fft_filter_fff.h \ |
| 230 | 231 |
gr_filter_delay_fc.h \ |
| 231 | 232 |
gr_fir_sysconfig_x86.h \ |
| 232 |
gr_fractional_interpolator.h \ |
|
| 233 |
gr_fractional_interpolator_ff.h \ |
|
| 234 |
gr_fractional_interpolator_cc.h \ |
|
| 233 | 235 |
gr_goertzel_fc.h \ |
| 234 | 236 |
gr_hilbert_fc.h \ |
| 235 | 237 |
gr_iir_filter_ffd.h \ |
| ... | ... | |
| 291 | 293 |
gr_fft_filter_ccc.i \ |
| 292 | 294 |
gr_fft_filter_fff.i \ |
| 293 | 295 |
gr_filter_delay_fc.i \ |
| 296 |
gr_fractional_interpolator_ff.i \ |
|
| 297 |
gr_fractional_interpolator_cc.i \ |
|
| 294 | 298 |
gr_goertzel_fc.i \ |
| 295 | 299 |
gr_hilbert_fc.i \ |
| 296 | 300 |
gr_iir_filter_ffd.i \ |
| b/gnuradio-core/src/lib/filter/filter.i | ||
|---|---|---|
| 1 | 1 |
/* -*- c++ -*- */ |
| 2 | 2 |
/* |
| 3 |
* Copyright 2004,2005,2006 Free Software Foundation, Inc. |
|
| 3 |
* Copyright 2004,2005,2006,2007 Free Software Foundation, Inc.
|
|
| 4 | 4 |
* |
| 5 | 5 |
* This file is part of GNU Radio |
| 6 | 6 |
* |
| ... | ... | |
| 28 | 28 |
#include <gr_filter_delay_fc.h> |
| 29 | 29 |
#include <gr_fft_filter_ccc.h> |
| 30 | 30 |
#include <gr_fft_filter_fff.h> |
| 31 |
#include <gr_fractional_interpolator_ff.h> |
|
| 32 |
#include <gr_fractional_interpolator_cc.h> |
|
| 31 | 33 |
#include <gr_goertzel_fc.h> |
| 32 | 34 |
#include <gr_cma_equalizer_cc.h> |
| 33 | 35 |
%} |
| ... | ... | |
| 39 | 41 |
%include "gr_filter_delay_fc.i" |
| 40 | 42 |
%include "gr_fft_filter_ccc.i" |
| 41 | 43 |
%include "gr_fft_filter_fff.i" |
| 44 |
%include "gr_fractional_interpolator_ff.i" |
|
| 45 |
%include "gr_fractional_interpolator_cc.i" |
|
| 42 | 46 |
%include "gr_goertzel_fc.i" |
| 43 | 47 |
%include "gr_cma_equalizer_cc.i" |
| 44 | 48 |
|
| /dev/null | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004 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 |
|
|
| 27 |
#include <gr_io_signature.h> |
|
| 28 |
#include <gr_fractional_interpolator.h> |
|
| 29 |
#include <gri_mmse_fir_interpolator.h> |
|
| 30 |
#include <stdexcept> |
|
| 31 |
|
|
| 32 |
// Public constructor |
|
| 33 |
gr_fractional_interpolator_sptr gr_make_fractional_interpolator(float phase_shift, float interp_ratio) |
|
| 34 |
{
|
|
| 35 |
return gr_fractional_interpolator_sptr(new gr_fractional_interpolator(phase_shift, interp_ratio)); |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
gr_fractional_interpolator::gr_fractional_interpolator(float phase_shift, float interp_ratio) |
|
| 39 |
: gr_block ("fractional_interpolator",
|
|
| 40 |
gr_make_io_signature (1, 1, sizeof (float)), |
|
| 41 |
gr_make_io_signature (1, 1, sizeof (float))), |
|
| 42 |
d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp() |
|
| 43 |
{
|
|
| 44 |
if (interp_ratio <= 0) |
|
| 45 |
throw std::out_of_range ("interpolation ratio must be > 0");
|
|
| 46 |
if (phase_shift < 0 || phase_shift > 1) |
|
| 47 |
throw std::out_of_range ("phase shift ratio must be > 0 and < 1");
|
|
| 48 |
|
|
| 49 |
set_relative_rate (1.0 / interp_ratio); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
gr_fractional_interpolator::~gr_fractional_interpolator() |
|
| 53 |
{
|
|
| 54 |
delete d_interp; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
void |
|
| 58 |
gr_fractional_interpolator::forecast(int noutput_items, gr_vector_int &ninput_items_required) |
|
| 59 |
{
|
|
| 60 |
unsigned ninputs = ninput_items_required.size(); |
|
| 61 |
for (unsigned i=0; i < ninputs; i++) |
|
| 62 |
|
|
| 63 |
ninput_items_required[i] = |
|
| 64 |
(int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
int |
|
| 68 |
gr_fractional_interpolator::general_work(int noutput_items, |
|
| 69 |
gr_vector_int &ninput_items, |
|
| 70 |
gr_vector_const_void_star &input_items, |
|
| 71 |
gr_vector_void_star &output_items) |
|
| 72 |
{
|
|
| 73 |
const float *in = (const float *) input_items[0]; |
|
| 74 |
float *out = (float *) output_items[0]; |
|
| 75 |
|
|
| 76 |
int ii = 0; // input index |
|
| 77 |
int oo = 0; // output index |
|
| 78 |
|
|
| 79 |
while (oo < noutput_items){
|
|
| 80 |
|
|
| 81 |
// produce output sample |
|
| 82 |
|
|
| 83 |
out[oo++] = d_interp->interpolate(&in[ii], d_mu); |
|
| 84 |
|
|
| 85 |
// printf( "%4d %9.6f\n", ii, d_mu); |
|
| 86 |
|
|
| 87 |
double s = d_mu + d_mu_inc; |
|
| 88 |
double f = floor (s); |
|
| 89 |
int incr = (int) f; |
|
| 90 |
d_mu = s - f; |
|
| 91 |
ii += incr; |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
consume_each (ii); |
|
| 95 |
|
|
| 96 |
return noutput_items; |
|
| 97 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004 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 |
#ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_H |
|
| 24 |
#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_H |
|
| 25 |
|
|
| 26 |
#include <gr_block.h> |
|
| 27 |
|
|
| 28 |
class gri_mmse_fir_interpolator; |
|
| 29 |
|
|
| 30 |
class gr_fractional_interpolator; |
|
| 31 |
typedef boost::shared_ptr<gr_fractional_interpolator> gr_fractional_interpolator_sptr; |
|
| 32 |
|
|
| 33 |
// public constructor |
|
| 34 |
gr_fractional_interpolator_sptr gr_make_fractional_interpolator (float phase_shift, float interp_ratio); |
|
| 35 |
|
|
| 36 |
/*! |
|
| 37 |
* \brief Interpolating mmse filter with float input, float output |
|
| 38 |
* \ingroup filter |
|
| 39 |
*/ |
|
| 40 |
class gr_fractional_interpolator : public gr_block |
|
| 41 |
{
|
|
| 42 |
public: |
|
| 43 |
~gr_fractional_interpolator (); |
|
| 44 |
void forecast(int noutput_items, gr_vector_int &ninput_items_required); |
|
| 45 |
int general_work (int noutput_items, |
|
| 46 |
gr_vector_int &ninput_items, |
|
| 47 |
gr_vector_const_void_star &input_items, |
|
| 48 |
gr_vector_void_star &output_items); |
|
| 49 |
|
|
| 50 |
protected: |
|
| 51 |
gr_fractional_interpolator (float phase_shift, float interp_ratio); |
|
| 52 |
|
|
| 53 |
private: |
|
| 54 |
float d_mu; |
|
| 55 |
float d_mu_inc; |
|
| 56 |
gri_mmse_fir_interpolator *d_interp; |
|
| 57 |
|
|
| 58 |
friend gr_fractional_interpolator_sptr |
|
| 59 |
gr_make_fractional_interpolator (float phase_shift, float interp_ratio); |
|
| 60 |
}; |
|
| 61 |
|
|
| 62 |
#endif |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004,2007 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 |
|
|
| 27 |
#include <gr_io_signature.h> |
|
| 28 |
#include <gr_fractional_interpolator_cc.h> |
|
| 29 |
#include <gri_mmse_fir_interpolator_cc.h> |
|
| 30 |
#include <stdexcept> |
|
| 31 |
|
|
| 32 |
// Public constructor |
|
| 33 |
gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc(float phase_shift, float interp_ratio) |
|
| 34 |
{
|
|
| 35 |
return gr_fractional_interpolator_cc_sptr(new gr_fractional_interpolator_cc(phase_shift, interp_ratio)); |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
gr_fractional_interpolator_cc::gr_fractional_interpolator_cc(float phase_shift, float interp_ratio) |
|
| 39 |
: gr_block ("fractional_interpolator_cc",
|
|
| 40 |
gr_make_io_signature (1, 1, sizeof (float)), |
|
| 41 |
gr_make_io_signature (1, 1, sizeof (float))), |
|
| 42 |
d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator_cc()) |
|
| 43 |
{
|
|
| 44 |
if (interp_ratio <= 0) |
|
| 45 |
throw std::out_of_range ("interpolation ratio must be > 0");
|
|
| 46 |
if (phase_shift < 0 || phase_shift > 1) |
|
| 47 |
throw std::out_of_range ("phase shift ratio must be > 0 and < 1");
|
|
| 48 |
|
|
| 49 |
set_relative_rate (1.0 / interp_ratio); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
gr_fractional_interpolator_cc::~gr_fractional_interpolator_cc() |
|
| 53 |
{
|
|
| 54 |
delete d_interp; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
void |
|
| 58 |
gr_fractional_interpolator_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) |
|
| 59 |
{
|
|
| 60 |
unsigned ninputs = ninput_items_required.size(); |
|
| 61 |
for (unsigned i=0; i < ninputs; i++) |
|
| 62 |
|
|
| 63 |
ninput_items_required[i] = |
|
| 64 |
(int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
int |
|
| 68 |
gr_fractional_interpolator_cc::general_work(int noutput_items, |
|
| 69 |
gr_vector_int &ninput_items, |
|
| 70 |
gr_vector_const_void_star &input_items, |
|
| 71 |
gr_vector_void_star &output_items) |
|
| 72 |
{
|
|
| 73 |
const gr_complex *in = (const gr_complex *) input_items[0]; |
|
| 74 |
gr_complex *out = (gr_complex *) output_items[0]; |
|
| 75 |
|
|
| 76 |
int ii = 0; // input index |
|
| 77 |
int oo = 0; // output index |
|
| 78 |
|
|
| 79 |
while (oo < noutput_items) {
|
|
| 80 |
|
|
| 81 |
out[oo++] = d_interp->interpolate(&in[ii], d_mu); |
|
| 82 |
|
|
| 83 |
double s = d_mu + d_mu_inc; |
|
| 84 |
double f = floor (s); |
|
| 85 |
int incr = (int) f; |
|
| 86 |
d_mu = s - f; |
|
| 87 |
ii += incr; |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
consume_each (ii); |
|
| 91 |
|
|
| 92 |
return noutput_items; |
|
| 93 |
} |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004,2007 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 |
#ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H |
|
| 24 |
#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H |
|
| 25 |
|
|
| 26 |
#include <gr_block.h> |
|
| 27 |
|
|
| 28 |
class gri_mmse_fir_interpolator_cc; |
|
| 29 |
|
|
| 30 |
class gr_fractional_interpolator_cc; |
|
| 31 |
typedef boost::shared_ptr<gr_fractional_interpolator_cc> gr_fractional_interpolator_cc_sptr; |
|
| 32 |
|
|
| 33 |
// public constructor |
|
| 34 |
gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); |
|
| 35 |
|
|
| 36 |
/*! |
|
| 37 |
* \brief Interpolating mmse filter with gr_complex input, gr_complex output |
|
| 38 |
* \ingroup filter |
|
| 39 |
*/ |
|
| 40 |
class gr_fractional_interpolator_cc : public gr_block |
|
| 41 |
{
|
|
| 42 |
public: |
|
| 43 |
~gr_fractional_interpolator_cc (); |
|
| 44 |
void forecast(int noutput_items, gr_vector_int &ninput_items_required); |
|
| 45 |
int general_work (int noutput_items, |
|
| 46 |
gr_vector_int &ninput_items, |
|
| 47 |
gr_vector_const_void_star &input_items, |
|
| 48 |
gr_vector_void_star &output_items); |
|
| 49 |
|
|
| 50 |
float mu() const { return d_mu;}
|
|
| 51 |
float interp_ratio() const { return d_mu_inc;}
|
|
| 52 |
void set_mu (float mu) { d_mu = mu; }
|
|
| 53 |
void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; }
|
|
| 54 |
|
|
| 55 |
protected: |
|
| 56 |
gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); |
|
| 57 |
|
|
| 58 |
private: |
|
| 59 |
float d_mu; |
|
| 60 |
float d_mu_inc; |
|
| 61 |
gri_mmse_fir_interpolator_cc *d_interp; |
|
| 62 |
|
|
| 63 |
friend gr_fractional_interpolator_cc_sptr |
|
| 64 |
gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); |
|
| 65 |
}; |
|
| 66 |
|
|
| 67 |
#endif |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2007 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 |
GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_cc); |
|
| 24 |
|
|
| 25 |
gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); |
|
| 26 |
|
|
| 27 |
class gr_fractional_interpolator_cc : public gr_block |
|
| 28 |
{
|
|
| 29 |
private: |
|
| 30 |
gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); |
|
| 31 |
|
|
| 32 |
public: |
|
| 33 |
float mu() const; |
|
| 34 |
float interp_ratio() const; |
|
| 35 |
void set_mu (float mu); |
|
| 36 |
void set_interp_ratio (float interp_ratio); |
|
| 37 |
}; |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004,2007 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 |
|
|
| 27 |
#include <gr_io_signature.h> |
|
| 28 |
#include <gr_fractional_interpolator_ff.h> |
|
| 29 |
#include <gri_mmse_fir_interpolator.h> |
|
| 30 |
#include <stdexcept> |
|
| 31 |
|
|
| 32 |
// Public constructor |
|
| 33 |
gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff(float phase_shift, float interp_ratio) |
|
| 34 |
{
|
|
| 35 |
return gr_fractional_interpolator_ff_sptr(new gr_fractional_interpolator_ff(phase_shift, interp_ratio)); |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
gr_fractional_interpolator_ff::gr_fractional_interpolator_ff(float phase_shift, float interp_ratio) |
|
| 39 |
: gr_block ("fractional_interpolator_ff",
|
|
| 40 |
gr_make_io_signature (1, 1, sizeof (float)), |
|
| 41 |
gr_make_io_signature (1, 1, sizeof (float))), |
|
| 42 |
d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator()) |
|
| 43 |
{
|
|
| 44 |
if (interp_ratio <= 0) |
|
| 45 |
throw std::out_of_range ("interpolation ratio must be > 0");
|
|
| 46 |
if (phase_shift < 0 || phase_shift > 1) |
|
| 47 |
throw std::out_of_range ("phase shift ratio must be > 0 and < 1");
|
|
| 48 |
|
|
| 49 |
set_relative_rate (1.0 / interp_ratio); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
gr_fractional_interpolator_ff::~gr_fractional_interpolator_ff() |
|
| 53 |
{
|
|
| 54 |
delete d_interp; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
void |
|
| 58 |
gr_fractional_interpolator_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required) |
|
| 59 |
{
|
|
| 60 |
unsigned ninputs = ninput_items_required.size(); |
|
| 61 |
for (unsigned i=0; i < ninputs; i++) |
|
| 62 |
|
|
| 63 |
ninput_items_required[i] = |
|
| 64 |
(int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
int |
|
| 68 |
gr_fractional_interpolator_ff::general_work(int noutput_items, |
|
| 69 |
gr_vector_int &ninput_items, |
|
| 70 |
gr_vector_const_void_star &input_items, |
|
| 71 |
gr_vector_void_star &output_items) |
|
| 72 |
{
|
|
| 73 |
const float *in = (const float *) input_items[0]; |
|
| 74 |
float *out = (float *) output_items[0]; |
|
| 75 |
|
|
| 76 |
int ii = 0; // input index |
|
| 77 |
int oo = 0; // output index |
|
| 78 |
|
|
| 79 |
while (oo < noutput_items) {
|
|
| 80 |
|
|
| 81 |
out[oo++] = d_interp->interpolate(&in[ii], d_mu); |
|
| 82 |
|
|
| 83 |
double s = d_mu + d_mu_inc; |
|
| 84 |
double f = floor (s); |
|
| 85 |
int incr = (int) f; |
|
| 86 |
d_mu = s - f; |
|
| 87 |
ii += incr; |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
consume_each (ii); |
|
| 91 |
|
|
| 92 |
return noutput_items; |
|
| 93 |
} |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004,2007 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 |
#ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H |
|
| 24 |
#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H |
|
| 25 |
|
|
| 26 |
#include <gr_block.h> |
|
| 27 |
|
|
| 28 |
class gri_mmse_fir_interpolator; |
|
| 29 |
|
|
| 30 |
class gr_fractional_interpolator_ff; |
|
| 31 |
typedef boost::shared_ptr<gr_fractional_interpolator_ff> gr_fractional_interpolator_ff_sptr; |
|
| 32 |
|
|
| 33 |
// public constructor |
|
| 34 |
gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); |
|
| 35 |
|
|
| 36 |
/*! |
|
| 37 |
* \brief Interpolating mmse filter with float input, float output |
|
| 38 |
* \ingroup filter |
|
| 39 |
*/ |
|
| 40 |
class gr_fractional_interpolator_ff : public gr_block |
|
| 41 |
{
|
|
| 42 |
public: |
|
| 43 |
~gr_fractional_interpolator_ff (); |
|
| 44 |
void forecast(int noutput_items, gr_vector_int &ninput_items_required); |
|
| 45 |
int general_work (int noutput_items, |
|
| 46 |
gr_vector_int &ninput_items, |
|
| 47 |
gr_vector_const_void_star &input_items, |
|
| 48 |
gr_vector_void_star &output_items); |
|
| 49 |
|
|
| 50 |
float mu() const { return d_mu;}
|
|
| 51 |
float interp_ratio() const { return d_mu_inc;}
|
|
| 52 |
void set_mu (float mu) { d_mu = mu; }
|
|
| 53 |
void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; }
|
|
| 54 |
|
|
| 55 |
protected: |
|
| 56 |
gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); |
|
| 57 |
|
|
| 58 |
private: |
|
| 59 |
float d_mu; |
|
| 60 |
float d_mu_inc; |
|
| 61 |
gri_mmse_fir_interpolator *d_interp; |
|
| 62 |
|
|
| 63 |
friend gr_fractional_interpolator_ff_sptr |
|
| 64 |
gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); |
|
| 65 |
}; |
|
| 66 |
|
|
| 67 |
#endif |
|
| b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2007 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 |
GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_ff); |
|
| 24 |
|
|
| 25 |
gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); |
|
| 26 |
|
|
| 27 |
class gr_fractional_interpolator_ff : public gr_block |
|
| 28 |
{
|
|
| 29 |
private: |
|
| 30 |
gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); |
|
| 31 |
|
|
| 32 |
public: |
|
| 33 |
float mu() const; |
|
| 34 |
float interp_ratio() const; |
|
| 35 |
void set_mu (float mu); |
|
| 36 |
void set_interp_ratio (float interp_ratio); |
|
| 37 |
}; |
|
| b/gnuradio-core/src/python/gnuradio/gr/Makefile.am | ||
|---|---|---|
| 60 | 60 |
qa_fft_filter.py \ |
| 61 | 61 |
qa_filter_delay_fc.py \ |
| 62 | 62 |
qa_flow_graph.py \ |
| 63 |
qa_fractional_interpolator.py \ |
|
| 63 | 64 |
qa_frequency_modulator.py \ |
| 64 | 65 |
qa_fsk_stuff.py \ |
| 65 | 66 |
qa_goertzel.py \ |
| b/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py | ||
|---|---|---|
| 1 |
#!/usr/bin/env python |
|
| 2 |
# |
|
| 3 |
# Copyright 2007 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 |
from gnuradio import gr, gr_unittest |
|
| 24 |
|
|
| 25 |
class test_fractional_resampler (gr_unittest.TestCase): |
|
| 26 |
|
|
| 27 |
def setUp(self): |
|
| 28 |
self.fg = gr.flow_graph() |
|
| 29 |
|
|
| 30 |
def tearDown(self): |
|
| 31 |
self.fg = None |
|
| 32 |
|
|
| 33 |
def test_000_make(self): |
|
| 34 |
op = gr.fractional_interpolator_ff(0.0, 1.0) |
|
| 35 |
op2 = gr.fractional_interpolator_cc(0.0, 1.0) |
|
| 36 |
|
|
| 37 |
if __name__ == '__main__': |
|
| 38 |
gr_unittest.main() |
|
| 39 |
|
|
Also available in: Unified diff