classdef AGC< matlab.System
% AGC Automatic gain controller
%   AGC1 = audioexample.AGC creates an automatic gain controller (AGC)
%   System object, AGC1, that adaptively adjusts its gain to achieve a
%   constant signal level at the output.
%
%   AGC1 = audioexample.AGC(Name,Value) creates an AGC object, AGC1,
%   with the specified property Name set to the specified Value. You
%   can specify additional name-value pair arguments in any order as
%   (Name1,Value1,...,NameN,ValueN).
%
%   Step method syntax:
%
%   Y = step(AGC1, X) applies an adaptive gain to the input X, to
%   achieve average output power level specified by the
%   DesiredOutputPower property. X must be a double-precision or
%   single-precision real column vector.
% 
%   [Y,G] = step(AGC1, X) returns the gain, G, applied to the input in
%   X.
%
%   [Y,G,P] = step(AGC1, X) returns the power level estimate, P, of
%   input X. You can use P as an energy detector output. P is in units
%   of Watts, referenced to 1 Ohm.
%
%   AGC methods:
%
%   step     - Apply adaptive gain to input signal (see above)
%   release  - Allow property value and input characteristics changes
%   clone    - Create AGC object with same property values
%   isLocked - Locked status (logical)
%   <a href="matlab:help matlab.System/reset   ">reset</a>    - Reset states of AGC object
%
%   AGC properties:
%
%   AdaptationStepSize - Step size for gain updates
%   DesiredOutputPower - Desired output power (dB)
%   AveragingLength    - Averaging length
%   MaxPowerGain       - Maximum power gain (dB)

   
    %   Copyright 2016-2019 The MathWorks, Inc.

    methods
        function out=AGC
        end

        function out=processTunedPropertiesImpl(~) %#ok<STOUT>
            % Cast to correct data type
        end

        function out=resetImpl(~) %#ok<STOUT>
        end

        function out=resetStates(~) %#ok<STOUT>
        end

        function out=setupImpl(~) %#ok<STOUT>
        end

        function out=stepImpl(~) %#ok<STOUT>
        end

        function out=validateInputsImpl(~) %#ok<STOUT>
        end

    end
    properties
        %AdaptationStepSize Step size
        %   Specify the step size for gain updates as a double-precision or
        %   single-precision real positive scalar. The default is 0.01. If
        %   you increase the step size, AGC responds to changes at the
        %   input signal level faster. However, gain pumping also
        %   increases. This property is tunable.
        AdaptationStepSize;

        %AveragingLength Averaging length
        %   Specify the length of the averaging filter as a positive
        %   integer-valued scalar. The default is 100. The averaging filter
        %   approximates the expected value operation. Increase the
        %   AveragingLength to reduce gain pumping for higher amplitude
        %   values. Note that increasing the averaging window length slows
        %   down the processing speed.
        AveragingLength;

        %DesiredOutputPower Desired output power (dB)
        %   Specify the desired output power level referenced to 1 Ohm in
        %   dB as a scalar. The default is 0. The AGC sets the variable
        %   gain such that E(y.^2) is equal to the desired output power in
        %   Watts, where y is the output signal and E() is the expected
        %   value. This property is tunable.
        DesiredOutputPower;

        %MaxPowerGain Maximum power gain (dB)
        %   Specify the maximum power gain of the AGC in dB as a real
        %   numeric scalar. The default is 60. If the noise only part of
        %   the signal has a very low level, the AGC gain may increase
        %   rapidly. When the desired signal packet arrives, the AGC may
        %   take a long time to converge.
        %
        %   Set this property to a value that is large enough to provide
        %   sufficient gain to reach the DesiredOutputPower when the input
        %   signal power is low and also small enough to minimize
        %   convergence time for high SNR signals.
        MaxPowerGain;

    end
end
