
% ilogft.m  5/02    inverse transform of complex cq
% enter cqcxin in sonagram form ie  as output from logftS transposed
% [timfil]  = ilogft(cqcxin , freqs, 150,  150, 11025 );
%       input cqcxin - calc from logftS with complex out; change to sonagram in
%       freqs           output from logftS
%       hopsiz          from logftS
%       Nmax           the output windowsiz; should coord with hopsiz if no overlap
%       SR               from logftS
%                   calculates with Hamming window

        function  [timfil, icqt]  =  ilogft(cqcxin , freqs, hopsiz,  Nmax, SR);
        
        %  cqcxin = cqcxin'; % change to sonagram form
%         SR = 11025;
%          windsizTfn = 256;
%          hopsiz = 80;
        TWOPIoSR = 2*pi/SR;
 %       calcwin = 1;
        
        
        digfreq =  (freqs* TWOPIoSR)' ; %make sure column
        if cols(digfreq) ~= 1 , digfreq = digfreq'; end
        
                        %  Nmax x nfreqs
        iexp = (exp(i * digfreq * [0 : Nmax - 1]))'  ;
        % transform matrix - time basis fns in columns ; frequency varies over the freqs calc for cqtrans
        
       % if calcwin == 1, 
         %   iexp = iexp .* (hamming(Nmax) * ones(1, length(freqs)));
            % end
            
            %    Nmax x nfreqs     nfreqs x number of frames ie transform in columns
        icqt = iexp * cqcxin;
            % temporal estimation in columns
        % ==========================================
        %  from ifftgen.m
        % resize the output matrix for row out
        icqt = icqt';
        nhops = rows(icqt) ;
        windsiz = Nmax;
        outsmps = (nhops -1) * hopsiz + windsiz;
        outfilT = zeros(1, outsmps);

        for ii = 1:nhops
           init = 1 + (ii - 1)* hopsiz;
            fnl = init + windsiz - 1;    %  fnl - init = windsiz -1  or windsiz numbers
            outfilT(init:fnl) = outfilT(init:fnl) + icqt(ii,:);
        end
        timfil = real(outfilT);

        
        
        
        
        % end from ifftgen
        % timfil = real(timfil(:));