GNU Radio Manual and C++ API Reference 3.10.5.1
The Free & Open Software Radio Ecosystem
moving_average.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2008,2013,2017,2018 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11
12#ifndef MOVING_AVERAGE_H
13#define MOVING_AVERAGE_H
14
15#include <gnuradio/blocks/api.h>
16#include <gnuradio/sync_block.h>
17#include <cstdint>
18
19namespace gr {
20namespace blocks {
21
22/*!
23 * \brief output is the moving sum of the last N samples, scaled by the scale factor
24 * \ingroup level_controllers_blk
25 */
26template <class T>
27class BLOCKS_API moving_average : virtual public sync_block
28{
29public:
30 // gr::blocks::moving_average::sptr
31 typedef std::shared_ptr<moving_average<T>> sptr;
32
33 /*!
34 * Create a moving average block.
35 *
36 * \param length Number of samples to use in the average.
37 * \param scale scale factor for the result.
38 * \param max_iter limits how long we go without flushing the accumulator
39 * This is necessary to avoid numerical instability for float and complex.
40 * \param vlen When > 1, do a per-vector-element moving average
41 */
42 static sptr make(int length, T scale, int max_iter = 4096, unsigned int vlen = 1);
43
44 /*!
45 * Get the length used in the avaraging calculation.
46 */
47 virtual int length() const = 0;
48
49 /*!
50 * Get the scale factor being used.
51 */
52 virtual T scale() const = 0;
53
54 /*!
55 * Set both the length and the scale factor together.
56 */
57 virtual void set_length_and_scale(int length, T scale) = 0;
58
59 /*!
60 * Set the length.
61 */
62 virtual void set_length(int length) = 0;
63
64 /*!
65 * Set the scale factor.
66 */
67 virtual void set_scale(T scale) = 0;
68};
69
74} /* namespace blocks */
75} /* namespace gr */
76
77#endif /* MOVING_AVERAGE_H */
output is the moving sum of the last N samples, scaled by the scale factor
Definition: moving_average.h:28
std::shared_ptr< moving_average< T > > sptr
Definition: moving_average.h:31
virtual void set_length_and_scale(int length, T scale)=0
virtual int length() const =0
virtual void set_length(int length)=0
static sptr make(int length, T scale, int max_iter=4096, unsigned int vlen=1)
virtual void set_scale(T scale)=0
virtual T scale() const =0
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
moving_average< std::int32_t > moving_average_ii
Definition: moving_average.h:71
moving_average< gr_complex > moving_average_cc
Definition: moving_average.h:73
moving_average< float > moving_average_ff
Definition: moving_average.h:72
moving_average< std::int16_t > moving_average_ss
Definition: moving_average.h:70
GNU Radio logging wrapper.
Definition: basic_block.h:29
PMT_API size_t length(const pmt_t &v)
Return the number of elements in v.