GNU Radio's DAB Package
dab_ofdm_ffs_sample.h
Go to the documentation of this file.
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 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 #ifndef INCLUDED_DAB_OFDM_FFS_SAMPLE_H
23 #define INCLUDED_DAB_OFDM_FFS_SAMPLE_H
24 
25 #include <gr_sync_block.h>
26 
28 
29 typedef boost::shared_ptr<dab_ofdm_ffs_sample> dab_ofdm_ffs_sample_sptr;
30 
31 dab_ofdm_ffs_sample_sptr dab_make_ofdm_ffs_sample (unsigned int symbol_length, unsigned int fft_length, unsigned int num_symbols, float alpha, unsigned int sample_rate);
32 
33 /*!
34  * \brief samples FFS error estimation at the correct time and averages it
35  * \ingroup DAB
36  * \param symbol_length number of samples in an OFDM symbol
37  * \param fft_length number of samples in an OFDM symbol without the cyclic prefix
38  * \param num_symbols number of symbols to use for averaging (more symbols is better, but symbols towards the end of the frame tend to have larger time offsets and worse values)
39  * \param alpha how fast should we adapt to new FFS error values (1=immediately)
40  * \param sample_rate sampling rate - needed to calculate the offset estimation in Hz
41  *
42  * input: port 0: float - actual data; port 1: byte - trigger signal indicating the start of a frame
43  * output: float fine frequency offset estimation (in radian per sample)
44  */
45 class dab_ofdm_ffs_sample : public gr_sync_block
46 {
47  private:
48  // The friend declaration allows dab_make_ofdm_ffs_sample to
49  // access the private constructor.
50 
51  friend dab_ofdm_ffs_sample_sptr dab_make_ofdm_ffs_sample (unsigned int symbol_length, unsigned int fft_length, unsigned int num_symbols, float alpha, unsigned int sample_rate);
52 
53  dab_ofdm_ffs_sample (unsigned int symbol_length, unsigned int fft_length, unsigned int num_symbols, float alpha, unsigned int sample_rate); // private constructor
54 
55  unsigned int d_symbol_length; // length of a symbol in samples
56  unsigned int d_fft_length; // length of a symbol without cyclic prefix in samples
57  unsigned int d_num_symbols; // number of symbols per frame to average over
58  float d_alpha; // adjustment speed factor
59  unsigned int d_sample_rate; // sample rate -- only needed to print the ffs error in Hz
60 
61  unsigned int d_cur_symbol; // which symbol in the frame is currently under observation?
62  unsigned int d_cur_sample; // which sample in the symbol is currently under observation?
63  float d_ffs_error_sum; // sum of error samples in current frame
64  float d_estimated_error; // total estimated error
65  float d_estimated_error_per_sample; // total estimated error / fft_length
66 
67  public:
68  /*! \return fine frequency error estimate in Hz */
69  float ffe_estimate() { return d_estimated_error_per_sample*d_sample_rate/(2*M_PI); }
70  int work (int noutput_items,
71  gr_vector_const_void_star &input_items,
72  gr_vector_void_star &output_items);
73 };
74 
75 #endif /* INCLUDED_DAB_OFDM_FFS_SAMPLE_H */
dab_ofdm_ffs_sample::work
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
dab_ofdm_ffs_sample::dab_make_ofdm_ffs_sample
friend dab_ofdm_ffs_sample_sptr dab_make_ofdm_ffs_sample(unsigned int symbol_length, unsigned int fft_length, unsigned int num_symbols, float alpha, unsigned int sample_rate)
dab_make_ofdm_ffs_sample
dab_ofdm_ffs_sample_sptr dab_make_ofdm_ffs_sample(unsigned int symbol_length, unsigned int fft_length, unsigned int num_symbols, float alpha, unsigned int sample_rate)
dab_ofdm_ffs_sample
samples FFS error estimation at the correct time and averages it
Definition: dab_ofdm_ffs_sample.h:46
dab_ofdm_ffs_sample::ffe_estimate
float ffe_estimate()
Definition: dab_ofdm_ffs_sample.h:69