function [f]=imdct(c,g,Ls)
%IMDCT  Inverse MDCT
%   Usage:  f=imdct(c,g);
%           f=imdct(c,g,Ls);
%
%   Input parameters:
%         c     : M*N array of coefficients.
%         g     : Window function.
%         Ls    : Final length of function (optional)
%   Output parameters:
%         f     : Input data
%
%   IMDCT(c,g) computes an inverse MDCT with window g. The number of
%   channels is deduced from the size of the coefficient array c.
%
%   The window g may be a text string decribing the window. The following
%   types are recognized
% 
%   'gauss'     - Gaussian window.
%
%   'dualgauss' - Canonical dual of Gaussian window.
%
%   'tight'     - Tight window generated from a Gaussian.
%
%   'sqrthann'  - Square root of Hanning window. This is a tight, FIR
%                 window.  
% 
%   IMDCT(f,g,Ls) does the same, but cuts or zero-extend the final
%   result to length Ls.
% 
%   SEE ALSO:  MDCT, DGT, 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.

% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.

%   AUTHOR: Peter Soendergaard
%   TESTING: TEST_MDCT
%   REFERNCE: OK

error(nargchk(2,3,nargin));

% If input is real, and window is real, output must be real as well.
wasreal=(isreal(g) && isreal(c));

wasrow=0;
if isnumeric(g)
  if size(g,2)>1
    if size(g,1)>1
      error('g must be a vector');
    else
      % g was a row vector.
      g=g(:);
      
      % If the input window is a row vector, and the dimension of c is
      % equal to two, the output signal will also
      % be a row vector.
      if ndims(c)==2
        wasrow=1;
      end;
    end;
  end;
end;

M=size(c,1);
N=size(c,2);
W=size(c,3);

a=M;
L=M*N;

assert_L(L,size(g,1),L,a,2*M,'IMDCT');

g=comp_window(g,a,2*M,L,1,'IMDCT');

c=comp_idwiltiii(reshape(c,M*N,W),a,M);

f=comp_igdgt(c,g,a,2*M,L,0,.5,0,0);

% Check if Ls was specified.
if nargin==3
  f=postpad(f,Ls);
else
  Ls=L;
end;

f=comp_sigreshape_post(f,Ls,wasrow,[0; W]);

% Clean signal if it is known to be real
if wasreal
  f=real(f);
end;


      About Koders | Resources | Downloads | Support | Black Duck | Terms of 
      Service | DMCA | Privacy Policy | Contact Us
            ©2012 Koders is a trademark of Black Duck Software, Inc. Black Duck, 
            Know Your Code, Ohloh, and the Black Duck logo are registered 
            trademarks of Black Duck Software, Inc. in the United States and 
            other jurisdictions. All other trademarks are the property of their 
            respective holders.

