GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
throttle.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005-2011,2013 Free Software Foundation, Inc.
4  * Copyright 2021 Marcus Müller
5  *
6  * This file is part of GNU Radio
7  *
8  * SPDX-License-Identifier: GPL-3.0-or-later
9  *
10  */
11 
12 #ifndef INCLUDED_GR_THROTTLE_H
13 #define INCLUDED_GR_THROTTLE_H
14 
15 #include <gnuradio/blocks/api.h>
16 #include <gnuradio/sync_block.h>
17 
18 namespace gr {
19 namespace blocks {
20 
21 /*!
22  * \brief throttle flow of samples such that the average rate does
23  * not exceed samples_per_sec.
24  * \ingroup misc_blk
25  *
26  * \details
27  * input: one stream of itemsize; output: one stream of itemsize
28  *
29  * N.B. this should only be used in GUI apps where there is no
30  * other rate limiting block. It is not intended nor effective at
31  * precisely controlling the rate of samples. That should be
32  * controlled by a source or sink tied to sample clock. E.g., a
33  * USRP or audio card.
34  *
35  * You can insert this block "in series" with your sample flow, in which case it does a
36  * throttled copy of input to output. Alternatively, you can not connect its output and
37  * just connect this block's input in parallel to an existing block in your flow graph. In
38  * that case, Throttle will limit the rate at which samples are consumed; especially at
39  * higher rates, where the copying overhead might be significant, this is functionally not
40  * different to copying at a limited rate.
41  */
42 class BLOCKS_API throttle : virtual public sync_block
43 {
44 public:
45  typedef std::shared_ptr<throttle> sptr;
46 
47  static sptr make(size_t itemsize, double samples_per_sec, bool ignore_tags = true);
48 
49  //! Sets the sample rate in samples per second.
50  virtual void set_sample_rate(double rate) = 0;
51 
52  //! Get the sample rate in samples per second.
53  virtual double sample_rate() const = 0;
54 };
55 
56 } /* namespace blocks */
57 } /* namespace gr */
58 
59 #endif /* INCLUDED_GR_THROTTLE_H */
throttle flow of samples such that the average rate does not exceed samples_per_sec.
Definition: throttle.h:43
virtual double sample_rate() const =0
Get the sample rate in samples per second.
virtual void set_sample_rate(double rate)=0
Sets the sample rate in samples per second.
static sptr make(size_t itemsize, double samples_per_sec, bool ignore_tags=true)
std::shared_ptr< throttle > sptr
Definition: throttle.h:45
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
BLOCKS_API size_t itemsize(vector_type type)
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29