function x = decode(X, winLen, hopSize) % x = decode(X, winLen, hopSize) % X - input stft signal % winLen - length of the hann window % hopSize - number of samples in the hop from bin to bin % preforms the inverse short time fourier transform of a signal. The % signal x is reconstructed from X by taking the fft signalLen = size(X,2); % number of columns in the Hanning windowed signal x = zeros(1,winLen+signalLen*hopSize); % Initialize the output vector % Create a periodic hanning window the length of f hannWin = hann(winLen, 'periodic'); hannWin = hannWin'; %transpose of hannning window winIndex = 1; for i = 0:hopSize:(hopSize*(signalLen-1)) Xfft = X(:,winIndex)'; Xfft = [Xfft, conj(Xfft([(winLen/2):-1:2]))]; %Conjugate of the input signal xMag = real(ifft(Xfft,winLen)); % Real portion of the ifft of the window vector x((i+1):(i+winLen)) = x((i+1):(i+winLen)) + xMag.*hannWin; winIndex = winIndex + 1; end; %takes the fft samples of the bin (since the bin is size N/2) and then the %conjugate of those samples in reverse order. This is to get the entire %length N vector (earlier adjusted for the Nyquist rate sample reduction of the encode process) to preform the ifft operation on. this is equivalent to %to getting