/trunk/Level 1/mdctv.m
http://aac-codec-matlab.googlecode.com/ · MATLAB · 48 lines · 18 code · 7 blank · 23 comment · 2 complexity · a8e2a5c1fab7376b99b16846d156b8d2 MD5 · raw file
- function y = mdctv(x)
- % MDCTV Calculates the Modified Discrete Cosine Transform in a vectorized way
- % y = mdctv(x)
- %
- % Use either a Sine or a Kaiser-Bessel Derived window (KBDWin)with
- % 50% overlap for perfect TDAC reconstruction.
- % Remember that MDCT coefs are symmetric: y(k)=-y(N-k-1) so the full
- % matrix (N) of coefs is: yf = [y;-flipud(y)];
- %
- % x: input signal (can be either a column or frame per column)
- % y: MDCT of x
- %
- % Fast ! ! !
-
- % ------- mdctv.m ------------------------------------------
- % Marios Athineos, marios@ee.columbia.edu
- % http://www.ee.columbia.edu/~marios/
- % Copyright (c) 2002 by Columbia University.
- % All rights reserved.
- % ----------------------------------------------------------
-
- [flen,fnum] = size(x);
- % Make column if it's a single row
- if (flen==1)
- x = x(:);
- flen = fnum;
- fnum = 1;
- end
- % Make sure length is even
- if (rem(flen,2)~=0)
- error('MDCT is defined only for even lengths.');
- end
-
- % We need these for furmulas below
- N = flen; % Length of window
- M = N/2; % Number of coefficients
- N0 = (M+1)/2;
-
- % Create the transformation matrix
- [n,k] = meshgrid(0:(N-1),0:(M-1));
- T = cos(pi*(n+N0).*(k+0.5)/M);
- clear k n;
-
- % So the MDCT is simply !!!
- y = T*x;
- end