Digital Automatic Gain Control Algorithm