class sdr.AGC

Implements an automatic gain controller (AGC).

Notes

Automatic Gain Control Block Diagram
x[n] -->X---------------------------------------------------------------------+--> y[n]
        ^                                                                     |
        |                                                                     |
    +--------+      +------+                     -1  +--------+   +-------+   |
    | exp(.) |<--+--| z^-1 |<--@<---X<--------@<-----| log(.) |<--|  |.|  |<--+
    +--------+   |  +------+   ^   alpha    log(R)   +--------+   +-------+
                 |             |  or beta
                 +-------------+

x[n] = Input signal
y[n] = Output signal
alpha = Attack rate
beta = Decay rate
R = Reference magnitude
@ = Adder
X = Multiplier

References

Examples

Create an example received signal with two bursty signals surrounded by noise.

In [1]: x = np.exp(1j * 2 * np.pi * np.arange(5000) / 100); \
   ...: x[0:1000] *= 0; \
   ...: x[1000:2000] *= 10; \
   ...: x[2000:3000] *= 0; \
   ...: x[3000:4000] *= 0.1; \
   ...: x[4000:5000] *= 0
   ...: 

In [2]: x += 0.001 * (np.random.randn(x.size) + 1j * np.random.randn(x.size))

In [3]: plt.figure(); \
   ...: sdr.plot.time_domain(x); \
   ...: plt.title("Input signal");
   ...: 
../../_images/sdr_AGC_1.png

Create an AGC with an attack rate of \(\alpha = 0.5\) and a decay rate of \(\beta = 0.01\). Notice that over time the noise is amplified (according to the decay rate). Also notice that when the signal of interest appears the AGC gain is quickly decreased (according to the attack rate).

In [4]: agc = sdr.AGC(0.5, 0.01)

In [5]: y = agc(x)

In [6]: plt.figure(); \
   ...: sdr.plot.time_domain(y); \
   ...: plt.ylim(-1.5, 1.5); \
   ...: plt.title("Output signal");
   ...: 
../../_images/sdr_AGC_2.png

Constructors

AGC(attack: float, decay: float, reference: float = 1.0, ...)

Creates an automatic gain controller (AGC).

Special methods

__call__(x: ArrayLike) NDArray[complex128]

Performs automatic gain control on the input signal.

Streaming mode only

reset(gain: float = 1.0)

Resets the AGC gain. Only useful when using streaming mode.

property streaming : bool

Indicates whether the AGC is in streaming mode.

property gain : float

The current linear gain.

Properties

property attack : float

(Settable) The attack rate \(\alpha\).

property decay : float

(Settable) The decay rate \(\beta\).

property reference : float

(Settable) The desired output magnitude.