function output = invtan2(input, gain, mix)
numrows = size(input);

if numrows(:,2) == 2
    inputL = input(:,1);
    inputR = input(:,2);
  
    %Left processing
    aL = atan2(gain*inputL, inputL);
    outputL = aL*mix + inputL*(1-mix);
    %cL = max(abs(outputL));
    %outputL = outputL/cL;

    %Right Processing
    aR = atan2(gain*inputR, inputR);
    outputR = aR*mix + inputR*(1-mix);
    %cR = max(abs(outputR));
    %outputR = outputR/cR;

    %Summing
    output = [outputL,outputR];
elseif numrows(:,2) == 1
    a  = atan2(gain*input, input);
    output = a*mix + input*(1-mix);
    %c = max(abs(outputL));
    %output = output/c;
end