📄 mdct.m
字号:
function c=mdct(f,g,M,L);%MDCT Modified Discrete Cosine Transform% Usage: c=mdct(f,g,M);% c=mdct(f,g,M,L);% [c,Ls]=mdct(f,g,M);% [c,Ls]=mdct(f,g,M,L);%% Input parameters:% f : Input data% g : Window function.% M : Number of bands.% L : Length of transform to do.% Output parameters:% c : 2*M x N array of coefficients.% Ls : Length of input signal.%% MDCT(f,g,M) computes a Modified Discrete Cosine Transform with M bands% and window g.%% The length of the transform will be the smallest possible that is% larger than the signal. f will be zero-extended to the length of the % transform. If f is a matrix, the transformation is applied to each column.% g must be whole-point even.%% MDCT(f,g,M,L) computes the MDCT transform as above, but does% a transform of length L. f will be cut or zero-extended to length L% before the transform is done.%% [c,Ls]=MDCT(f,g,M) or [c,Ls]=MDCT(f,g,M,L) additionally return the% length of the input signal f. This is handy for reconstruction:% % [c,Ls]=mdct(f,g,M);% fr=imdct(c,gd,M,Ls);% % will reconstuct the signal f no matter what the length of f is, provided% that gd is a dual Wilson window of g.%% The MDCT is sometimes known as an odd-stacked cosine modulated filter% bank. The MDCT defined by this routine is slightly different from the% most common definition of the MDCT, in order to be able to use the% same window functions as the Wilson transform.%% Assume that the following code has been executed for a column vector f% of length L:% % c=mdct(f,g,M); % Compute the MDCT of f.% N=size(c,2); % Number of translation coefficients.% % The following holds for m=0,...,M-1 % and n=0,...,N-1:%% If m+n is even:% % L-1% c(m+1,n+1) = sum f(l+1)*cos(pi*(m+.5)*l/M+pi/4)*g(l-n*M+1)% l=0% % If m+n is odd:% L-1% c(m+1,n+1) = sum f(l+1)*sin(pi*(m+.5)*l/M+pi/4)*g(l-n*M+1)% l=0% % SEE ALSO: IMDCT, DWILT, WILDUAL, WILORTH%% REFERENCES:% H. Bölcskei and F. Hlawatsch. Oversampled Wilson-type cosine modulated% filter banks with linear phase. In Asilomar Conf. on Signals, Systems, and% Computers, pages 998-1002, nov 1996.% % H. S. Malvar. Signal Processing with Lapped Transforms. Artech House% Publishers, 1992.% % J. P. Princen and A. B. Bradley. Analysis/synthesis filter bank design based% on time domain aliasing cancellation. IEEE Transactions on Acoustics,% Speech, and Signal Processing, ASSP-34(5):1153-1161, 1986.% % J. P. Princen, A. W. Johnson, and A. B. Bradley. Subband/transform coding% using filter bank designs based on time domain aliasing cancellation.% Proceedings - ICASSP, IEEE International Conference on Acoustics, Speech and% Signal Processing, pages 2161-2164, 1987.error(nargchk(3,4,nargin));assert_squarelat(M,M,1,'MDCT',0);% Change f to correct shape.[f,fl,W,wasrow,remembershape]=comp_sigreshape_pre(f,'MDCT');if size(g,2)>1 if size(g,1)>1 error('g must be a vector'); else % g was a row vector. g=g(:); end;end;%if ~iseven(g)% error('g must be whole point even.See help on pgauss.');%end;% If input is real, and window is real, output must be real as well.inputwasreal = (isreal(g) && isreal(f));% Change f to correct shape.[f,Ls,W,wasrow,remembershape]=comp_sigreshape_pre(f,'MDCT',0);Lwindow=size(g,1);if nargin<4 [b,N,L]=assert_L(-Ls,Lwindow,M,M,'MDCT'); if rem(N,2)==1 L=L+M; N=N+1; end;else [b,N,L]=assert_L(L,Lwindow,M,M,'MDCT'); if rem(N,2)==1 error('It must hold that L/M is even.'); end;end;f=postpad(f,L); % Call the computational subroutines.a=M;c2 = comp_gdgt(f,g,a,2*M,L,0,.5,0,0);c = comp_dwiltiii(c2,a);% Get correct shape.c=reshape(c,M,N,W);% Clean coefficients if they are known to be realif inputwasreal c=real(c);end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -