function LTg = Global_masking_threshold(LTt, LTn)
%
% Authors: Fabien A.P. Petitcolas (fapp2@cl.cam.ac.uk)
% Computer Laboratory
% University of Cambridge
%
% Teddy Furon (furont@thmulti.com)
% Laboratoire TSI - Telecom Paris
% UIIS Lab - Thomson multimedia R&D France
%
% Corrections:
% Michael Arnold (arnold@igd.fhg.de)
% Fraunhofer Institute for Computer Graphics (IGD)
%
%
% References:
% [1] Information technology -- Coding of moving pictures and associated
% audio for digital storage media at up to 1,5 Mbits/s -- Part3: audio.
% British standard. BSI, London. October 1993. Implementation of
% ISO/IEC 11172-3:1993. BSI, London. First edition 1993-08-01.
%
% Legal notice:
% This computer program is based on ISO/IEC 11172-3:1993, Information
% technology -- Coding of moving pictures and associated audio for digital
% storage media at up to about 1,5 Mbit/s -- Part 3: Audio, with the
% permission of ISO. Copies of this standards can be purchased from the
% British Standards Institution, 389 Chiswick High Road, GB-London W4 4AL,
% Telephone:+ 44 181 996 90 00, Telefax:+ 44 181 996 74 00 or from ISO,
% postal box 56, CH-1211 Geneva 20, Telephone +41 22 749 0111, Telefax
% +4122 734 1079. Copyright remains with ISO.
%----------------------------------------------------------------------------
%
% LTg = Global_masking_threshold(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].
%
% -- INPUT --
% LTt: Matrix of size (length Tonal_list)x(length(TH(:, 1) = 106 for fs =
% 44.1 kHz)
% LTn: Matrix of size (length Non_tonal_list)x(length(TH(:, 1) = 106 for fs =
% 44.1 kHz)
%
% -- OUTPUT --
% LTq: Vector with (106 for fs = 44.1 kHz) elements containing the loudness
% threshold values in dB.
% ------------
%
% See also Individual_masking_thresholds
%-----------------------------------------------------------------------------
global LTq MIN_POWER
% Sum the powers of the threshold in quiet and the individual masking
% threshold of the non-tonal maskers. For vectors, sum(X) is the sum of the
% elements of X. For matrices, sum(X) is a row vector with the sum over each
% column.
temp = 0.0;
idx = [];
colsum = [];
colsum = sum(10.0 .^ (LTn ./ 10.0));
temp = 10.0 .^ (LTq' ./ 10.0) + colsum;
% Contribution of the tonal component if not empty.
if not(isempty(LTt))
temp = temp + sum(10 .^ (LTt ./ 10), 1);
end
% Calculate global masking threshold in dB.
LTg = 10.0 * log(temp)./log(10.0);