xiangkan 发表于 2007-11-19 20:33

关于三角滤波器程序的问题求助

我是matlab新手,对三角滤波器melbankm.m程序,看不太明白。
想请教这个三角滤波器组里的每个滤波器的覆盖范围是一定的吗?
是不是可调节的,哪里调节,怎么调节?


function =melbankm(p,n,fs,fl,fh,w)
if nargin < 6
w='tz';
if nargin < 5
    fh=0.5;
    if nargin < 4
      fl=0;
    end
end
end
f0=700/fs;
fn2=floor(n/2);
lr=log((f0+fh)/(f0+fl))/(p+1);
% convert to fft bin numbers with 0 for DC term
bl=n*((f0+fl)*exp(*lr)-f0);
b2=ceil(bl(2));
b3=floor(bl(3));
if any(w=='y')
pf=log((f0+(b2:b3)/n)/(f0+fl))/lr;
fp=floor(pf);
r=;
c=;
v=2*;
mn=1;
mx=fn2+1;
else
b1=floor(bl(1))+1;
b4=min(fn2,ceil(bl(4)))-1;
pf=log((f0+(b1:b4)/n)/(f0+fl))/lr;
fp=floor(pf);
pm=pf-fp;
k2=b2-b1+1;
k3=b3-b1+1;
k4=b4-b1+1;
r=;
c=;
v=2*;
mn=b1+1;
mx=b4+1;
end
if any(w=='n')
v=1-cos(v*pi/2);
elseif any(w=='m')
v=1-0.92/1.08*cos(v*pi/2);
end
if nargout > 1
x=sparse(r,c,v);
else
x=sparse(r,c+mn-1,v,p,1+fn2);
end

[ 本帖最后由 eight 于 2007-11-19 20:49 编辑 ]

xiangkan 发表于 2007-11-19 20:34

补充

%MELBANKM determine matrix for a mel-spaced filterbank =(P,N,FS,FL,FH,W)
%
% Inputs: p   number of filters in filterbank
%n   length of fft
%fssample rate in Hz
%fllow end of the lowest filter as a fraction of fs (default = 0)
%fhhigh end of highest filter as a fraction of fs (default = 0.5)
%w   any sensible combination of the following:
%      't'triangular shaped filters in mel domain (default)
%      'n'hanning shaped filters in mel domain
%      'm'hamming shaped filters in mel domain
%
%      'z'highest and lowest filters taper down to zero (default)
%      'y'lowest filter remains at 1 down to 0 frequency and
%      highest filter remains at 1 up to nyquist freqency
%
%         If 'ty' or 'ny' is specified, the total power in the fft is preserved.
%
% Outputs: x   a sparse matrix containing the filterbank amplitudes
%      If x is the only output argument then size(x)=
%      otherwise size(x)=
%mn   the lowest fft bin with a non-zero coefficient
%mx   the highest fft bin with a non-zero coefficient
%
% Usage: f=fft(s);   f=fft(s);
%x=melbankm(p,n,fs);=melbankm(p,n,fs);
%n2=1+floor(n/2);z=log(x*(f(na:nb)).*conj(f(na:nb)));
%z=log(x*abs(f(1:n2)).^2);
%c=dct(z); c(1)=[];
%
% To plot filterbanks e.g. plot(melbankm(20,256,8000)')
%
页: [1]
查看完整版本: 关于三角滤波器程序的问题求助