function [ xt, Xf ] = ICCDST( S, F_start, F_end, N_sig )

% Function to invert the CC-DST.

% S: cell array contains the CC-DST voices.
% F_start: matrix contains the lower-edge frequencies of the voices.
% F_end: matrix contains the upper-edge frequencies of the voices.
% N_sig: number of samples of the synthesized signal.
% xt: reconstructed signal (in time domain).
% Xf: DFT of the reconstructed signal.

N = length(S);
Xf = zeros(1, 4*N_sig);  % empty frame to accumulate the results
 
for j=1:length(S)   
    z = (N_sig/length(S{j})).*fftshift(fft(S{j}));
    Bw = length(z);
    Xf_frame = zeros(1, 4*N_sig);  
    if j<=N/2 && ~mod(Bw, 2)
        z = circshift(z, [0, -1]);
    end
    Xf_frame(F_start(j)+2*N_sig+1:F_end(j)+2*N_sig+1) = z;
    Xf = Xf + Xf_frame;
end
 
Xf = Xf(2*N_sig -N_sig/2 +1:2*N_sig + N_sig/2);
xt = ifft(fftshift(Xf));
if max(imag(xt)<1e-10)
    xt=real(xt);   % neglect small imaginary part
end    
 
end