I have a project which goes like this: I have to take a signal (a wav file), then do the STFT (Short Time Fourier Transform) of the signal, and then do the Inverse STFT, and get back the same signal that I had in the first place.
For some reason I get the same signal but with NOISE. I also notticed that the signal that i had at the beggining is smaller than the signal I get at the end by some points.
xt = x(xoff+1:xoff+M); % extract frame of input data xtw = w .* xt; % apply window to current frame if (N-M)~=0 xtwz = [zp(1:((N-M)/2)) ; xtw ; zp(((N-M)/2+1):(N-M))]; else xtwz=xtw; end Xtwz(:,m) = fft(xtwz); % STFT for frame m xoff = xoff + R; % advance in-pointer by hop-size R end
% Keep half of the spectrum if rem(N,2)==0 Xtwz = Xtwz(1:(N/2+1),:); else Xtwz = Xtwz(1:(N/2+1/2),:); end
function g = istft_til(d,R,N,M)
s = size(d); nframes = s(2); xlen = M + (nframes-1)*R; g = zeros(1,xlen); i=0;
for b = 1:nframes ft = d(:,b)'; ft = [ft , conj(ft(N/2:-1:2))]; px = real(ifft(ft)); i=(b-1)*R; a=px((N-M)/2+1:(N+M)/2); g((i+1):(i+M)) = g((i+1):(i+M)) + a; end
Does anyone have an idea why is this happening, or how could I fix it???