gr-baz Package
baz_peak_detector.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
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_PEAK_DETECTOR_H
29#define INCLUDED_BAZ_PEAK_DETECTOR_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 */
46typedef boost::shared_ptr<baz_peak_detector> baz_peak_detector_sptr;
47
48/*!
49 * \brief Return a shared_ptr to a new instance of baz_peak_detector.
50 *
51 * To avoid accidental use of raw pointers, baz_peak_detector's
52 * constructor is private. howto_make_square2_ff is the public
53 * interface for creating new instances.
54 */
55BAZ_API baz_peak_detector_sptr baz_make_peak_detector (float min_diff = 0.0, int min_len = 1, int lockout = 0, float drop = 0.0, float alpha = 1.0, int look_ahead = 0, bool byte_output = false, bool verbose = false);
56
57/*!
58 * \brief square2 a stream of floats.
59 * \ingroup block
60 *
61 * This uses the preferred technique: subclassing gr::sync_block.
62 */
63class BAZ_API baz_peak_detector : public gr::block
64{
65private:
66 // The friend declaration allows howto_make_square2_ff to
67 // access the private constructor.
68
69 friend BAZ_API baz_peak_detector_sptr baz_make_peak_detector (float min_diff, int min_len, int lockout, float drop, float alpha, int look_ahead, bool byte_output, bool verbose);
70
71 baz_peak_detector(float min_diff, int min_len, int lockout, float drop, float alpha, int look_ahead, bool byte_output, bool verbose); // private constructor
72
73 float d_min_diff;
74 int d_min_len;
75 int d_lockout;
76 float d_drop;
77 float d_alpha;
78 int d_look_ahead;
79 volatile bool d_threshold_set;
80 float d_threshold;
81 bool d_byte_output;
82
83 bool d_rising;
84 int d_rise_count;
85 int d_lockout_count;
86 float d_first;
87 float d_ave;
88 float d_peak;
89 int d_peak_idx;
90 int d_look_ahead_count;
91 int d_advance;
92 bool d_verbose;
93 int64_t d_last_peak_idx;
94
95 public:
96 ~baz_peak_detector (); // public destructor
97
98 void set_threshold(float threshold);
100
101 inline float threshold() const
102 { return d_threshold; }
103
104 inline float threshold_set() const
105 { return d_threshold_set; }
106
107 //int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
108
109 void forecast(int noutput_items, gr_vector_int &ninput_items_required);
110 int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
111};
112
113#endif /* INCLUDED_BAZ_PEAK_DETECTOR_H */
#define BAZ_API
Definition: api.h:19
BAZ_API baz_peak_detector_sptr baz_make_peak_detector(float min_diff=0.0, int min_len=1, int lockout=0, float drop=0.0, float alpha=1.0, int look_ahead=0, bool byte_output=false, bool verbose=false)
Return a shared_ptr to a new instance of baz_peak_detector.
class BAZ_API baz_peak_detector
Definition: baz_peak_detector.h:33
square2 a stream of floats.
Definition: baz_peak_detector.h:64
friend BAZ_API baz_peak_detector_sptr baz_make_peak_detector(float min_diff, int min_len, int lockout, float drop, float alpha, int look_ahead, bool byte_output, bool verbose)
Return a shared_ptr to a new instance of baz_peak_detector.
float threshold() const
Definition: baz_peak_detector.h:101
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
float threshold_set() const
Definition: baz_peak_detector.h:104
void set_threshold(float threshold)