The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: STFT and ISTFT problem. I get noise with the same signal. (Short Time Fourier Transform)
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 3
Registered: 6/30/13
STFT and ISTFT problem. I get noise with the same signal. (Short Time Fourier Transform)
Posted: Nov 4, 2013 9:56 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:


function Xtwz = stft(x, M, R, N, w)

nframes = floor(1+ (length(x)-M)/R);
Xtwz = zeros(N,nframes); % pre-allocate STFT output array
xoff = 0;
zp = zeros(N-M,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 (N-M)~=0
xtwz = [zp(1:((N-M)/2)) ; xtw ; zp(((N-M)/2+1):(N-M))];
Xtwz(:,m) = fft(xtwz); % STFT for frame m
xoff = xoff + R; % advance in-pointer by hop-size R

% Keep half of the spectrum
if rem(N,2)==0
Xtwz = Xtwz(1:(N/2+1),:);
Xtwz = Xtwz(1:(N/2+1/2),:);


function g = istft_til(d,R,N,M)

s = size(d);
nframes = s(2);
xlen = M + (nframes-1)*R;
g = zeros(1,xlen);

for b = 1:nframes
ft = d(:,b)';
ft = [ft , conj(ft(N/2:-1:2))];
px = real(ifft(ft));
g((i+1):(i+M)) = g((i+1):(i+M)) + a;


Does anyone have an idea why is this happening, or how could I fix it???

Thanks in advance.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.