www.pudn.com > Matlab-MPEG.rar > Test_MPEG.asv, change:2007-08-21,size:3798b


function Test_MPEG  
    
 
%   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.  
%------------------------------------------------------------------------------- 
Common; 
 
% 建立DEMO样例 
% fs为采样率 
fs = 44100; 
f = [1500 1700 1800 2000 10000 11000 12000 13000]; 
a = [   1    2    1   .5     2   1.5     3     1]; 
t = 0:1/fs:1;   % t在[0 1]之间,步长为1/fs 
x = randn(size(t)); 
for i = 1:length(f), 
   x = x + a(i) * sin(2 * pi * f(i) * t); 
end 
x = x / max(abs(x)); 
 
% 或读入音频样本 
% [x fs] = wavread('svega'); 
 
% 显示音频波形 
figure(1); 
plot(x); 
 
%--------------------------------------------------------- 
 
% 装入需要的数据表. 
 
% 装入 安静时的绝对掩蔽阈(Threshold in quiet) 
% 第一层、采样率为44.1kHz的数据,位率为128 
[TH, Map, LTq] = Table_absolute_threshold(1, fs, 128);  
 
% 临界频带边界。第k个临界频带的上边界是由i指定的TH表中的频率 
% CB(k) = i, the top end of the kth critical band is the frequency indexed by i in TH table. 
CB = Table_critical_band_boundaries(1, fs);   
 
% 初始化在子带分中使用的分析窗口,即读入常数表C 
C = Table_analysis_window; 
 
% 处理输入向量x(音频信号采样值). 
for OFFSET = 1:384:length(x); 
   S = []; 
    
%%% Subband filter analysis. Layer 1 uses 12 samples per subband. 
%%% 子带滤波分析:第一层每个频带使用12个采样 
 
   % Analysis subband filtering [1, pp. 67]. 
   % 分析子带滤波 
   % 32*12 = 384 
   for i = 0:11,     
      S = [S; Analysis_subband_filter(x, OFFSET + 32 * i, C)]; 
   end 
    
   % Scalefactor calculation [1, pp. 70]. 
   scf = Scale_factors(S); 
 
   % ----------------------------------------------------------------- 
%%% Psychoacoustic analysis. 
%%% 心理声学分析 
 
	% Compute the FFT for time frequency conversion [1, pp. 110]. 
    % 为时频转换计算FFT 
	X = FFT_Analysis(x, OFFSET); 
    
   % Determine the sound pressure level in each  subband [1, pp. 110]. 
   % 确定每个子频带的声压级 
   Lsb = Sound_pressure_level(X, scf); 
    
   % Find the tonal (sine like) and non-tonal (noise like) components 
   % of the signal [1, pp. 111--113] 
   % 确定信号中的音调和非音调(如噪声)成分 
   [Flags Tonal_list Non_tonal_list] = Find_tonal_components(X, TH, Map, CB); 
    
   % Decimate the maskers: 剔除所有不相关的屏蔽 
   [Flags Tonal_list Non_tonal_list] = ... 
      Decimation(X, Tonal_list, Non_tonal_list, Flags, TH, Map); 
    
   % 计算单独的屏蔽阈值 [1, pp. 113--114] 
   [LTt, LTn] = ... % to be continued 
      Individual_masking_thresholds(X, Tonal_list, Non_tonal_list, TH, Map); 
    
   % 计算全局屏蔽阈值 [1, pp. 114] 
   % LTq为安静时的绝对掩蔽阈 
   ,LTt为音调的单独屏蔽阈值,LTn为非音调的单独屏蔽阈值 
   LTg = Global_masking_threshold(LTq, LTt, LTn); 
    
   if (DRAW) 
      disp('Global masking threshold'); 
      hold on; 
      plot(TH(:, INDEX), LTg, 'k--'); 
      hold off; 
      title('Masking components and masking thresholds.'); 
   end 
    
   % Determine the minimum masking threshold in each subband [1, pp. 114] 
   LTmin = Minimum_masking_threshold(LTg, Map); %jing: of each subband 
   if (DRAW) 
      figure; plot(LTmin); title('Minimum masking threshold'); 
      xlabel('Subband number'); ylabel('dB'); pause; 
   end 
    
   % Compute the singal-to-maks ratio 
   SMRsb = Lsb - LTmin; %jing:for 32 subbands 
end