@cache(level=<NUM_LIT:10>)<EOL>def cq_to_chroma(n_input, bins_per_octave=<NUM_LIT:12>, n_chroma=<NUM_LIT:12>,<EOL>fmin=None, window=None, base_c=True, dtype=np.float32):
<EOL>n_merge = float(bins_per_octave) / n_chroma<EOL>if fmin is None:<EOL><INDENT>fmin = note_to_hz('<STR_LIT>')<EOL><DEDENT>if np.mod(n_merge, <NUM_LIT:1>) != <NUM_LIT:0>:<EOL><INDENT>raise ParameterError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>cq_to_ch = np.repeat(np.eye(n_chroma), n_merge, axis=<NUM_LIT:1>)<EOL>cq_to_ch = np.roll(cq_to_ch, - int(n_merge // <NUM_LIT:2>), axis=<NUM_LIT:1>)<EOL>n_octaves = np.ceil(np.float(n_input) / bins_per_octave)<EOL>cq_to_ch = np.tile(cq_to_ch, int(n_octaves))[:, :n_input]<EOL>midi_0 = np.mod(hz_to_midi(fmin), <NUM_LIT:12>)<EOL>if base_c:<EOL><INDENT>roll = midi_0<EOL><DEDENT>else:<EOL><INDENT>roll = midi_0 - <NUM_LIT:9><EOL><DEDENT>roll = int(np.round(roll * (n_chroma / <NUM_LIT>)))<EOL>cq_to_ch = np.roll(cq_to_ch, roll, axis=<NUM_LIT:0>).astype(dtype)<EOL>if window is not None:<EOL><INDENT>cq_to_ch = scipy.signal.convolve(cq_to_ch,<EOL>np.atleast_2d(window),<EOL>mode='<STR_LIT>')<EOL><DEDENT>return cq_to_ch<EOL>
Convert a Constant-Q basis to Chroma.


    Parameters
    ----------
    n_input : int > 0 [scalar]
        Number of input components (CQT bins)

    bins_per_octave : int > 0 [scalar]
        How many bins per octave in the CQT

    n_chroma : int > 0 [scalar]
        Number of output bins (per octave) in the chroma

    fmin : None or float > 0
        Center frequency of the first constant-Q channel.
        Default: 'C1' ~= 32.7 Hz

    window : None or np.ndarray
        If provided, the cq_to_chroma filter bank will be
        convolved with `window`.

    base_c : bool
        If True, the first chroma bin will start at 'C'
        If False, the first chroma bin will start at 'A'

    dtype : np.dtype
        The data type of the output basis.
        By default, uses 32-bit (single-precision) floating point.


    Returns
    -------
    cq_to_chroma : np.ndarray [shape=(n_chroma, n_input)]
        Transformation matrix: `Chroma = np.dot(cq_to_chroma, CQT)`

    Raises
    ------
    ParameterError
        If `n_input` is not an integer multiple of `n_chroma`

    Notes
    -----
    This function caches at level 10.

    Examples
    --------
    Get a CQT, and wrap bins to chroma

    >>> y, sr = librosa.load(librosa.util.example_audio_file())
    >>> CQT = np.abs(librosa.cqt(y, sr=sr))
    >>> chroma_map = librosa.filters.cq_to_chroma(CQT.shape[0])
    >>> chromagram = chroma_map.dot(CQT)
    >>> # Max-normalize each time step
    >>> chromagram = librosa.util.normalize(chromagram, axis=0)

    >>> import matplotlib.pyplot as plt
    >>> plt.subplot(3, 1, 1)
    >>> librosa.display.specshow(librosa.amplitude_to_db(CQT,
    ...                                                  ref=np.max),
    ...                          y_axis='cqt_note')
    >>> plt.title('CQT Power')
    >>> plt.colorbar()
    >>> plt.subplot(3, 1, 2)
    >>> librosa.display.specshow(chromagram, y_axis='chroma')
    >>> plt.title('Chroma (wrapped CQT)')
    >>> plt.colorbar()
    >>> plt.subplot(3, 1, 3)
    >>> chroma = librosa.feature.chroma_stft(y=y, sr=sr)
    >>> librosa.display.specshow(chroma, y_axis='chroma', x_axis='time')
    >>> plt.title('librosa.feature.chroma_stft')
    >>> plt.colorbar()
    >>> plt.tight_layout()