11#ifndef INCLUDED_ANALOG_AGC2_H
12#define INCLUDED_ANALOG_AGC2_H
42 float decay_rate = 1e-2,
43 float reference = 1.0,
46 : _attack_rate(attack_rate),
47 _decay_rate(decay_rate),
48 _reference(reference),
50 _max_gain(max_gain){};
55 float gain()
const {
return _gain; }
68 float tmp = -_reference +
69 sqrt(output.real() * output.real() + output.imag() * output.imag());
70 float rate = _decay_rate;
81 if (_max_gain > 0.0 && _gain > _max_gain) {
89 for (
unsigned i = 0; i < n; i++)
90 output[i] = scale(input[i]);
115 float decay_rate = 1e-2,
116 float reference = 1.0,
118 float max_gain = 0.0)
119 : _attack_rate(attack_rate),
120 _decay_rate(decay_rate),
121 _reference(reference),
123 _max_gain(max_gain){};
128 float gain()
const {
return _gain; }
139 float output = input * _gain;
141 float tmp = (fabsf(output)) - _reference;
142 float rate = _decay_rate;
143 if (fabsf(tmp) > _gain) {
152 if (_max_gain > 0.0 && _gain > _max_gain) {
158 void scaleN(
float output[],
const float input[],
unsigned n)
160 for (
unsigned i = 0; i < n; i++)
161 output[i] = scale(input[i]);
high performance Automatic Gain Control class
Definition: agc2.h:30
float gain() const
Definition: agc2.h:55
void set_gain(float gain)
Definition: agc2.h:61
float _attack_rate
Definition: agc2.h:94
void set_attack_rate(float rate)
Definition: agc2.h:59
void set_decay_rate(float rate)
Definition: agc2.h:58
float _reference
Definition: agc2.h:96
agc2_cc(float attack_rate=1e-1, float decay_rate=1e-2, float reference=1.0, float gain=1.0, float max_gain=0.0)
Definition: agc2.h:41
gr_complex scale(gr_complex input)
Definition: agc2.h:64
void scaleN(gr_complex output[], const gr_complex input[], unsigned n)
Definition: agc2.h:87
float _gain
Definition: agc2.h:97
float reference() const
Definition: agc2.h:54
void set_max_gain(float max_gain)
Definition: agc2.h:62
float _decay_rate
Definition: agc2.h:95
void set_reference(float reference)
Definition: agc2.h:60
float max_gain() const
Definition: agc2.h:56
float decay_rate() const
Definition: agc2.h:52
float _max_gain
Definition: agc2.h:98
float attack_rate() const
Definition: agc2.h:53
float _attack_rate
Definition: agc2.h:165
void set_decay_rate(float rate)
Definition: agc2.h:132
float _decay_rate
Definition: agc2.h:166
float scale(float input)
Definition: agc2.h:137
void set_reference(float reference)
Definition: agc2.h:133
void scaleN(float output[], const float input[], unsigned n)
Definition: agc2.h:158
float _gain
Definition: agc2.h:168
agc2_ff(float attack_rate=1e-1, float decay_rate=1e-2, float reference=1.0, float gain=1.0, float max_gain=0.0)
Definition: agc2.h:114
void set_attack_rate(float rate)
Definition: agc2.h:131
float _reference
Definition: agc2.h:167
float reference() const
Definition: agc2.h:127
void set_max_gain(float max_gain)
Definition: agc2.h:135
void set_gain(float gain)
Definition: agc2.h:134
float attack_rate() const
Definition: agc2.h:125
float max_gain() const
Definition: agc2.h:129
float _max_gain
Definition: agc2.h:169
float gain() const
Definition: agc2.h:128
float decay_rate() const
Definition: agc2.h:126
#define ANALOG_API
Definition: gr-analog/include/gnuradio/analog/api.h:18
std::complex< float > gr_complex
Definition: gr_complex.h:15
GNU Radio logging wrapper.
Definition: basic_block.h:29