large_vocab_adt_dafx2018/features.py
def onset_detection_fn(x, f_win_size, f_hop_size, f_bins_per_octave, f_octaves, f_fmin, sr, mean_filter_size):
    """
    Filter bank for onset pattern calculation
    """
    # calculate frequency constant-q transform
    f_win = scipy.signal.hanning(f_win_size)
    x_spec = librosa.stft(x,
                          n_fft=f_win_size,
                          hop_length=f_hop_size,
                          win_length=f_win_size,
                          window=f_win)
    x_spec = np.abs(x_spec) / (2 * np.sum(f_win))

    f_cq_mat = cq_matrix(f_bins_per_octave, f_octaves * f_bins_per_octave, f_fmin, f_win_size, sr)
    x_cq_spec = np.dot(f_cq_mat, x_spec[:-1, :])

    # subtract moving mean
    b = np.concatenate([[1], np.ones(mean_filter_size, dtype=float) / -mean_filter_size])
    od_fun = scipy.signal.lfilter(b, 1, x_cq_spec, axis=1)

    # half-wave rectify
    od_fun = np.maximum(0, od_fun)

    # post-process OPs
    od_fun = np.log10(1 + 1000*od_fun)
    return od_fun, x_cq_spec

    Filter bank for onset pattern calculation
    
Filter bank for onset pattern calculation
Filter bank for onset pattern calculation
def onset_detection_fn(x, f_win_size, f_hop_size, f_bins_per_octave, f_octaves, f_fmin, sr, mean_filter_size):
    f_win = scipy.signal.hanning(f_win_size)
    x_spec = librosa.stft(x,
                          n_fft=f_win_size,
                          hop_length=f_hop_size,
                          win_length=f_win_size,
                          window=f_win)
    x_spec = np.abs(x_spec) / (2 * np.sum(f_win))
    f_cq_mat = cq_matrix(f_bins_per_octave, f_octaves * f_bins_per_octave, f_fmin, f_win_size, sr)
    x_cq_spec = np.dot(f_cq_mat, x_spec[:-1, :])
    b = np.concatenate([[1], np.ones(mean_filter_size, dtype=float) / -mean_filter_size])
    od_fun = scipy.signal.lfilter(b, 1, x_cq_spec, axis=1)
    od_fun = np.maximum(0, od_fun)
    od_fun = np.log10(1 + 1000*od_fun)
    return od_fun, x_cq_spec
def onset_detection_fn ( x , f_win_size , f_hop_size , f_bins_per_octave , f_octaves , f_fmin , sr , mean_filter_size ) : f_win = scipy . signal . hanning ( f_win_size ) x_spec = librosa . stft ( x , n_fft = f_win_size , hop_length = f_hop_size , win_length = f_win_size , window = f_win ) x_spec = np . abs ( x_spec ) / ( 2 * np . sum ( f_win ) ) f_cq_mat = cq_matrix ( f_bins_per_octave , f_octaves * f_bins_per_octave , f_fmin , f_win_size , sr ) x_cq_spec = np . dot ( f_cq_mat , x_spec [ : - 1 , : ] ) b = np . concatenate ( [ [ 1 ] , np . ones ( mean_filter_size , dtype = float ) / - mean_filter_size ] ) od_fun = scipy . signal . lfilter ( b , 1 , x_cq_spec , axis = 1 ) od_fun = np . maximum ( 0 , od_fun ) od_fun = np . log10 ( 1 + 1000 * od_fun ) return od_fun , x_cq_spec
Filter bank for onset pattern calculation
Filter bank for onset pattern calculation
"""
    Filter bank for onset pattern calculation
    """ # calculate frequency constant-q transform # subtract moving mean # half-wave rectify # post-process OPs
x
f_win_size
f_hop_size
f_bins_per_octave
f_octaves
f_fmin
sr
mean_filter_size