To make necessary signal processing easier, signal power level should be as high as possible. However information may be represented by up to 8 bits and when amplitude exceeds 28 (256), clipping occurs and the information is lost. To avoid volatility of signal power caused by radio propagation phenomena (multipath fading, Doppler shift etc.) antenna gain must be changed when it is essential. AGC (Automatic Gain Control) increases or decreases antenna gain when signal amplitude is not satisfactory. Adaptive algorithm cooperates with each device supported by rtl-sdr.
There are two thresholds: fixed (equals 127 and -127), which informs whether clipping has occurred and adaptive one:
almost_thershold, which is responsible for receiving with highest possible antenna gain and algorithm’s stability. When clipping is detected, gain is decremented and
almost_threshold is set to where
i means current index. The goal is to keep signal amplitude between
almost_threshold and maximum/minimum possible value. If there are no more than few samples (per 100k) between
almost_threshold and max/min, gain is incremented and
almost_threshold is set to . This hysteresis loop between and guarantees algorithm’s stability.