gr-baz Package
baz_correlator.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2013 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 /*
24  * gr-baz by Balint Seeber (http://spench.net/contact)
25  * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
26  */
27 
28 #ifndef INCLUDED_BAZ_CORRELATOR_H
29 #define INCLUDED_BAZ_CORRELATOR_H
30 
31 #include <gnuradio/sync_block.h>
32 
34 
35 /*
36  * We use boost::shared_ptr's instead of raw pointers for all access
37  * to gr::blocks (and many other data structures). The shared_ptr gets
38  * us transparent reference counting, which greatly simplifies storage
39  * management issues. This is especially helpful in our hybrid
40  * C++ / Python system.
41  *
42  * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
43  *
44  * As a convention, the _sptr suffix indicates a boost::shared_ptr
45  */
46 typedef boost::shared_ptr<baz_correlator> baz_correlator_sptr;
47 
48 /*!
49  * \brief Return a shared_ptr to a new instance of baz_correlator.
50  *
51  * To avoid accidental use of raw pointers, baz_correlator's
52  * constructor is private. baz_make_correlator is the public
53  * interface for creating new instances.
54  */
55 BAZ_API baz_correlator_sptr baz_make_correlator (
56  float samp_rate,
57  float symbol_rate,
58  int window_length,
59  float threshold=0.5,
60  int width=1024,
61  const char* sync_path="sync.dat",
62  int sync_length=511,
63  int sync_offset=50,
64  //sync_dtype='c8',
65  int sync_window_length=500
66 );
67 
68 /*!
69  * \brief square2 a stream of floats.
70  * \ingroup block
71  *
72  * This uses the preferred technique: subclassing gr::sync_block.
73  */
74 class BAZ_API baz_correlator : public gr::block
75 {
76 private:
77  // The friend declaration allows baz_make_correlator To
78  // access the private constructor.
79 
80  friend BAZ_API baz_correlator_sptr baz_make_correlator(
81  float samp_rate,
82  float symbol_rate,
83  int window_length,
84  float threshold,
85  int width,
86  const char* sync_path,
87  int sync_length,
88  int sync_offset,
89  //sync_dtype='c8',
90  int sync_window_length
91  );
92 
94  float samp_rate,
95  float symbol_rate,
96  int window_length,
97  float threshold,
98  int width,
99  const char* sync_path,
100  int sync_length,
101  int sync_offset,
102  //sync_dtype='c8',
103  int sync_window_length
104 ); // private constructor
105 
106  float d_samp_rate;
107  float d_symbol_rate;
108  int d_window_length;
109  float d_threshold;
110  int d_width;
111  //const char* sync_path;
112  //int sync_length;
113  //int sync_offset;
114  //sync_dtype='c8',
115  int d_sync_window_length;
116 
117  std::vector<std::complex<float> > d_sync;
118  bool d_synced;
119  int64_t d_next_window_idx;
120  int64_t d_current_idx;
121  std::vector<std::complex<float> > d_conjmul_result;
122  //std::vector<float> d_abs_result;
123  float d_max_peak;
124  int d_max_peak_idx;
125  int d_sync_window_idx;
126  int d_current_item_idx;
127 
128  std::complex<float> correlate(const std::complex<float>* in, const std::complex<float>* sync);
129 
130 public:
131  ~baz_correlator(); // public destructor
132 
133  //
134 
135  //void forecast(int noutput_items, gr_vector_int &ninput_items_required);
136  int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
137 };
138 
139 #endif /* INCLUDED_BAZ_CORRELATOR_H */
BAZ_API baz_correlator_sptr baz_make_correlator(float samp_rate, float symbol_rate, int window_length, float threshold=0.5, int width=1024, const char *sync_path="sync.dat", int sync_length=511, int sync_offset=50, int sync_window_length=500)
Return a shared_ptr to a new instance of baz_correlator.
class BAZ_API baz_correlator
Definition: baz_correlator.h:33
#define BAZ_API
Definition: config.h:8
square2 a stream of floats.This uses the preferred technique: subclassing gr::sync_block.
Definition: baz_correlator.h:74