PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. function y = mdctv(x)
  2. % MDCTV Calculates the Modified Discrete Cosine Transform in a vectorized way
  3. % y = mdctv(x)
  4. %
  5. % Use either a Sine or a Kaiser-Bessel Derived window (KBDWin)with
  6. % 50% overlap for perfect TDAC reconstruction.
  7. % Remember that MDCT coefs are symmetric: y(k)=-y(N-k-1) so the full
  8. % matrix (N) of coefs is: yf = [y;-flipud(y)];
  9. %
  10. % x: input signal (can be either a column or frame per column)
  11. % y: MDCT of x
  12. %
  13. % Fast ! ! !
  14. % ------- mdctv.m ------------------------------------------
  15. % Marios Athineos, marios@ee.columbia.edu
  16. % http://www.ee.columbia.edu/~marios/
  17. % Copyright (c) 2002 by Columbia University.
  18. % All rights reserved.
  19. % ----------------------------------------------------------
  20. [flen,fnum] = size(x);
  21. % Make column if it's a single row
  22. if (flen==1)
  23. x = x(:);
  24. flen = fnum;
  25. fnum = 1;
  26. end
  27. % Make sure length is even
  28. if (rem(flen,2)~=0)
  29. error('MDCT is defined only for even lengths.');
  30. end
  31. % We need these for furmulas below
  32. N = flen; % Length of window
  33. M = N/2; % Number of coefficients
  34. N0 = (M+1)/2;
  35. % Create the transformation matrix
  36. [n,k] = meshgrid(0:(N-1),0:(M-1));
  37. T = cos(pi*(n+N0).*(k+0.5)/M);
  38. clear k n;
  39. % So the MDCT is simply !!!
  40. y = T*x;
  41. end