function  LTg = globalth(LTq, LTt, LTn)
%LTg = Global_masking_threshold(LTq, LTt, LTn)
%
%   Compute the global masking threshold for the subset of frequency lines 
%   defined in table [1, pp. 117]. It is the sum -- in the normal square
%   amplitude scale of the spectrum -- of the individual masking
%   thresholds and the absolute threshold [1, pp. 114].
%
%   See also Individual_masking_thresholds, Table_absolute_threshold

%-------------------------------------------------------------------------------
common;

N = length(LTq(:, 1));
if (~(isempty(LTt)))
   m = length(LTt(:, 1));
end
n = length(LTn(:, 1));
   
% The global masking thresholds is computing for the subset of frequencies
% defined in [1, Table 1.b]. They are the summ of the powers of the 
% corresponding to the individual masking thresholds (LTt, LTn) and the
% threshold in quiet (LTq).
for i = 1:N,
   
   % Threshold in quiet
   temp = 10^(LTq(i) / 10);
   
   % Contribution of the tonal component
   if (~(isempty(LTt)))
	   for j = 1:m,
	      temp = temp + 10^(LTt(j, i) / 10);
      end
   end
      
   % Contribution of the noise components
   for j = 1:n,
      temp = temp + 10^(LTn(j, i) / 10);
   end
   
   LTg(i) = 10 * log10(temp);
end
