www.pudn.com > asr.rar > FEATURES.M, change:2004-11-06,size:1543b


function [sc]=features(sg,fmrate,winsize,coeffsize,fs) 
 
% Spectral Coefficient Computation 
% 
% [sc]=features(sg,fmrate,winsize,coeffsize,fs) 
%        sg - signal vector 
%    fmrate - frame rate in number of data samples 
%   winsize - window size 
% coeffsize - number of coefficients in each frame 
%        fs - sampling rate 
% 
% This function will return a spectral coefficient matrix 
 
%% compute number of frames 
%% (nf-1)*fmrate + winsize = len 
len=size(sg); 
nf = floor((len-winsize)/fmrate) +1; 
%% Mel Scale Table%% 
melfc=[200;300;400;500;600;700;800;900;... 
1000;1149;1320;1516;1741;2000;2297;2639;... 
3031;3482;4000;4595;5278;6063;6964]; 
melbw=[100;100;100;100;100;100;100;100;... 
124;160;184;211;242;278;320;367;422;484;... 
556;639;734;843;969]; 
melfc=melfc./(fs/2); 
melbw=melbw./(fs);  
if((melfc(coeffsize)+melbw(coeffsize))>1)... 
 input('Too many spectral coefficients for the given sampling rate'); 
end 
ubound=melfc(1:coeffsize)+melbw(1:coeffsize); 
lbound=melfc(1:coeffsize)-melbw(1:coeffsize); 
ubound=floor(ubound*winsize/2); 
lbound=floor(lbound*winsize/2); 
 
%% Normalization w.r.t. signal power 
sg=sg-mean(sg); 
sg=sg/std(sg); 
 
%% Frame Analysis 
sc=[]; 
 
for i=1:nf 
   %% Windowing %% 
   startpt = 1+(i-1)*fmrate; 
   s=sg(startpt:startpt+winsize-1); 
   %% Spectral Coefficients %% 
   sp=abs(fft(s,256)); 
   for j=1:coeffsize 
       range = lbound(j):ubound(j); 
       points = ubound(j)-lbound(j)+1; 
       sc(j,i)=10*log10(sum(sp(range).^2)/points + eps); 
   end 
end 
 
 
 
return