23 #ifndef INCLUDED_ANALOG_AGC2_H
24 #define INCLUDED_ANALOG_AGC2_H
53 agc2_cc(
float attack_rate = 1e-1,
float decay_rate = 1e-2,
54 float reference = 1.0,
55 float gain = 1.0,
float max_gain = 0.0)
56 : _attack_rate(attack_rate), _decay_rate(decay_rate),
57 _reference(reference),
58 _gain(gain), _max_gain(max_gain) {};
63 float gain()
const {
return _gain; }
76 float tmp = -_reference + sqrt(output.real()*output.real() +
77 output.imag()*output.imag());
78 float rate = _decay_rate;
89 if(_max_gain > 0.0 && _gain > _max_gain) {
97 for(
unsigned i = 0; i < n; i++)
98 output[i] = scale (input[i]);
122 agc2_ff(
float attack_rate = 1e-1,
float decay_rate = 1e-2,
123 float reference = 1.0,
124 float gain = 1.0,
float max_gain = 0.0)
125 : _attack_rate(attack_rate), _decay_rate(decay_rate),
126 _reference(reference),
127 _gain(gain), _max_gain(max_gain) {};
132 float gain()
const {
return _gain; }
143 float output = input * _gain;
145 float tmp = (fabsf(output)) - _reference;
146 float rate = _decay_rate;
147 if(fabsf(tmp) > _gain) {
156 if(_max_gain > 0.0 && _gain > _max_gain) {
162 void scaleN(
float output[],
const float input[],
unsigned n)
164 for(
unsigned i = 0; i < n; i++)
165 output[i] = scale (input[i]);
void set_reference(float reference)
Definition: agc2.h:68
float _attack_rate
Definition: agc2.h:102
void set_attack_rate(float rate)
Definition: agc2.h:67
float reference() const
Definition: agc2.h:131
float _reference
Definition: agc2.h:171
high performance Automatic Gain Control class
Definition: agc2.h:41
float attack_rate() const
Definition: agc2.h:129
void set_attack_rate(float rate)
Definition: agc2.h:135
gr_complex scale(gr_complex input)
Definition: agc2.h:72
float max_gain() const
Definition: agc2.h:64
void set_reference(float reference)
Definition: agc2.h:137
void set_gain(float gain)
Definition: agc2.h:69
float reference() const
Definition: agc2.h:62
float _gain
Definition: agc2.h:172
std::complex< float > gr_complex
Definition: gr_complex.h:27
float _decay_rate
Definition: agc2.h:103
float _decay_rate
Definition: agc2.h:170
void set_decay_rate(float rate)
Definition: agc2.h:136
float _max_gain
Definition: agc2.h:106
float gain() const
Definition: agc2.h:63
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:122
float scale(float input)
Definition: agc2.h:141
float _max_gain
Definition: agc2.h:173
float max_gain() const
Definition: agc2.h:133
void scaleN(gr_complex output[], const gr_complex input[], unsigned n)
Definition: agc2.h:95
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:53
void set_max_gain(float max_gain)
Definition: agc2.h:70
float _attack_rate
Definition: agc2.h:169
void set_decay_rate(float rate)
Definition: agc2.h:66
void scaleN(float output[], const float input[], unsigned n)
Definition: agc2.h:162
float _gain
Definition: agc2.h:105
void set_max_gain(float max_gain)
Definition: agc2.h:139
float attack_rate() const
Definition: agc2.h:61
float decay_rate() const
Definition: agc2.h:60
#define ANALOG_API
Definition: gr-analog/include/gnuradio/analog/api.h:30
float _reference
Definition: agc2.h:104
void set_gain(float gain)
Definition: agc2.h:138
float decay_rate() const
Definition: agc2.h:130
float gain() const
Definition: agc2.h:132