Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



STFT and ISTFT problem. I get noise with the same signal. (Short Time Fourier Transform)
Posted:
Nov 4, 2013 9:56 AM


Dear friends,
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.
Here is the code of STFT and ISTFT:
*STFT*
function Xtwz = stft(x, M, R, N, w) nframes = floor(1+ (length(x)M)/R); Xtwz = zeros(N,nframes); % preallocate STFT output array xoff = 0; zp = zeros(NM,1); % zero padding (to be inserted) for m=1:nframes xt = x(xoff+1:xoff+M); % extract frame of input data xtw = w .* xt; % apply window to current frame if (NM)~=0 xtwz = [zp(1:((NM)/2)) ; xtw ; zp(((NM)/2+1):(NM))]; else xtwz=xtw; end Xtwz(:,m) = fft(xtwz); % STFT for frame m xoff = xoff + R; % advance inpointer by hopsize 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
*ISTFT*
function g = istft_til(d,R,N,M) s = size(d); nframes = s(2); xlen = M + (nframes1)*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=(b1)*R; a=px((NM)/2+1:(N+M)/2); g((i+1):(i+M)) = g((i+1):(i+M)) + a; end end
Does anyone have an idea why is this happening, or how could I fix it???
Thanks in advance.



