function HarmOut = harmoniser(x, maxlevel)
               %%%% Simple harmoniser by M.Bechara %%%%
% Input arguments x for input signal, sv for square value, maxlevel for
% normalisation
%Determine channel size for mono stereo slit processing
maxlevel_amplitude = db2mag(maxlevel);
[~, channels] = size(x);
if channels == 1;
    
        % a = abs(x); % Full-Wave
        a = (abs(x) + x) ./ 2;  % Half-Wave
% a = pgain .* a;
    Hmaxlevel = max(a);
    HarmOut = a ./(Hmaxlevel ./maxlevel_amplitude);
    
     
  
elseif channels == 2;
    LeftInput = x(:,1);
    RightInput = x(:,2);
    aL = (abs(LeftInput) + LeftInput) ./ 2;
    aR = (abs(RightInput) + RightInput) ./ 2;
  %aL = pgain .* aL;
 % aR = pgain .* aR;
     HmaxlevelL = max(aL);
         HarmOutL =aL ./(HmaxlevelL ./maxlevel_amplitude);
        
          HmaxlevelR = max(aR);
         HarmOutR = aR ./(HmaxlevelR ./maxlevel_amplitude);
    
    HarmOut = [HarmOutL, HarmOutR];
   
    
end