Ejemplo n.º 1
0
def KaiserFil(dataserie):
    import math
    pi = math.pi
    b = []
    fs = 250
    cutoff = [0.5, 4.0, 7.0, 12.0, 30.0]
    y = dataserie
    filtered = []
    for band in range(len(cutoff) - 1):
        wl = 2 * cutoff[band] / fs * pi
        wh = 2 * cutoff[band + 1] / fs * pi
        M = 250  # Set number of weights as 128
        bn = zeros(M)
        for i in range(M):
            n = i - M / 2  # Make symmetrical
            if n == 0:
                bn[i] = wh / pi - wl / pi
            else:
                bn[i] = (sin(wh * n)) / (pi * n) - (sin(wl * n)) / (
                    pi * n)  # Filter impulse response
        bn = bn * kaiser(M, 5.2)
        b.append(bn)
        [w, h] = freqz(bn, 1)
        filtered.append(np.convolve(bn, y))
    #print(np.array(filtered).shape,"dd")
    return np.array(filtered)[:, M // 2:M // 2 + 1000]
Ejemplo n.º 2
0
def load_data(
    fn='/home/ritz/mix/audio samples instruments/sampled vocal/love.wav',
    select=(0, 20000)):
    '''Load selection of test wave file. Apply widewindow fade in/out.'''
    x = wav.read(fn, to_mono=True)
    x = (x[select[0]:select[1]]).astype('float128')
    x = chunker.widewindow(x, pl.kaiser(1500, 15))
Ejemplo n.º 3
0
def smooth(x, beta):
    """ kaiser window smoothing """
    window_len = 11
    # extending the data at beginning and at the end
    # to apply the window at the borders
    s = pylab.r_[x[window_len - 1:0:-1], x, x[-1:-window_len:-1]]
    w = pylab.kaiser(window_len, beta)
    y = pylab.convolve(w / w.sum(), s, mode='valid')
    return y[5:len(y) - 5]
Ejemplo n.º 4
0
def smooth(x,beta):
    """ kaiser window smoothing """
    window_len=11
    # extending the data at beginning and at the end
    # to apply the window at the borders
    s = pylab.r_[x[window_len-1:0:-1],x,x[-1:-window_len:-1]]
    w = pylab.kaiser(window_len,beta)
    y = pylab.convolve(w/w.sum(),s,mode='valid')
    return y[5:len(y)-5]