www.pudn.com > Matlab-MPEG.rar > Individual_masking_thresholds.m, change:2007-08-21,size:4180b


function  [LTt, LTn] = Individual_masking_thresholds(X, Tonal_list, ... 
   Non_tonal_list, TH, Map) 
%   [LTt, LTn] = Individual_masking_thresholds(X, Tonal_list, ... 
%   Non_tonal_list, TH, Map) 
% 
%   计算音调和非音调信号两者在相邻谱频率上的屏蔽效果。 
%   Compute the masking effect of both tonal and non_tonal components on 
%   the neighbouring spectral frequencies [1, pp. 113]. The strength os the 
%   masker is summed with the masking index and the masking function. 
% 
%   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. 
% 
%------------------------------------------------------------------------------- 
Common; 
 
% Individual masking thresholds for both tonal and non-tonal  
% components are set to -infinity since the masking function has 
% infinite attenuation beyond -3 and +8 barks, that is the component 
% has no masking effect on frequencies beyond those ranges [1, pp. 113--114] 
if isempty(Tonal_list) 
   LTt = []; 
else 
   LTt = zeros(length(Tonal_list(:, 1)), length(TH(:, 1))) + MIN_POWER; 
end 
LTn = zeros(length(Non_tonal_list(:, 1)), length(TH(:, 1))) + MIN_POWER; 
 
% Only a subset of the samples are considered for the calculation of 
% the global masking threshold. The number of these samples depends 
% on the sampling rate and the encoding layer. All the information 
% needed is in TH which contains the frequencies, critical band rates 
% and absolute threshold. 
for i = 1:length(TH(:, 1))  % 1:106 
   zi = TH(i, BARK);  % Critical band rate of the frequency considered    
    
   if not(isempty(Tonal_list)) 
	   % For each tonal component 
	   for k = 1:length(Tonal_list(:, 1)), 
	      j  = Tonal_list(k, INDEX); 
	      zj = TH(Map(j), BARK); % Critical band rate of the masker     % sen: "To every tonal and non-tonal component the index i in the subsampled frequency domain is assigned, which is closest in frequency to the original spectral line X(k)" 
	      dz = zi - zj;          % Distance in Bark to the masker 
	       
	      if (dz >= -3 & dz < 8) 
	          
	         % Masking index 
	         avtm = -1.525 - 0.275 * zj - 4.5; 
	          
	         % Masking function 
	         if (-3 <= dz & dz < -1) 
	            vf = 17 * (dz + 1) - (0.4 * X(j) + 6); 
	         elseif (-1 <= dz & dz < 0) 
	            vf = (0.4 * X(j) + 6) * dz; 
	         elseif (0 <= dz & dz < 1) 
	            vf = -17 * dz; 
	         elseif (1 <= dz & dz < 8) 
	            vf = - (dz - 1) * (17 - 0.15 * X(j)) - 17; 
	         end 
          
	         LTt(k, i) = Tonal_list(k, SPL) + avtm + vf; 
	      end 
      end 
   end 
    
    
   % For each non-tonal component 
   for k = 1:length(Non_tonal_list(:, 1)), 
      j  = Non_tonal_list(k, INDEX); 
      zj = TH(Map(j), BARK); % Critical band rate of the masker 
      dz = zi - zj;          % Distance in Bark to the masker 
       
      if (dz >= -3 & dz < 8) 
          
         % Masking index 
         avnm = -1.525 - 0.175 * zj - 0.5; 
          
         % Masking function 
         if (-3 <= dz & dz < -1) 
            vf = 17 * (dz + 1) - (0.4 * X(j) + 6); 
         elseif (-1 <= dz & dz < 0) 
            vf = (0.4 * X(j) + 6) * dz; 
         elseif (0 <= dz & dz < 1) 
            vf = -17 * dz; 
         elseif (1 <= dz & dz < 8) 
            vf = - (dz - 1) * (17 - 0.15 * X(j)) - 17; 
         end 
          
         LTn(k, i) = Non_tonal_list(k, SPL) + avnm + vf; 
      end 
   end 
end 
 
% Add the indicudual masking thresholds to the existing graph 
if (DRAW) 
    if not(isempty(Tonal_list)) 
        hold on; 
        for j = 1:length(Tonal_list(:, 1)) 
            plot(TH(:, INDEX), LTt(j, :), 'r:'); 
        end 
        disp('Masking threshold for tonal components.'); 
        pause; 
   end 
	for j = 1:length(Non_tonal_list(:, 1)) 
	   plot(TH(:, INDEX), LTn(j, :), 'g:'); 
	end 
   hold off; 
   disp('Masking threshold for non-tonal components.'); 
   pause; 
end