def __early_downsample(y, sr, hop_length, res_type, n_octaves,
                       nyquist, filter_cutoff):

    if res_type != 'kaiser_fast':
        return y, sr, hop_length

    downsample_count1 = int(np.ceil(np.log2(audio.BW_FASTEST * nyquist /
                                            filter_cutoff)) - 1)
    num_twos = __num_two_factors(hop_length)
    downsample_count2 = max(0, num_twos - n_octaves + 1)
    downsample_count = min(downsample_count1, downsample_count2)

    if downsample_count > 0:
        downsample_factor = 2.0**(downsample_count)

        assert hop_length % downsample_factor == 0
        hop_length //= downsample_factor

        if len(y) < downsample_factor:
            raise ParameterError('Input signal length={:d} is too short for '
                                 '{:d}-octave CQT'.format(len(y), n_octaves))

        # The additional scaling of sqrt(downsample_factor) here is to implicitly
        # rescale the filters
        y = np.sqrt(downsample_factor) * audio.resample(y, sr, sr / downsample_factor,
                                                        res_type=res_type, scale=True)

        sr /= downsample_factor

    return y, sr, hop_length
Perform early downsampling on an audio signal, if it applies.
dataset/ETHPy150Open bmcfee/librosa/librosa/core/constantq.py/__early_downsample