Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2013
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. # x is the input signal
  2.  
  3. # STFT
  4. fftsize = 8192;  overlap = 4;  hop = fftsize / overlap
  5. w = scipy.hamming(fftsize)  
  6. x_stft = scipy.array([scipy.fft(w*x[i:i+fftsize]) for i in range(0, len(x)-fftsize, hop)])
  7.  
  8. # ISTFT
  9. w /= sum([w[hop * i] ** 2 for i in range(overlap)])   # normalize for perfect reconstruction  
  10. y = scipy.zeros(len(x))
  11. for n,i in enumerate(range(0, len(x)-fftsize, hop)):
  12.   y[i:i+fftsize] += scipy.real(scipy.ifft(x_stft[n])) * w    # overlap-add
  13.  
  14. # y is the output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement