#NEWLINE# @ cache #NEWLINE# def hybrid_cqt( y , sr = 22050 , hop_length = 512 , fmin = None , n_bins = 84 , bins_per_octave = 12 , tuning = None , filter_scale = 1 , norm = 1 , sparsity = 0.01 , resolution = util . Deprecated ( ) ) : #NEWLINE# #INDENT# 'Compute the hybrid constant-Q transform of an audio signal.\n\n    Here, the hybrid CQT uses the pseudo CQT for higher frequencies where\n    the hop_length is longer than half the filter length and the full CQT\n    for lower frequencies.\n\n    Parameters\n    ----------\n    y : np.ndarray [shape=(n,)]\n        audio time series\n\n    sr : number > 0 [scalar]\n        sampling rate of `y`\n\n    hop_length : int > 0 [scalar]\n        number of samples between successive CQT columns.\n\n    fmin : float > 0 [scalar]\n        Minimum frequency. Defaults to C1 ~= 32.70 Hz\n\n    n_bins : int > 0 [scalar]\n        Number of frequency bins, starting at `fmin`\n\n    bins_per_octave : int > 0 [scalar]\n        Number of bins per octave\n\n    tuning : None or float in `[-0.5, 0.5)`\n        Tuning offset in fractions of a bin (cents).\n\n        If `None`, tuning will be automatically estimated.\n\n    filter_scale : float > 0\n        Filter filter_scale factor. Larger values use longer windows.\n\n    sparsity : float in [0, 1)\n        Sparsify the CQT basis by discarding up to `sparsity`\n        fraction of the energy in each basis.\n\n        Set `sparsity=0` to disable sparsification.\n\n    resolution : float\n        .. warning:: This parameter name was in librosa 0.4.2\n            Use the `filter_scale` parameter instead.\n            The `resolution` parameter will be removed in librosa 0.5.0.\n\n\n    Returns\n    -------\n    CQT : np.ndarray [shape=(n_bins, t), dtype=np.float]\n        Constant-Q energy for each frequency at each time.\n\n    Raises\n    ------\n    ParameterError\n        If `hop_length` is not an integer multiple of\n        `2**(n_bins / bins_per_octave)`\n\n        Or if `y` is too short to support the frequency range of the CQT.\n\n    See Also\n    --------\n    cqt\n    pseudo_cqt\n    ' #NEWLINE# filter_scale = util . rename_kw ( 'resolution' , resolution , 'filter_scale' , filter_scale , '0.4.2' , '0.5.0' ) #NEWLINE# if ( fmin is None ) : #NEWLINE# #INDENT# fmin = note_to_hz ( 'C1' ) #NEWLINE# #UNINDENT# if ( tuning is None ) : #NEWLINE# #INDENT# tuning = estimate_tuning ( y = y , sr = sr ) #NEWLINE# #UNINDENT# freqs = cqt_frequencies ( n_bins , fmin , bins_per_octave = bins_per_octave , tuning = tuning ) #NEWLINE# lengths = filters . constant_q_lengths ( sr , fmin , n_bins = n_bins , bins_per_octave = bins_per_octave , tuning = tuning , filter_scale = filter_scale ) #NEWLINE# pseudo_filters = ( lengths < ( 2 * hop_length ) ) #NEWLINE# n_bins_pseudo = int ( np . sum ( pseudo_filters ) ) #NEWLINE# cqt_resp = [ ] #NEWLINE# if ( n_bins_pseudo > 0 ) : #NEWLINE# #INDENT# fmin_pseudo = np . min ( freqs [ pseudo_filters ] ) #NEWLINE# my_pseudo_cqt = pseudo_cqt ( y , sr , hop_length = hop_length , fmin = fmin_pseudo , n_bins = n_bins_pseudo , bins_per_octave = bins_per_octave , tuning = tuning , filter_scale = filter_scale , norm = norm , sparsity = sparsity ) #NEWLINE# cqt_resp . append ( my_pseudo_cqt ) #NEWLINE# #UNINDENT# n_bins_full = int ( np . sum ( ( ~ pseudo_filters ) ) ) #NEWLINE# if ( n_bins_full > 0 ) : #NEWLINE# #INDENT# fmin_full = np . min ( freqs [ ( ~ pseudo_filters ) ] ) #NEWLINE# my_cqt = np . abs ( cqt ( y , sr , hop_length = hop_length , fmin = fmin_full , n_bins = n_bins_full , bins_per_octave = bins_per_octave , tuning = tuning , filter_scale = filter_scale , norm = norm , sparsity = sparsity , real = False ) ) #NEWLINE# cqt_resp . append ( my_cqt ) #NEWLINE# #UNINDENT# return __trim_stack ( cqt_resp , n_bins , True )