def stft(data, cp, do, hop): dos = int(do*cp) w = scipy.kaiser(dos,12) temp=[] wyn=[] for i in range(0, len(data)-dos, hop): temp=scipy.fft(w*data[i:i+dos]) max=-1 for j in range(0, len(temp),1): licz=temp[j].real**2+temp[j].imag**2 if( licz>max ): max = licz maxj = j wyn.append(maxj) #wyn = scipy.array([scipy.fft(w*data[i:i+dos]) #for i in range(0, len(data)-dos, 1)]) return wyn
def stft(data, cp, do, hop): dos = int(do * cp) w = scipy.kaiser(dos, 12) # 12 is very high for kaiser window temp = [] wyn = [] for i in range(0, len(data) - dos, hop): temp = scipy.fft(w * data[i : i + dos]) max = -1 for j in range(0, len(temp), 1): licz = temp[j].real ** 2 + temp[j].imag ** 2 if licz > max: max = licz maxj = j wyn.append(maxj) # wyn = scipy.array([scipy.fft(w*data[i:i+dos]) # for i in range(0, len(data)-dos, 1)]) return wyn
def stft(data, cp, do, hop): dos = int(do * cp) w = scipy.kaiser(dos, 12) # 12 is very high for kaiser window temp = [] wyn = [] for i in range(0, len(data) - dos, int(hop * cp)): temp2 = scipy.fft(w * data[i:i + dos]) temp = scipy.fftpack.fftshift(temp2) max = -1 for j in range(0, len(temp), 1): licz = temp[j].real**2 + temp[j].imag**2 if (licz > max): max = licz maxj = j wyn.append(maxj) #wyn = scipy.array([scipy.fft(w*data[i:i+dos]) #for i in range(0, len(data)-dos, 1)]) return wyn
def kaiser_window(self, beta=4, use_scipy=None): if use_scipy == None: # modified Bessel function of zero kind order from somewhere def I_0(x): i0=0 fac = lambda n:reduce(lambda a,b:a*(b+1),range(n),1) for n in xrange(20): i0 += ((x/2.0)**n/(fac(n)))**2 return i0 t = numpy.arange(self.x.size, type=numpy.Float) - self.x.size/2.0 T = self.x.size # this is the window function array apod = I_0(beta*numpy.sqrt(1-(2*t/T)**2))/I_0(beta) else: # alternative method using scipy import scipy apod=scipy.kaiser(self.x.size, beta) for i in range(2): self.y[i] = self.y[i]*apod return self
def kaiser_window(self, beta=4, show=0, use_scipy=None): if use_scipy == None: # modified Bessel function of zero kind order from somewhere def I_0(x): i0=0 fac = lambda n:reduce(lambda a,b:a*(b+1),range(n),1) for n in range(20): i0 += ((x/2.0)**n/(fac(n)))**2 return i0 t = N.arange(self.data_points, type=N.Float) - self.data_points/2.0 T = self.data_points # this is the window function array apod = I_0(beta*N.sqrt(1-(2*t/T)**2))/I_0(beta) else: # alternative method using scipy import scipy apod=scipy.kaiser(self.data_points, beta) for i in range(2): self.the_result.y[i] = self.the_result.y[i]*apod if show == 1: return self.the_result return self
def k(M, beta): return pad(sc.kaiser(M, beta), p)