1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009,2012 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 #ifndef INCLUDED_CHANNELS_CFO_MODEL_IMPL_H
24 #define INCLUDED_CHANNELS_CFO_MODEL_IMPL_H
25 
26 #include "sincostable.h"
27 #include <gnuradio/analog/fastnoise_source.h>
28 #include <gnuradio/blocks/integrate.h>
29 #include <gnuradio/blocks/multiply.h>
30 #include <gnuradio/blocks/vco_c.h>
31 #include <gnuradio/channels/cfo_model.h>
32 #include <gnuradio/top_block.h>
33 
34 namespace gr {
35 namespace channels {
36 
37 class CHANNELS_API cfo_model_impl : public cfo_model
38 {
39 private:
40     double d_samp_rate;
41     double d_std_dev_hz;
42     double d_max_dev_hz;
43     sincostable d_table;
44     gr::analog::fastnoise_source_f::sptr d_noise;
45     double d_cfo;
46     float d_angle;
47     double d_noise_seed;
48 
49 public:
50     cfo_model_impl(double sample_rate_hz,
51                    double std_dev_hz,
52                    double max_dev_hz,
53                    double noise_seed = 0);
54 
55     ~cfo_model_impl();
56     void setup_rpc();
57     int work(int, gr_vector_const_void_star&, gr_vector_void_star&);
58 
set_std_dev(double _dev)59     void set_std_dev(double _dev)
60     {
61         d_std_dev_hz = _dev;
62         d_noise = gr::analog::fastnoise_source_f::make(
63             analog::GR_GAUSSIAN, d_std_dev_hz, d_noise_seed);
64     }
set_max_dev(double _dev)65     void set_max_dev(double _dev) { d_max_dev_hz = _dev; }
set_samp_rate(double _rate)66     void set_samp_rate(double _rate) { d_samp_rate = _rate; }
67 
std_dev()68     double std_dev() const { return d_std_dev_hz; }
max_dev()69     double max_dev() const { return d_max_dev_hz; }
samp_rate()70     double samp_rate() const { return d_samp_rate; }
71 };
72 
73 } /* namespace channels */
74 } /* namespace gr */
75 
76 #endif /* INCLUDED_CHANNELS_CFO_MODEL_IMPL_H */
77