def pwd(x, w): N = len(x) w = h.zeropad(w, N) w_ = w[::-1].conj() X_pwd = [] points = range(0, N) for i in points: x_subset = h.subset(x, i, N) fft_subset = fft(w * w_ * x_subset * x_subset[::-1].conj()) X_pwd.append(fft_subset) X_pwd = array(X_pwd).transpose() return X_pwd
def stft(x, w, L=None): # L is the overlap, see http://cnx.org/content/m10570/latest/ N = len(x) #T = len(w) if L is None: L = N # Zero pad the window w = h.zeropad(w, N) X_stft = [] points = range(0, N, N//L) for i in points: x_subset = h.subset(x, i, N) fft_subset = fft(x_subset * w) X_stft.append(fft_subset) X_stft = array(X_stft).transpose() return X_stft
def stft(x, w, L=None): # L is the overlap, see http://cnx.org/content/m10570/latest/ N = len(x) #T = len(w) if L is None: L = N # Zero pad the window w = h.zeropad(w, N) X_stft = [] points = range(0, N, N // L) for i in points: x_subset = h.subset(x, i, N) fft_subset = fft(x_subset * w) X_stft.append(fft_subset) X_stft = array(X_stft).transpose() return X_stft
from __future__ import division from pylab import * from numpy import * from numpy.fft import * # from pytfd import stft from pytfd.stft import * from pytfd.windows import * import pytfd.helpers as h N = 4096 T = 64 for window_name in ('ones', 'hanning', 'gaussian', 'blackman'): window_function = globals()[window_name] w = window_function(T) W = fft(h.zeropad(w, N)) figure() subplot(1, 2, 1) title(window_name) plot(h.zeropad(w, 2*T)) axis([0, 2*T, 0, 2]) subplot(1, 2, 2) title("FT(%s)"%window_name) plot(linspace(0, 2*pi, N), fftshift(log10(abs(W)+1))) savefig(window_name)