
    }KgB                   f   U d Z ddlmZ ddlZddlZddlmZ ddlm	Z	 ddl
mZ dd	lmZmZmZmZmZmZmZmZ dd
lmZmZmZmZmZ g dZeddd	 	 	 	 	 	 	 dd       Zeddd	 	 	 	 	 	 	 dd       Zddd	 	 	 	 	 	 	 ddZeddd	 	 	 	 	 	 	 dd       Zeddd	 	 	 	 	 	 	 dd       Zeddd	 	 	 	 	 	 	 dd       Zddd	 	 	 	 	 	 	 ddZedddd	 	 	 	 	 	 	 	 	 dd       Zedddd	 	 	 	 	 	 	 	 	 dd       Zedddd	 	 	 	 	 	 	 	 	 dd       Zdddd	 	 	 	 	 	 	 	 	 ddZedddd	 	 	 	 	 	 	 	 	 dd       Zedddd	 	 	 	 	 	 	 	 	 dd       Zedddd	 	 	 	 	 	 	 	 	 dd       Zdddd	 	 	 	 	 	 	 	 	 ddZedd dd!       Z edd 	 	 	 	 	 dd"       Z edd 	 	 	 	 	 dd#       Z dd 	 	 	 	 	 dd$Z edd dd%       Z!edd 	 	 	 	 	 dd&       Z!edd 	 	 	 	 	 dd'       Z!dd 	 	 	 	 	 dd(Z!edd)       Z"e	 	 	 	 	 	 dd*       Z"e	 	 	 	 	 	 dd+       Z"	 	 	 	 	 	 dd,Z"e	 	 	 	 	 	 	 	 dd-       Z#e	 	 	 	 	 	 	 	 dd.       Z#e	 	 	 	 	 	 	 	 dd/       Z#	 	 	 	 	 	 	 	 dd0Z#e	 	 	 	 	 	 	 	 	 	 dd1       Z$e	 	 	 	 	 	 	 	 	 	 dd2       Z$e	 	 	 	 	 	 	 	 	 	 dd3       Z$	 	 	 	 	 	 	 	 	 	 dd4Z$edd5       Z%edd6       Z%e	 	 	 	 	 	 dd7       Z%	 	 	 	 	 	 dd8Z%edd9dd:       Z&edd9dd;       Z&edd9	 	 	 	 	 dd<       Z&d=d9	 	 	 	 	 dd>Z&eddddd?	 	 	 	 	 	 	 	 	 	 	 dd@       Z'eddddd?	 	 	 	 	 	 	 	 	 	 	 ddA       Z'eddddd?	 	 	 	 	 	 	 	 	 	 	 ddB       Z' eg d?C      d=dDdEd=d?	 	 	 	 	 	 	 	 	 	 	 ddF       Z'eddG       Z(eddH       Z(e	 	 	 	 ddI       Z(	 	 	 	 ddJZ(eddK       Z)eddL       Z)e	 	 	 	 ddM       Z)	 	 	 	 ddNZ)eddO       Z*eddP       Z*e	 	 	 	 	 	 ddQ       Z*	 	 	 	 	 	 ddRZ*eddSddT       Z+eddS	 	 	 	 	 ddU       Z+eddS	 	 	 	 	 ddV       Z+dDdS	 	 	 	 	 ddWZ+eddSddX       Z,eddSddY       Z,eddS	 	 	 	 	 ddZ       Z,dDdS	 	 	 	 	 dd[Z,eddd\	 	 	 	 	 	 	 dd]       Z-eddd\	 	 	 	 	 	 	 dd^       Z-eddd\	 	 	 	 	 	 	 dd_       Z-d`dad\	 	 	 	 	 	 	 ddbZ-eddd\	 	 	 	 	 	 	 ddc       Z.eddd\	 	 	 	 	 	 	 ddd       Z.eddd\	 	 	 	 	 	 	 dde       Z.d`dad\	 	 	 	 	 	 	 ddfZ.eddgddh       Z/eddg	 	 	 	 	 ddi       Z/eddg	 	 	 	 	 ddj       Z/dadg	 	 	 	 	 ddkZ/eddg	 	 	 	 	 ddl       Z0eddg	 	 	 	 	 ddm       Z0eddg	 	 	 	 	 ddn       Z0dadg	 	 	 	 	 ddoZ0ddpdqd drZ1dad`ds	 	 	 	 	 	 	 	 	 ddtZ2	 dd`dudDdv	 	 	 	 	 	 	 	 	 ddwZ3dddx	 	 	 	 	 	 	 ddyZ4ddzdd{	 	 	 	 	 	 	 dd|Z5edd}	 	 	 	 	 dd~       Z6edd}	 	 	 	 	 dd       Z6edd}	 	 	 	 	 dd       Z6dd}	 	 	 	 	 ddZ6edd}	 	 	 	 	 dd       Z7edd}	 	 	 	 	 dd       Z7edd}	 	 	 	 	 dd       Z7dd}	 	 	 	 	 ddZ7edd}	 	 	 	 	 dd       Z8edd}	 	 	 	 	 dd       Z8edd}	 	 	 	 	 dd       Z8dd}	 	 	 	 	 ddZ8edd}	 	 	 	 	 dd       Z9edd}	 	 	 	 	 dd       Z9edd}	 	 	 	 	 dd       Z9dd}	 	 	 	 	 ddZ9dd}	 	 	 	 	 d	dZ:e6e7e8e9e:e:dZ;de<d<   edd	 	 	 	 	 	 	 d
d       Z=edd	 	 	 	 	 	 	 dd       Z=edd	 	 	 	 	 	 	 dd       Z=dd	 	 	 	 	 	 	 ddZ=dd	 	 	 	 	 	 	 ddZ>ddddd	 	 	 	 	 	 	 	 	 	 	 ddZ?dddd	 	 	 	 	 	 	 	 	 ddZ@edddd	 	 	 	 	 	 	 	 	 	 	 dd       ZAedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZAedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZA eg dC      d=d=d=d	 	 	 	 	 	 	 	 	 	 	 dd       ZAedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZBedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZBedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZBd=d=d=d	 	 	 	 	 	 	 	 	 	 	 ddZBedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZCedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZCedddd	 	 	 	 	 	 	 	 	 	 	 dd       ZCd=d=d=d	 	 	 	 	 	 	 	 	 	 	 ddZCedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZDedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZDedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZD eg dC      d=d=d=d	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZDedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZEedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZEedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZEd=d=d=d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZEedddd	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZFedddd	 	 	 	 	 	 	 	 	 	 	 	 	 d d       ZFedddd	 	 	 	 	 	 	 	 	 	 	 	 	 d!d       ZFd=d=d=d	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZFedddd	 	 	 	 	 	 	 	 	 d"d       ZGedddd	 	 	 	 	 	 	 	 	 d#d       ZGdddDd	 	 	 	 	 	 	 	 	 d$dZGy(%  zUnit conversion utilities    )annotationsN   )notation   )ParameterError)	vectorize)AnyCallableDictIterableOptionalSizedUnionoverload)_IterableLike_FloatLike_co_SequenceLike_ScalarOrSequence_IntLike_co)*frames_to_samplesframes_to_timesamples_to_framessamples_to_timetime_to_samplestime_to_framesblocks_to_samplesblocks_to_framesblocks_to_time
note_to_hznote_to_midi
midi_to_hzmidi_to_note
hz_to_note
hz_to_midi	hz_to_mel
hz_to_octs	hz_to_fjs	mel_to_hz
octs_to_hzA4_to_tuningtuning_to_A4fft_frequenciescqt_frequenciesmel_frequenciestempo_frequenciesfourier_tempo_frequenciesA_weightingB_weightingC_weightingD_weightingZ_weightingfrequency_weightingmulti_frequency_weightingsamples_like
times_likemidi_to_svara_hmidi_to_svara_cnote_to_svara_hnote_to_svara_chz_to_svara_hhz_to_svara_ci   
hop_lengthn_fftc                    y N framesrA   rB   s      X/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/librosa/core/convert.pyr   r   A            c                    y rD   rE   rF   s      rH   r   r   H        rJ   c                   d}|t        |dz        }t        j                  |       |z  |z   j                  t               S )a  Convert frame indices to audio sample indices.

    Parameters
    ----------
    frames : number or np.ndarray [shape=(n,)]
        frame index or vector of frame indices
    hop_length : int > 0 [scalar]
        number of samples between successive frames
    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``n_fft // 2``
        to counteract windowing effects when using a non-centered STFT.

    Returns
    -------
    times : number or np.ndarray
        time (in samples) of each given frame number::

            times[i] = frames[i] * hop_length

    See Also
    --------
    frames_to_time : convert frame indices to time values
    samples_to_frames : convert sample indices to frame indices

    Examples
    --------
    >>> y, sr = librosa.load(librosa.ex('choice'))
    >>> tempo, beats = librosa.beat.beat_track(y=y, sr=sr)
    >>> beat_samples = librosa.frames_to_samples(beats, sr=sr)
    r   r   )intnp
asanyarrayastype)rG   rA   rB   offsets       rH   r   r   R   sA    J FUaZMM&!J.7??DDrJ   .c                    y rD   rE   samplesrA   rB   s      rH   r   r   ~   rI   rJ   c                    y rD   rE   rT   s      rH   r   r      rL   rJ   c                    y rD   rE   rT   s      rH   r   r      rL   rJ   c                   d}|t        |dz        }t        j                  |       } t        j                  t        j                  | |z
  |z        t               S )a  Convert sample indices into STFT frames.

    Examples
    --------
    >>> # Get the frame numbers for every 256 samples
    >>> librosa.samples_to_frames(np.arange(0, 22050, 256))
    array([ 0,  0,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,
            7,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 13, 13,
           14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20,
           21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
           28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34,
           35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41,
           42, 42, 43])

    Parameters
    ----------
    samples : int or np.ndarray [shape=(n,)]
        sample index or vector of sample indices

    hop_length : int > 0 [scalar]
        number of samples between successive frames

    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``- n_fft // 2``
        to counteract windowing effects in STFT.

        .. note:: This may result in negative frame indices.

    Returns
    -------
    frames : int or np.ndarray [shape=(n,), dtype=int]
        Frame numbers corresponding to the given times::

            frames[i] = floor( samples[i] / hop_length )

    See Also
    --------
    samples_to_time : convert sample indices to time values
    frames_to_samples : convert frame indices to sample indices
    r   r   dtype)rN   rO   rP   asarrayfloor)rU   rA   rB   rR   s       rH   r   r      sO    ^ FUaZmmG$G::bhh& 0Z?@LLrJ   )srrA   rB   c                    y rD   rE   rG   r]   rA   rB   s       rH   r   r           rJ   c                    y rD   rE   r_   s       rH   r   r      r`   rJ   c                    y rD   rE   r_   s       rH   r   r      r`   rJ   i"V  c               8    t        | ||      }t        ||      S )a  Convert frame counts to time (seconds).

    Parameters
    ----------
    frames : np.ndarray [shape=(n,)]
        frame index or vector of frame indices
    sr : number > 0 [scalar]
        audio sampling rate
    hop_length : int > 0 [scalar]
        number of samples between successive frames
    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``n_fft // 2``
        to counteract windowing effects when using a non-centered STFT.

    Returns
    -------
    times : np.ndarray [shape=(n,)]
        time (in seconds) of each given frame number::

            times[i] = frames[i] * hop_length / sr

    See Also
    --------
    time_to_frames : convert time values to frame indices
    frames_to_samples : convert frame indices to sample indices

    Examples
    --------
    >>> y, sr = librosa.load(librosa.ex('choice'))
    >>> tempo, beats = librosa.beat.beat_track(y=y, sr=sr)
    >>> beat_times = librosa.frames_to_time(beats, sr=sr)
    r@   r]   )r   r   )rG   r]   rA   rB   rU   s        rH   r   r      s     P  :UKG7r**rJ   c                    y rD   rE   timesr]   rA   rB   s       rH   r   r     r`   rJ   c                    y rD   rE   rf   s       rH   r   r   )  r`   rJ   c                    y rD   rE   rf   s       rH   r   r   4  r`   rJ   c               8    t        | |      }t        |||      S )ax  Convert time stamps into STFT frames.

    Parameters
    ----------
    times : np.ndarray [shape=(n,)]
        time (in seconds) or vector of time values

    sr : number > 0 [scalar]
        audio sampling rate

    hop_length : int > 0 [scalar]
        number of samples between successive frames

    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``- n_fft // 2``
        to counteract windowing effects in STFT.

        .. note:: This may result in negative frame indices.

    Returns
    -------
    frames : np.ndarray [shape=(n,), dtype=int]
        Frame numbers corresponding to the given times::

            frames[i] = floor( times[i] * sr / hop_length )

    See Also
    --------
    frames_to_time : convert frame indices to time values
    time_to_samples : convert time values to sample indices

    Examples
    --------
    Get the frame numbers for every 100ms

    >>> librosa.time_to_frames(np.arange(0, 1, 0.1),
    ...                         sr=22050, hop_length=512)
    array([ 0,  4,  8, 12, 17, 21, 25, 30, 34, 38])
    rd   r@   )r   r   )rg   r]   rA   rB   rU   s        rH   r   r   ?  s     ^ e+GW5IIrJ   rd   c                    y rD   rE   rg   r]   s     rH   r   r   s      rJ   c                    y rD   rE   rl   s     rH   r   r   x  rI   rJ   c                    y rD   rE   rl   s     rH   r   r     rI   rJ   c               X    t        j                  |       |z  j                  t              S )a  Convert timestamps (in seconds) to sample indices.

    Parameters
    ----------
    times : number or np.ndarray
        Time value or array of time values (in seconds)
    sr : number > 0
        Sampling rate

    Returns
    -------
    samples : int or np.ndarray [shape=times.shape, dtype=int]
        Sample indices corresponding to values in ``times``

    See Also
    --------
    time_to_frames : convert time values to frame indices
    samples_to_time : convert sample indices to time values

    Examples
    --------
    >>> librosa.time_to_samples(np.arange(0, 1, 0.1), sr=22050)
    array([    0,  2205,  4410,  6615,  8820, 11025, 13230, 15435,
           17640, 19845])
    )rO   rP   rQ   rN   rl   s     rH   r   r     s#    8 MM% 2%--c22rJ   c                    y rD   rE   rU   r]   s     rH   r   r     rm   rJ   c                    y rD   rE   rr   s     rH   r   r     rI   rJ   c                    y rD   rE   rr   s     rH   r   r     rI   rJ   c               D    t        j                  |       t        |      z  S )a"  Convert sample indices to time (in seconds).

    Parameters
    ----------
    samples : np.ndarray
        Sample index or array of sample indices
    sr : number > 0
        Sampling rate

    Returns
    -------
    times : np.ndarray [shape=samples.shape]
        Time values corresponding to ``samples`` (in seconds)

    See Also
    --------
    samples_to_frames : convert sample indices to frame indices
    time_to_samples : convert time values to sample indices

    Examples
    --------
    Get timestamps corresponding to every 512 samples

    >>> librosa.samples_to_time(np.arange(0, 22050, 512), sr=22050)
    array([ 0.   ,  0.023,  0.046,  0.07 ,  0.093,  0.116,  0.139,
            0.163,  0.186,  0.209,  0.232,  0.255,  0.279,  0.302,
            0.325,  0.348,  0.372,  0.395,  0.418,  0.441,  0.464,
            0.488,  0.511,  0.534,  0.557,  0.58 ,  0.604,  0.627,
            0.65 ,  0.673,  0.697,  0.72 ,  0.743,  0.766,  0.789,
            0.813,  0.836,  0.859,  0.882,  0.906,  0.929,  0.952,
            0.975,  0.998])
    )rO   rP   floatrr   s     rH   r   r     s    F ==!E"I--rJ   c                    y rD   rE   blocksblock_lengths     rH   r   r     rm   rJ   c                    y rD   rE   rx   s     rH   r   r     rI   rJ   c                    y rD   rE   rx   s     rH   r   r     rI   rJ   c               2    |t        j                  |       z  S )aZ  Convert block indices to frame indices

    Parameters
    ----------
    blocks : np.ndarray
        Block index or array of block indices
    block_length : int > 0
        The number of frames per block

    Returns
    -------
    frames : np.ndarray [shape=samples.shape, dtype=int]
        The index or indices of frames corresponding to the beginning
        of each provided block.

    See Also
    --------
    blocks_to_samples
    blocks_to_time

    Examples
    --------
    Get frame indices for each block in a stream

    >>> filename = librosa.ex('brahms')
    >>> sr = librosa.get_samplerate(filename)
    >>> stream = librosa.stream(filename, block_length=16,
    ...                         frame_length=2048, hop_length=512)
    >>> for n, y in enumerate(stream):
    ...     n_frame = librosa.blocks_to_frames(n, block_length=16)

    rO   rP   rx   s     rH   r   r     s    F "--///rJ   c                    y rD   rE   ry   rz   rA   s      rH   r   r     rI   rJ   c                    y rD   rE   r   s      rH   r   r     rI   rJ   c                    y rD   rE   r   s      rH   r   r   %  rI   rJ   c               6    t        | |      }t        ||      S )ad  Convert block indices to sample indices

    Parameters
    ----------
    blocks : np.ndarray
        Block index or array of block indices
    block_length : int > 0
        The number of frames per block
    hop_length : int > 0
        The number of samples to advance between frames

    Returns
    -------
    samples : np.ndarray [shape=samples.shape, dtype=int]
        The index or indices of samples corresponding to the beginning
        of each provided block.

        Note that these correspond to the *first* sample index in
        each block, and are not frame-centered.

    See Also
    --------
    blocks_to_frames
    blocks_to_time

    Examples
    --------
    Get sample indices for each block in a stream

    >>> filename = librosa.ex('brahms')
    >>> sr = librosa.get_samplerate(filename)
    >>> stream = librosa.stream(filename, block_length=16,
    ...                         frame_length=2048, hop_length=512)
    >>> for n, y in enumerate(stream):
    ...     n_sample = librosa.blocks_to_samples(n, block_length=16,
    ...                                          hop_length=512)

    )rz   )rA   )r   r   )ry   rz   rA   rG   s       rH   r   r   ,  s    R f<@FV
;;rJ   c                    y rD   rE   ry   rz   rA   r]   s       rH   r   r   Y  rI   rJ   c                    y rD   rE   r   s       rH   r   r   `  rI   rJ   c                    y rD   rE   r   s       rH   r   r   g  r`   rJ   c               8    t        | ||      }t        ||      S )a  Convert block indices to time (in seconds)

    Parameters
    ----------
    blocks : np.ndarray
        Block index or array of block indices
    block_length : int > 0
        The number of frames per block
    hop_length : int > 0
        The number of samples to advance between frames
    sr : int > 0
        The sampling rate (samples per second)

    Returns
    -------
    times : np.ndarray [shape=samples.shape]
        The time index or indices (in seconds) corresponding to the
        beginning of each provided block.

        Note that these correspond to the time of the *first* sample
        in each block, and are not frame-centered.

    See Also
    --------
    blocks_to_frames
    blocks_to_samples

    Examples
    --------
    Get time indices for each block in a stream

    >>> filename = librosa.ex('brahms')
    >>> sr = librosa.get_samplerate(filename)
    >>> stream = librosa.stream(filename, block_length=16,
    ...                         frame_length=2048, hop_length=512)
    >>> for n, y in enumerate(stream):
    ...     n_time = librosa.blocks_to_time(n, block_length=16,
    ...                                     hop_length=512, sr=sr)

    )rz   rA   rd   )r   r   )ry   rz   rA   r]   rU   s        rH   r   r   r  s%    ^  \jG 7r**rJ   c                     y rD   rE   notekwargss     rH   r   r     rm   rJ   c                     y rD   rE   r   s     rH   r   r     rm   rJ   c                     y rD   rE   r   s     rH   r   r     rI   rJ   c                ,    t        t        | fi |      S )a1  Convert one or more note names to frequency (Hz)

    Examples
    --------
    >>> # Get the frequency of a note
    >>> librosa.note_to_hz('C')
    array([ 16.352])
    >>> # Or multiple notes
    >>> librosa.note_to_hz(['A3', 'A4', 'A5'])
    array([ 220.,  440.,  880.])
    >>> # Or notes with tuning deviations
    >>> librosa.note_to_hz('C2-32', round_midi=False)
    array([ 64.209])

    Parameters
    ----------
    note : str or iterable of str
        One or more note names to convert
    **kwargs : additional keyword arguments
        Additional parameters to `note_to_midi`

    Returns
    -------
    frequencies : number or np.ndarray [shape=(len(note),)]
        Array of frequencies (in Hz) corresponding to ``note``

    See Also
    --------
    midi_to_hz
    note_to_midi
    hz_to_note
    )r!   r    r   s     rH   r   r     s    F l426233rJ   
round_midic                    y rD   rE   r   r   s     rH   r    r      rm   rJ   c                    y rD   rE   r   s     rH   r    r      rm   rJ   c                    y rD   rE   r   s     rH   r    r      rI   rJ   Tc          
        t        | t              s.t        j                  | D cg c]  }t	        ||       c}      S dddddddd	}d
dddd
ddddd	}t
        j                  j                  |       }|st        d| d      |j                  d      j                         }t        j                  |j                  d      D cg c]  }||   	 c}      }|j                  d      }	|j                  d      }
|	sd}	nt        |	      }	|
sd}
nt        |
      dz  }
d|	d
z   z  ||   z   |z   |
z   }|rt        t        j                  |            S |S c c}w c c}w )u  Convert one or more spelled notes to MIDI number(s).

    Notes may be spelled out with optional accidentals or octave numbers.

    The leading note name is case-insensitive.

    Sharps are indicated with ``#``, flats may be indicated with ``!`` or ``b``.

    Parameters
    ----------
    note : str or iterable of str
        One or more note names.
    round_midi : bool
        - If ``True``, midi numbers are rounded to the nearest integer.
        - If ``False``, allow fractional midi numbers.

    Returns
    -------
    midi : float or np.array
        Midi note numbers corresponding to inputs.

    Raises
    ------
    ParameterError
        If the input is not in valid note format

    See Also
    --------
    midi_to_note
    note_to_hz

    Examples
    --------
    >>> librosa.note_to_midi('C')
    12
    >>> librosa.note_to_midi('C#3')
    49
    >>> librosa.note_to_midi('C♯3')  # Using Unicode sharp
    49
    >>> librosa.note_to_midi('C♭3')  # Using Unicode flat
    47
    >>> librosa.note_to_midi('f4')
    65
    >>> librosa.note_to_midi('Bb-1')
    10
    >>> librosa.note_to_midi('A!8')
    116
    >>> librosa.note_to_midi('G𝄪6')  # Double-sharp
    93
    >>> librosa.note_to_midi('B𝄫6')  # Double-flat
    93
    >>> librosa.note_to_midi('C♭𝄫5')  # Triple-flats also work
    69
    >>> # Lists of notes also work
    >>> librosa.note_to_midi(['C', 'E', 'G'])
    array([12, 16, 19])
    r   r   r            	      )CDEFGABr   )	# b!u   ♯u   𝄪u   ♭u   𝄫u   ♮zImproper note format: sr   
accidentaloctavecentsg{Gz?   )
isinstancestrrO   arrayr    r   NOTE_REmatchr   groupuppersumrN   round)r   r   n	pitch_mapacc_mapr   pitchorR   r   r   
note_values               rH   r    r      sx   x dC xxNAaJ?NOO !I 
G ""4(E5d1X>??KK%%'EVV\)BC)BAWQZ)BCDF[["FKK EVE
T!fqj)Ie,<<vEMJ288J'((a O: Ds   EE)r   r   keyunicodec                    y rD   rE   midir   r   r   r   s        rH   r"   r"   _       rJ   c                    y rD   rE   r   s        rH   r"   r"   k  r   rJ   c                    y rD   rE   r   s        rH   r"   r"   w  r   rJ   )excludedFzC:majc               B   |r|st        d      t        j                  ||      }t        t	        j
                  |             }t        dt	        j                  | |z
  d      z        }||dz     }|r!dj                  |t        |dz        dz
        }|r|d|d	}|S )
u  Convert one or more MIDI numbers to note strings.

    MIDI numbers will be rounded to the nearest integer.

    Notes will be of the format 'C0', 'C♯0', 'D0', ...

    Examples
    --------
    >>> librosa.midi_to_note(0)
    'C-1'

    >>> librosa.midi_to_note(37)
    'C♯2'

    >>> librosa.midi_to_note(37, unicode=False)
    'C#2'

    >>> librosa.midi_to_note(-2)
    'A♯-2'

    >>> librosa.midi_to_note(104.7)
    'A7'

    >>> librosa.midi_to_note(104.7, cents=True)
    'A7-30'

    >>> librosa.midi_to_note(np.arange(12, 24)))
    array(['C0', 'C♯0', 'D0', 'D♯0', 'E0', 'F0', 'F♯0', 'G0', 'G♯0', 'A0',
           'A♯0', 'B0'], dtype='<U3')

    Use a key signature to resolve enharmonic equivalences

    >>> librosa.midi_to_note(range(12, 24), key='F:min')
    array(['C0', 'D♭0', 'D0', 'E♭0', 'E0', 'F0', 'G♭0', 'G0', 'A♭0', 'A0',
           'B♭0', 'B0'], dtype='<U3')

    Parameters
    ----------
    midi : int or iterable of int
        Midi numbers to convert.

    octave : bool
        If True, include the octave number

    cents : bool
        If true, cent markers will be appended for fractional notes.
        Eg, ``midi_to_note(69.3, cents=True) == 'A4+03'``

    key : str
        A key signature to use when resolving enharmonic equivalences.

    unicode : bool
        If ``True`` (default), accidentals will use Unicode notation: ♭ or ♯

        If ``False``, accidentals will use ASCII-compatible notation: b or #

    Returns
    -------
    notes : str or np.ndarray of str
        Strings describing each midi note.

    Raises
    ------
    ParameterError
        if ``cents`` is True and ``octave`` is False

    See Also
    --------
    midi_to_hz
    note_to_midi
    hz_to_note
    key_to_notes
    z/Cannot encode cents without octave information.)r   r   d   r   r   z	{:s}{:0d}r   r   z+02d)r   r   key_to_notesrN   rO   r   aroundformat)	r   r   r   r   r   note_mapnote_num
note_centsr   s	            rH   r"   r"     s    d VNOO$$g>H 288D>"HS299TH_a889JHrM"D!!$HrM(:Q(>?q*T*+KrJ   c                     y rD   rE   notess    rH   r!   r!     rm   rJ   c                     y rD   rE   r   s    rH   r!   r!     rm   rJ   c                     y rD   rE   r   s    rH   r!   r!     rI   rJ   c                D    ddt        j                  |       dz
  dz  z  z  S )ax  Get the frequency (Hz) of MIDI note(s)

    Examples
    --------
    >>> librosa.midi_to_hz(36)
    65.406

    >>> librosa.midi_to_hz(np.arange(36, 48))
    array([  65.406,   69.296,   73.416,   77.782,   82.407,
             87.307,   92.499,   97.999,  103.826,  110.   ,
            116.541,  123.471])

    Parameters
    ----------
    notes : int or np.ndarray [shape=(n,), dtype=int]
        midi number(s) of the note(s)

    Returns
    -------
    frequency : number or np.ndarray [shape=(n,), dtype=float]
        frequency (frequencies) of ``notes`` in Hz

    See Also
    --------
    hz_to_midi
    note_to_hz
         {@       @g     @Q@g      (@r~   r   s    rH   r!   r!     s'    < CR]]51D8D@ABBrJ   c                     y rD   rE   frequenciess    rH   r$   r$     rm   rJ   c                     y rD   rE   r   s    rH   r$   r$     rm   rJ   c                     y rD   rE   r   s    rH   r$   r$   $  rI   rJ   c                    dt        j                  t        j                  |             t        j                  d      z
  z  dz   }|S )a  Get MIDI note number(s) for given frequencies

    Examples
    --------
    >>> librosa.hz_to_midi(60)
    34.506
    >>> librosa.hz_to_midi([110, 220, 440])
    array([ 45.,  57.,  69.])

    Parameters
    ----------
    frequencies : float or np.ndarray [shape=(n,), dtype=float]
        frequencies to convert

    Returns
    -------
    note_nums : number or np.ndarray [shape=(n,), dtype=float]
        MIDI notes to ``frequencies``

    See Also
    --------
    midi_to_hz
    note_to_midi
    hz_to_note
    r   r   E   rO   log2rP   )r   r   s     rH   r$   r$   +  s8    8 RWWR]];%?@2775>QRUWWDKrJ   c                     y rD   rE   r   r   s     rH   r#   r#   K  rm   rJ   c                     y rD   rE   r   s     rH   r#   r#   P  rm   rJ   c                     y rD   rE   r   s     rH   r#   r#   U  rI   rJ   c                ,    t        t        |       fi |S )a  Convert one or more frequencies (in Hz) to the nearest note names.

    Parameters
    ----------
    frequencies : float or iterable of float
        Input frequencies, specified in Hz
    **kwargs : additional keyword arguments
        Arguments passed through to `midi_to_note`

    Returns
    -------
    notes : str or np.ndarray of str
        ``notes[i]`` is the closest note name to ``frequency[i]``
        (or ``frequency`` if the input is scalar)

    See Also
    --------
    hz_to_midi
    midi_to_note
    note_to_hz

    Examples
    --------
    Get a single note name for a frequency

    >>> librosa.hz_to_note(440.0)
    'A5'

    Get multiple notes with cent deviation

    >>> librosa.hz_to_note([32, 64], cents=True)
    ['C1-38', 'C2-38']

    Get multiple notes, but suppress octave labels

    >>> librosa.hz_to_note(440.0 * (2.0 ** np.linspace(0, 1, 12)),
    ...                    octave=False)
    ['A', 'A#', 'B', 'C', 'C#', 'D', 'E', 'F', 'F#', 'G', 'G#', 'A']

    )r"   r$   r   s     rH   r#   r#   \  s    V 
;/:6::rJ   htkc                    y rD   rE   r   r   s     rH   r%   r%     rm   rJ   c                    y rD   rE   r   s     rH   r%   r%     rI   rJ   c                    y rD   rE   r   s     rH   r%   r%     rI   rJ   c                  t        j                  |       } |r dt        j                  d| dz  z         z  }|S d}d}| |z
  |z  }d}||z
  |z  }t        j                  d      dz  }| j                  r+| |k\  }|t        j                  | |   |z        |z  z   ||<   |S | |k\  r|t        j                  | |z        |z  z   }|S )	a  Convert Hz to Mels

    Examples
    --------
    >>> librosa.hz_to_mel(60)
    0.9
    >>> librosa.hz_to_mel([110, 220, 440])
    array([ 1.65,  3.3 ,  6.6 ])

    Parameters
    ----------
    frequencies : number or np.ndarray [shape=(n,)] , float
        scalar or array of frequencies
    htk : bool
        use HTK formula instead of Slaney

    Returns
    -------
    mels : number or np.ndarray [shape=(n,)]
        input frequencies in Mels

    See Also
    --------
    mel_to_hz
         F@      ?     @        竪P@     @@皙@      ;@)rO   rP   log10logndim)	r   r   melsf_minf_sp
min_log_hzmin_log_mellogsteplog_ts	            rH   r%   r%     s    8 --,K
!BHHS;3F-F$GG ED%4'D J%-KffSkD Gz)!BFF;u+=
+J$Kg$UUU
 K	 

	"RVVK*$<=GGKrJ   c                    y rD   rE   r   r   s     rH   r(   r(     rm   rJ   c                    y rD   rE   r   s     rH   r(   r(     rm   rJ   c                    y rD   rE   r   s     rH   r(   r(     rI   rJ   c               `   t        j                  |       } |rdd| dz  z  dz
  z  S d}d}||| z  z   }d}||z
  |z  }t        j                  d      d	z  }| j                  r+| |k\  }|t        j                  || |   |z
  z        z  ||<   |S | |k\  r|t        j                  || |z
  z        z  }|S )
a  Convert mel bin numbers to frequencies

    Examples
    --------
    >>> librosa.mel_to_hz(3)
    200.

    >>> librosa.mel_to_hz([1,2,3,4,5])
    array([  66.667,  133.333,  200.   ,  266.667,  333.333])

    Parameters
    ----------
    mels : np.ndarray [shape=(n,)], float
        mel bins to convert
    htk : bool
        use HTK formula instead of Slaney

    Returns
    -------
    frequencies : np.ndarray [shape=(n,)]
        input mels in Hz

    See Also
    --------
    hz_to_mel
    r   g      $@r   r   r   r   r   r   r   )rO   rP   r   r   exp)	r   r   r   r   freqsr   r   r   r   s	            rH   r(   r(     s    : ==D
/#566 EDD4KE J%-KffSkD Gyy#!BFF7d5kK6O+P$QQe
 L	 
	RVVGtk/A$BCCLrJ   tuningbins_per_octavec                    y rD   rE   r   r  r  s      rH   r&   r&     rI   rJ   c                    y rD   rE   r  s      rH   r&   r&   %  rL   rJ   c                    y rD   rE   r  s      rH   r&   r&   /  rL   rJ   r   r   c                   dd||z  z  z  }t        j                  t        j                  |       t        |      dz  z        }|S )a  Convert frequencies (Hz) to (fractional) octave numbers.

    Examples
    --------
    >>> librosa.hz_to_octs(440.0)
    4.
    >>> librosa.hz_to_octs([32, 64, 128, 256])
    array([ 0.219,  1.219,  2.219,  3.219])

    Parameters
    ----------
    frequencies : number >0 or np.ndarray [shape=(n,)] or float
        scalar or vector of frequencies
    tuning : float
        Tuning deviation from A440 in (fractional) bins per octave.
    bins_per_octave : int > 0
        Number of bins per octave.

    Returns
    -------
    octaves : number or np.ndarray [shape=(n,)]
        octave number for each frequency

    See Also
    --------
    octs_to_hz
    r   r      )rO   r   rP   rv   )r   r  r  A440octss        rH   r&   r&   9  sC    B 36O344Dwwr}}[9U4[2=MNODKrJ   c                    y rD   rE   r  r  r  s      rH   r)   r)   `  rI   rJ   c                    y rD   rE   r  s      rH   r)   r)   g  rL   rJ   c                    y rD   rE   r  s      rH   r)   r)   q  rL   rJ   c               f    dd||z  z  z  }t        |      dz  dt        j                  |       z  z  S )a  Convert octaves numbers to frequencies.

    Octaves are counted relative to A.

    Examples
    --------
    >>> librosa.octs_to_hz(1)
    55.
    >>> librosa.octs_to_hz([-2, -1, 0, 1, 2])
    array([   6.875,   13.75 ,   27.5  ,   55.   ,  110.   ])

    Parameters
    ----------
    octs : np.ndarray [shape=(n,)] or float
        octave number for each frequency
    tuning : float
        Tuning deviation from A440 in (fractional) bins per octave.
    bins_per_octave : int > 0
        Number of bins per octave.

    Returns
    -------
    frequencies : number or np.ndarray [shape=(n,)]
        scalar or vector of frequencies

    See Also
    --------
    hz_to_octs
    r   r   r  )rv   rO   rP   )r  r  r  r  s       rH   r)   r)   {  s;    F 36O344D$K"d(;!;<<rJ   )r  c                    y rD   rE   A4r  s     rH   r*   r*     rm   rJ   c                    y rD   rE   r  s     rH   r*   r*     rI   rJ   c                    y rD   rE   r  s     rH   r*   r*     rI   rJ   c                   |t        j                  t        j                  |             t        j                  d      z
  z  }|S )a  Convert a reference pitch frequency (e.g., ``A4=435``) to a tuning
    estimation, in fractions of a bin per octave.

    This is useful for determining the tuning deviation relative to
    A440 of a given frequency, assuming equal temperament. By default,
    12 bins per octave are used.

    This method is the inverse of `tuning_to_A4`.

    Examples
    --------
    The base case of this method in which A440 yields 0 tuning offset
    from itself.

    >>> librosa.A4_to_tuning(440.0)
    0.

    Convert a non-A440 frequency to a tuning offset relative
    to A440 using the default of 12 bins per octave.

    >>> librosa.A4_to_tuning(432.0)
    -0.318

    Convert two reference pitch frequencies to corresponding
    tuning estimations at once, but using 24 bins per octave.

    >>> librosa.A4_to_tuning([440.0, 444.0], bins_per_octave=24)
    array([   0.,   0.313   ])

    Parameters
    ----------
    A4 : float or np.ndarray [shape=(n,), dtype=float]
        Reference frequency(s) corresponding to A4.
    bins_per_octave : int > 0
        Number of bins per octave.

    Returns
    -------
    tuning : float or np.ndarray [shape=(n,), dtype=float]
        Tuning deviation from A440 in (fractional) bins per octave.

    See Also
    --------
    tuning_to_A4
    r   r   )r  r  r  s      rH   r*   r*     s4    ` )BGGBMM"4E,FQV,WXFMrJ   c                    y rD   rE   r  s     rH   r+   r+     rI   rJ   c                    y rD   rE   r  s     rH   r+   r+     rI   rJ   c                    y rD   rE   r  s     rH   r+   r+     rI   rJ   c               >    ddt        j                  |       |z  z  z  S )a@  Convert a tuning deviation (from 0) in fractions of a bin per
    octave (e.g., ``tuning=-0.1``) to a reference pitch frequency
    relative to A440.

    This is useful if you are working in a non-A440 tuning system
    to determine the reference pitch frequency given a tuning
    offset and assuming equal temperament. By default, 12 bins per
    octave are used.

    This method is the inverse of  `A4_to_tuning`.

    Examples
    --------
    The base case of this method in which a tuning deviation of 0
    gets us to our A440 reference pitch.

    >>> librosa.tuning_to_A4(0.0)
    440.

    Convert a nonzero tuning offset to its reference pitch frequency.

    >>> librosa.tuning_to_A4(-0.318)
    431.992

    Convert 3 tuning deviations at once to respective reference
    pitch frequencies, using 36 bins per octave.

    >>> librosa.tuning_to_A4([0.1, 0.2, -0.1], bins_per_octave=36)
    array([   440.848,    441.698   439.154])

    Parameters
    ----------
    tuning : float or np.ndarray [shape=(n,), dtype=float]
        Tuning deviation from A440 in fractional bins per octave.
    bins_per_octave : int > 0
        Number of bins per octave.

    Returns
    -------
    A4 : float or np.ndarray [shape=(n,), dtype=float]
        Reference frequency corresponding to A4.

    See Also
    --------
    A4_to_tuning
    r   r   r~   r  s     rH   r+   r+     s#    b 32==0?BCCCrJ   i   r]   rB   c                J    t         j                  j                  |d| z        S )a  Alternative implementation of `np.fft.fftfreq`

    Parameters
    ----------
    sr : number > 0 [scalar]
        Audio sampling rate
    n_fft : int > 0 [scalar]
        FFT window size

    Returns
    -------
    freqs : np.ndarray [shape=(1 + n_fft/2,)]
        Frequencies ``(0, sr/n_fft, 2*sr/n_fft, ..., sr/2)``

    Examples
    --------
    >>> librosa.fft_frequencies(sr=22050, n_fft=16)
    array([     0.   ,   1378.125,   2756.25 ,   4134.375,
             5512.5  ,   6890.625,   8268.75 ,   9646.875,  11025.   ])
    r   )r   d)rO   fftrfftfreqr  s     rH   r,   r,   3  s    * 66??UcBh?//rJ   )r  r  c               x    dt        |      |z  z  }dt        j                  d| t               |z  z  }||z  |z  S )a  Compute the center frequencies of Constant-Q bins.

    Examples
    --------
    >>> # Get the CQT frequencies for 24 notes, starting at C2
    >>> librosa.cqt_frequencies(24, fmin=librosa.note_to_hz('C2'))
    array([  65.406,   69.296,   73.416,   77.782,   82.407,   87.307,
             92.499,   97.999,  103.826,  110.   ,  116.541,  123.471,
            130.813,  138.591,  146.832,  155.563,  164.814,  174.614,
            184.997,  195.998,  207.652,  220.   ,  233.082,  246.942])

    Parameters
    ----------
    n_bins : int > 0 [scalar]
        Number of constant-Q bins
    fmin : float > 0 [scalar]
        Minimum frequency
    bins_per_octave : int > 0 [scalar]
        Number of bins per octave
    tuning : float
        Deviation from A440 tuning in fractional bins

    Returns
    -------
    frequencies : np.ndarray [shape=(n_bins,)]
        Center frequency for each CQT bin
    r   r   rY   )rv   rO   arange)n_binsfminr  r  
correctionr   s         rH   r-   r-   K  sH    < f ?@J!
		!V5)O;K {**rJ   g    @)r&  fmaxr   c                   t        ||      }t        ||      }t        j                  |||       }t        ||      }|S )a  Compute an array of acoustic frequencies tuned to the mel scale.

    The mel scale is a quasi-logarithmic function of acoustic frequency
    designed such that perceptually similar pitch intervals (e.g. octaves)
    appear equal in width over the full hearing range.

    Because the definition of the mel scale is conditioned by a finite number
    of subjective psychoaoustical experiments, several implementations coexist
    in the audio signal processing literature [#]_. By default, librosa replicates
    the behavior of the well-established MATLAB Auditory Toolbox of Slaney [#]_.
    According to this default implementation,  the conversion from Hertz to mel is
    linear below 1 kHz and logarithmic above 1 kHz. Another available implementation
    replicates the Hidden Markov Toolkit [#]_ (HTK) according to the following formula::

        mel = 2595.0 * np.log10(1.0 + f / 700.0).

    The choice of implementation is determined by the ``htk`` keyword argument: setting
    ``htk=False`` leads to the Auditory toolbox implementation, whereas setting it ``htk=True``
    leads to the HTK implementation.

    .. [#] Umesh, S., Cohen, L., & Nelson, D. Fitting the mel scale.
        In Proc. International Conference on Acoustics, Speech, and Signal Processing
        (ICASSP), vol. 1, pp. 217-220, 1998.

    .. [#] Slaney, M. Auditory Toolbox: A MATLAB Toolbox for Auditory
        Modeling Work. Technical Report, version 2, Interval Research Corporation, 1998.

    .. [#] Young, S., Evermann, G., Gales, M., Hain, T., Kershaw, D., Liu, X.,
        Moore, G., Odell, J., Ollason, D., Povey, D., Valtchev, V., & Woodland, P.
        The HTK book, version 3.4. Cambridge University, March 2009.

    See Also
    --------
    hz_to_mel
    mel_to_hz
    librosa.feature.melspectrogram
    librosa.feature.mfcc

    Parameters
    ----------
    n_mels : int > 0 [scalar]
        Number of mel bins.
    fmin : float >= 0 [scalar]
        Minimum frequency (Hz).
    fmax : float >= 0 [scalar]
        Maximum frequency (Hz).
    htk : bool
        If True, use HTK formula to convert Hz to mel.
        Otherwise (False), use Slaney's Auditory Toolbox.

    Returns
    -------
    bin_frequencies : ndarray [shape=(n_mels,)]
        Vector of ``n_mels`` frequencies in Hz which are uniformly spaced on the Mel
        axis.

    Examples
    --------
    >>> librosa.mel_frequencies(n_mels=40)
    array([     0.   ,     85.317,    170.635,    255.952,
              341.269,    426.586,    511.904,    597.221,
              682.538,    767.855,    853.173,    938.49 ,
             1024.856,   1119.114,   1222.042,   1334.436,
             1457.167,   1591.187,   1737.532,   1897.337,
             2071.84 ,   2262.393,   2470.47 ,   2697.686,
             2945.799,   3216.731,   3512.582,   3835.643,
             4188.417,   4573.636,   4994.285,   5453.621,
             5955.205,   6502.92 ,   7101.009,   7754.107,
             8467.272,   9246.028,  10096.408,  11025.   ])

    r   )r%   rO   linspacer(   )n_melsr&  r(  r   min_melmax_melr   hzs           rH   r.   r.   q  s@    V #&G#&G;;w0Dt-BIrJ   )rA   r]   c                   t        j                  t        |       t         j                        }t         j                  |d<   d|z  |t        j
                  d|       z  z  |dd |S )a  Compute the frequencies (in beats per minute) corresponding
    to an onset auto-correlation or tempogram matrix.

    Parameters
    ----------
    n_bins : int > 0
        The number of lag bins
    hop_length : int > 0
        The number of samples between each bin
    sr : number > 0
        The audio sampling rate

    Returns
    -------
    bin_frequencies : ndarray [shape=(n_bins,)]
        vector of bin frequencies measured in BPM.

        .. note:: ``bin_frequencies[0] = +np.inf`` corresponds to 0-lag

    Examples
    --------
    Get the tempo frequencies corresponding to a 384-bin (8-second) tempogram

    >>> librosa.tempo_frequencies(384, sr=22050)
    array([      inf,  2583.984,  1291.992, ...,     6.782,
               6.764,     6.747])
    rY   r   g      N@r   r   N)rO   zerosrN   float64infr$  )r%  rA   r]   bin_frequenciess       rH   r/   r/     sU    < hhs6{"**=OOA)zBIIc64J'JKOABrJ   i  r]   
win_lengthrA   c                :    t        | dz  t        |      z  |      S )a  Compute the frequencies (in beats per minute) corresponding
    to a Fourier tempogram matrix.

    Parameters
    ----------
    sr : number > 0
        The audio sampling rate
    win_length : int > 0
        The number of frames per analysis window
    hop_length : int > 0
        The number of samples between each bin

    Returns
    -------
    bin_frequencies : ndarray [shape=(win_length // 2 + 1 ,)]
        vector of bin frequencies measured in BPM.

    Examples
    --------
    Get the tempo frequencies corresponding to a 384-bin (8-second) tempogram

    >>> librosa.fourier_tempo_frequencies(win_length=384, sr=22050)
    array([ 0.   ,  0.117,  0.234, ..., 22.266, 22.383, 22.5  ])
    <   r  )r,   rv   r4  s      rH   r0   r0     s    : b2gj(99LLrJ   )min_dbc                    y rD   rE   r   r8  s     rH   r1   r1     rI   rJ   c                    y rD   rE   r:  s     rH   r1   r1     rI   rJ   c                    y rD   rE   r:  s     rH   r1   r1     rI   rJ   g      Tc          	        t        j                  |       dz  }t        j                  g d      dz  }ddt        j                  |d         dt        j                  |      z  z   t        j                  ||d   z         z
  t        j                  ||d   z         z
  dt        j                  ||d   z         z  z
  dt        j                  ||d   z         z  z
  z  z   }||S t        j                  ||      S )	a  Compute the A-weighting of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    min_db : float [scalar] or None
        Clip weights below this threshold.
        If `None`, no clipping is performed.

    Returns
    -------
    A_weighting : scalar or np.ndarray [shape=(n,)]
        ``A_weighting[i]`` is the A-weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    multi_frequency_weighting
    B_weighting
    C_weighting
    D_weighting

    Examples
    --------
    Get the A-weighting for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weights = librosa.A_weighting(freqs)
    >>> fig, ax = plt.subplots()
    >>> ax.plot(freqs, weights)
    >>> ax.set(xlabel='Frequency (Hz)',
    ...        ylabel='Weighting (log10)',
    ...        title='A-Weighting of CQT frequencies')
    r   )@fW4@g oZ@g
@      4@r   r   r         ?   rO   rP   r   r   maximumr   r8  f_sqconstweightss        rH   r1   r1   !  s    P ==%,DHHABcIE
q
bhhtn
	
((4%(?
#	$ ((4%(?
#	$ a)
)		*
 a)
)	*! G ~zz&'**rJ   c                    y rD   rE   r:  s     rH   r2   r2   [  rI   rJ   c                    y rD   rE   r:  s     rH   r2   r2   b  rI   rJ   c                    y rD   rE   r:  s     rH   r2   r2   i  rI   rJ   c          	        t        j                  |       dz  }t        j                  g d      dz  }ddt        j                  |d         dt        j                  |      z  z   t        j                  ||d   z         z
  t        j                  ||d   z         z
  dt        j                  ||d	   z         z  z
  z  z   }||S t        j                  ||      S )
a  Compute the B-weighting of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    min_db : float [scalar] or None
        Clip weights below this threshold.
        If `None`, no clipping is performed.

    Returns
    -------
    B_weighting : scalar or np.ndarray [shape=(n,)]
        ``B_weighting[i]`` is the B-weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    multi_frequency_weighting
    A_weighting
    C_weighting
    D_weighting

    Examples
    --------
    Get the B-weighting for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weights = librosa.B_weighting(freqs)
    >>> fig, ax = plt.subplots()
    >>> ax.plot(freqs, weights)
    >>> ax.set(xlabel='Frequency (Hz)',
    ...        ylabel='Weighting (log10)',
    ...        title='B-Weighting of CQT frequencies')
    r   )r>  r?  gjc@g(\?r@  r   g      ?r   rA  r   rC  rE  s        rH   r2   r2   p  s    P ==%,DHH673>E
q

	
((4%(?
#	$ ((4%(?
#	$ a)
)		*" G n7E"**VW*EErJ   c                    y rD   rE   r:  s     rH   r3   r3     rI   rJ   c                    y rD   rE   r:  s     rH   r3   r3     rI   rJ   c                    y rD   rE   r:  s     rH   r3   r3     rI   rJ   c               r   t        j                  |       dz  }t        j                  ddg      dz  }ddt        j                  |d         t        j                  |      z   t        j                  ||d   z         z
  t        j                  ||d   z         z
  z  z   }||S t        j                  ||      S )a  Compute the C-weighting of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    min_db : float [scalar] or None
        Clip weights below this threshold.
        If `None`, no clipping is performed.

    Returns
    -------
    C_weighting : scalar or np.ndarray [shape=(n,)]
        ``C_weighting[i]`` is the C-weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    multi_frequency_weighting
    A_weighting
    B_weighting
    D_weighting

    Examples
    --------
    Get the C-weighting for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weights = librosa.C_weighting(freqs)
    >>> fig, ax = plt.subplots()
    >>> ax.plot(freqs, weights)
    >>> ax.set(xlabel='Frequency (Hz)', ylabel='Weighting (log10)',
    ...        title='C-Weighting of CQT frequencies')
    r   r>  r?  gX9v?r@  r   r   rC  rE  s        rH   r3   r3     s    N ==%,DHHi+,3E$
q
((4.	
((4%(?
#	$ ((4%(?
#	$# G n7E"**VW*EErJ   c                    y rD   rE   r:  s     rH   r4   r4     rI   rJ   c                    y rD   rE   r:  s     rH   r4   r4     rI   rJ   c                    y rD   rE   r:  s     rH   r4   r4     rI   rJ   c          	        t        j                  |       dz  }t        j                  g d      dz  }ddt        j                  |      z  t        j                  |d         z
  dt        j                  |d   |z
  dz  |d   |z  z         t        j                  |d   |z
  dz  |d	   |z  z         z
  t        j                  |d
   |z         z
  t        j                  |d   |z         z
  z  z   z  }||S t        j                  ||      S )a  Compute the D-weighting of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    min_db : float [scalar] or None
        Clip weights below this threshold.
        If `None`, no clipping is performed.

    Returns
    -------
    D_weighting : scalar or np.ndarray [shape=(n,)]
        ``D_weighting[i]`` is the D-weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    multi_frequency_weighting
    A_weighting
    B_weighting
    C_weighting

    Examples
    --------
    Get the D-weighting for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weights = librosa.D_weighting(freqs)
    >>> fig, ax = plt.subplots()
    >>> ax.plot(freqs, weights)
    >>> ax.set(xlabel='Frequency (Hz)', ylabel='Weighting (log10)',
    ...        title='D-Weighting of CQT frequencies')
    r   )g9?gՏ@gfffff>@g     @i`  g33333q@i  r@  rA  r   r   r   rB  r   r      rC  rE  s        rH   r4   r4     s   N ==%,DHHNOSVVEbhhtn
((58
	
XXuQx$1,uQx$>??hha4A-a4?@AhhuQx$'( hhuQx$'(
	

G ~zz&'**rJ   c               r    t        j                  t        |             }||S t        j                  ||      S )a#  Apply no weighting curve (aka Z-weighting).

    This function behaves similarly to `A_weighting`, `B_weighting`, etc.,
    but all frequencies are equally weighted.
    An optional threshold `min_db` can still be used to clip energies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    min_db : float [scalar] or None
        Clip weights below this threshold.
        If `None`, no clipping is performed.

    Returns
    -------
    Z_weighting : scalar or np.ndarray [shape=(n,)]
        ``Z_weighting[i]`` is the Z-weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    multi_frequency_weighting
    A_weighting
    B_weighting
    C_weighting
    D_weighting
    )rO   r0  lenrD  )r   r8  rH  s      rH   r5   r5   @  s3    @ hhs;'(G~zz&'**rJ   )r   r   r   r   ZNzGDict[Optional[str], Callable[..., Union[np.floating[Any], np.ndarray]]]WEIGHTING_FUNCTIONS)kindc                    y rD   rE   r   rZ  r   s      rH   r6   r6   s  rI   rJ   c                    y rD   rE   r\  s      rH   r6   r6   z  rI   rJ   c                    y rD   rE   r\  s      rH   r6   r6     rI   rJ   r   c               `    t        |t              r|j                         }t        |   | fi |S )a2  Compute the weighting of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    kind : str in
        The weighting kind. e.g. `'A'`, `'B'`, `'C'`, `'D'`, `'Z'`
    **kwargs
        Additional keyword arguments to A_weighting, B_weighting, etc.

    Returns
    -------
    weighting : scalar or np.ndarray [shape=(n,)]
        ``weighting[i]`` is the weighting of ``frequencies[i]``

    See Also
    --------
    perceptual_weighting
    multi_frequency_weighting
    A_weighting
    B_weighting
    C_weighting
    D_weighting

    Examples
    --------
    Get the A-weighting for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weights = librosa.frequency_weighting(freqs, kind='A')
    >>> fig, ax = plt.subplots()
    >>> ax.plot(freqs, weights)
    >>> ax.set(xlabel='Frequency (Hz)', ylabel='Weighting (log10)',
    ...        title='A-Weighting of CQT frequencies')
    )r   r   r   rY  r\  s      rH   r6   r6     s/    P $zz|t$[;F;;rJ   ZAC)kindsc          
     n    t        j                  |D cg c]  }t        | fd|i| c}d      S c c}w )a  Compute multiple weightings of a set of frequencies.

    Parameters
    ----------
    frequencies : scalar or np.ndarray [shape=(n,)]
        One or more frequencies (in Hz)
    kinds : list or tuple or str
        An iterable of weighting kinds. e.g. `('Z', 'B')`, `'ZAD'`, `'C'`
    **kwargs : keywords to pass to the weighting function.

    Returns
    -------
    weighting : scalar or np.ndarray [shape=(len(kinds), n)]
        ``weighting[i, j]`` is the weighting of ``frequencies[j]``
        using the curve determined by ``kinds[i]``.

    See Also
    --------
    perceptual_weighting
    frequency_weighting
    A_weighting
    B_weighting
    C_weighting
    D_weighting

    Examples
    --------
    Get the A, B, C, D, and Z weightings for CQT frequencies

    >>> import matplotlib.pyplot as plt
    >>> freqs = librosa.cqt_frequencies(n_bins=108, fmin=librosa.note_to_hz('C1'))
    >>> weightings = 'ABCDZ'
    >>> weights = librosa.multi_frequency_weighting(freqs, kinds=weightings)
    >>> fig, ax = plt.subplots()
    >>> for label, w in zip(weightings, weights):
    ...     ax.plot(freqs, w, label=label)
    >>> ax.set(xlabel='Frequency (Hz)', ylabel='Weighting (log10)',
    ...        title='Weightings of CQT frequencies')
    >>> ax.legend()
    rZ  r   )axis)rO   stackr6   )r   ra  r   ks       rH   r7   r7     s>    \ 88EJKU	[	;q	;F	;UKRS Ks   2r   )r]   rA   rB   rc  c               >    t        | |||      }t        ||      }|S )a  Return an array of time values to match the time axis from a feature matrix.

    Parameters
    ----------
    X : np.ndarray or scalar
        - If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
        - If scalar, X represents the number of frames.
    sr : number > 0 [scalar]
        audio sampling rate
    hop_length : int > 0 [scalar]
        number of samples between successive frames
    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``n_fft // 2``
        to counteract windowing effects when using a non-centered STFT.
    axis : int [scalar]
        The axis representing the time axis of X.
        By default, the last axis (-1) is taken.

    Returns
    -------
    times : np.ndarray [shape=(n,)]
        ndarray of times (in seconds) corresponding to each frame of X.

    See Also
    --------
    samples_like :
        Return an array of sample indices to match the time axis from a feature matrix.

    Examples
    --------
    Provide a feature matrix input:

    >>> y, sr = librosa.load(librosa.ex('trumpet'))
    >>> D = librosa.stft(y)
    >>> times = librosa.times_like(D, sr=sr)
    >>> times
    array([0.   , 0.023, ..., 5.294, 5.317])

    Provide a scalar input:

    >>> n_frames = 2647
    >>> times = librosa.times_like(n_frames, sr=sr)
    >>> times
    array([  0.00000000e+00,   2.32199546e-02,   4.64399093e-02, ...,
             6.13935601e+01,   6.14167800e+01,   6.14400000e+01])
    rA   rB   rc  rd   )r8   r   )Xr]   rA   rB   rc  rU   times          rH   r9   r9     s&    n 15tLG&w26DKrJ   rg  c                   t        j                  |       rt        j                  |       }n"t        j                  | j                  |         }t	        |||      S )a  Return an array of sample indices to match the time axis from a feature matrix.

    Parameters
    ----------
    X : np.ndarray or scalar
        - If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
        - If scalar, X represents the number of frames.
    hop_length : int > 0 [scalar]
        number of samples between successive frames
    n_fft : None or int > 0 [scalar]
        Optional: length of the FFT window.
        If given, time conversion will include an offset of ``n_fft // 2``
        to counteract windowing effects when using a non-centered STFT.
    axis : int [scalar]
        The axis representing the time axis of ``X``.
        By default, the last axis (-1) is taken.

    Returns
    -------
    samples : np.ndarray [shape=(n,)]
        ndarray of sample indices corresponding to each frame of ``X``.

    See Also
    --------
    times_like :
        Return an array of time values to match the time axis from a feature matrix.

    Examples
    --------
    Provide a feature matrix input:

    >>> y, sr = librosa.load(librosa.ex('trumpet'))
    >>> X = librosa.stft(y)
    >>> samples = librosa.samples_like(X)
    >>> samples
    array([     0,    512, ..., 116736, 117248])

    Provide a scalar input:

    >>> n_frames = 2647
    >>> samples = librosa.samples_like(n_frames)
    >>> samples
    array([      0,     512,    1024, ..., 1353728, 1354240, 1354752])
    r@   )rO   isscalarr$  shaper   )rh  rA   rB   rc  rG   s        rH   r8   r8   $	  sB    h 
{{1~11774=)V
%HHrJ   )abbrr   r   c                    y rD   rE   r   Sarm  r   r   s        rH   r:   r:   _	  r   rJ   c                    y rD   rE   ro  s        rH   r:   r:   k	  r   rJ   c                    y rD   rE   ro  s        rH   r:   r:   w	  r   rJ   rp  rm  r   r   c               8   g d}t        d |D              }t        t        j                  | |z
              }|r	||dz     }n||dz     }|rMd|cxkD  rdk\  rn n|r|d   dz   |dd z   }|S |d	z  }|S d
|cxk  rdk  rn |S |r|d   dz   |dd z   }|S |dz  }|S )u  Convert MIDI numbers to Hindustani svara

    Parameters
    ----------
    midi : numeric or np.ndarray
        The MIDI number or numbers to convert

    Sa : number > 0
        MIDI number of the reference Sa.

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'r', 'R', 'g', 'G', ...)

        If `False`, return long-form names ('Sa', 're', 'Re', 'ga', 'Ga', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

        This only takes effect if `octave=True`.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given MIDI number(s)

    See Also
    --------
    hz_to_svara_h
    note_to_svara_h
    midi_to_svara_c
    midi_to_note

    Examples
    --------
    Convert a single midi number:

    >>> librosa.midi_to_svara_h(65, Sa=60)
    'm'

    The first three svara with Sa at midi number 60:

    >>> librosa.midi_to_svara_h([60, 61, 62], Sa=60)
    array(['S', 'r', 'R'], dtype='<U1')

    With Sa=67, midi 60-62 are in the octave below:

    >>> librosa.midi_to_svara_h([60, 61, 62], Sa=67)
    array(['ṃ', 'Ṃ', 'P̣'], dtype='<U2')

    Or without unicode decoration:

    >>> librosa.midi_to_svara_h([60, 61, 62], Sa=67, unicode=False)
    array(['m,', 'M,', 'P,'], dtype='<U2')

    Or going up an octave, with Sa=60, and using unabbreviated notes

    >>> librosa.midi_to_svara_h([72, 73, 74], Sa=60, abbr=False)
    array(['Ṡa', 'ṙe', 'Ṙe'], dtype='<U3')
    )rp  reRegaGamaMaPadhaDhaniNic              3  &   K   | ]	  }|d      yw)r   NrE   ).0r   s     rH   	<genexpr>z"midi_to_svara_h.<locals>.<genexpr>	  s     3A1Q4s   r      r      ̇r   N'   ̣,)listrN   rO   r   )	r   rp  rm  r   r   	SVARA_MAPSVARA_MAP_SHORT	svara_numsvaras	            rH   r:   r:   	  s    VI 333O BHHTBY'(I	B/)b.)	Ra8+eABi7 L  L I!! L a8+eABi7 L LrJ   c                    y rD   rE   r   rp  rm  r   r   s        rH   r>   r>   	  r   rJ   c                    y rD   rE   r  s        rH   r>   r>   
  r   rJ   c                    y rD   rE   r  s        rH   r>   r>   
  r   rJ   c               J    t        |       }t        |t        |      |||      S )u  Convert frequencies (in Hz) to Hindustani svara

    Note that this conversion assumes 12-tone equal temperament.

    Parameters
    ----------
    frequencies : positive number or np.ndarray
        The frequencies (in Hz) to convert

    Sa : positive number
        Frequency (in Hz) of the reference Sa.

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'r', 'R', 'g', 'G', ...)

        If `False`, return long-form names ('Sa', 're', 'Re', 'ga', 'Ga', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

        This only takes effect if `octave=True`.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given frequency/frequencies

    See Also
    --------
    midi_to_svara_h
    note_to_svara_h
    hz_to_svara_c
    hz_to_note

    Examples
    --------
    Convert Sa in three octaves:

    >>> librosa.hz_to_svara_h([261/2, 261, 261*2], Sa=261)
    ['Ṣ', 'S', 'Ṡ']

    Convert one octave worth of frequencies with full names:

    >>> freqs = librosa.cqt_frequencies(n_bins=12, fmin=261)
    >>> librosa.hz_to_svara_h(freqs, Sa=freqs[0], abbr=False)
    ['Sa', 're', 'Re', 'ga', 'Ga', 'ma', 'Ma', 'Pa', 'dha', 'Dha', 'ni', 'Ni']
    rs  )r$   r:   )r   rp  rm  r   r   midiss         rH   r>   r>   
  s+    | {#E*R.tFG rJ   c                    y rD   rE   r   rp  rm  r   r   s        rH   r<   r<   ^
  rI   rJ   c                    y rD   rE   r  s        rH   r<   r<   e
  r   rJ   c                    y rD   rE   r  s        rH   r<   r<   q
  r   rJ   c               N    t        | d      }t        |t        |      |||      S )u*  Convert western notes to Hindustani svara

    Note that this conversion assumes 12-tone equal temperament.

    Parameters
    ----------
    notes : str or iterable of str
        Notes to convert (e.g., `'C#'` or `['C4', 'Db4', 'D4']`

    Sa : str
        Note corresponding to Sa (e.g., `'C'` or `'C5'`).

        If no octave information is provided, it will default to octave 0
        (``C0`` ~= 16 Hz)

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'r', 'R', 'g', 'G', ...)

        If `False`, return long-form names ('Sa', 're', 'Re', 'ga', 'Ga', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

        This only takes effect if `octave=True`.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given notes

    See Also
    --------
    midi_to_svara_h
    hz_to_svara_h
    note_to_svara_c
    note_to_midi
    note_to_hz

    Examples
    --------
    >>> librosa.note_to_svara_h(['C4', 'G4', 'C5', 'G5'], Sa='C5')
    ['Ṣ', 'P̣', 'S', 'P']
    Fr   rs  )r    r:   )r   rp  rm  r   r   r  s         rH   r<   r<   }
  s.    t 51E,r"fg rJ   c                    y rD   rE   r   rp  melarm  r   r   s         rH   r;   r;   
       rJ   c                    y rD   rE   r  s         rH   r;   r;   
  r  rJ   c                    y rD   rE   r  s         rH   r;   r;   
  r  rJ   rp  r  rm  r   r   c               &   t        t        j                  | |z
              }t        j                  |||      }||dz     }|rMd|cxkD  rdk\  rn n|r|d   dz   |dd z   }|S |dz  }|S d	|cxk  rdk  rn |S |r|d   d
z   |dd z   }|S |dz  }|S )aW  Convert MIDI numbers to Carnatic svara within a given melakarta raga

    Parameters
    ----------
    midi : numeric
        The MIDI numbers to convert

    Sa : number > 0
        MIDI number of the reference Sa.

        Default: 60 (261.6 Hz, `C4`)

    mela : int or str
        The name or index of the melakarta raga

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'R1', 'R2', 'G1', 'G2', ...)

        If `False`, return long-form names ('Sa', 'Ri1', 'Ri2', 'Ga1', 'Ga2', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information and subscript
        numbers.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given MIDI number(s)

    See Also
    --------
    hz_to_svara_c
    note_to_svara_c
    mela_to_degrees
    mela_to_svara
    list_mela
    )rm  r   r   r  r   r  r   Nr  r  r  r  )rN   rO   r   r   mela_to_svara)	r   rp  r  rm  r   r   r  	svara_mapr  s	            rH   r;   r;   
  s    l BHHTBY'(I&&t$HIi"n%E	Ra8+eABi7 L  L I!! L a8+eABi7 L LrJ   c                    y rD   rE   r   rp  r  rm  r   r   s         rH   r?   r?   0  r  rJ   c                    y rD   rE   r  s         rH   r?   r?   =  r  rJ   c                    y rD   rE   r  s         rH   r?   r?   J  r  rJ   c               L    t        |       }t        |t        |      ||||      S )u]  Convert frequencies (in Hz) to Carnatic svara

    Note that this conversion assumes 12-tone equal temperament.

    Parameters
    ----------
    frequencies : positive number or np.ndarray
        The frequencies (in Hz) to convert

    Sa : positive number
        Frequency (in Hz) of the reference Sa.

    mela : int [1, 72] or string
        The melakarta raga to use.

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'R1', 'R2', 'G1', 'G2', ...)

        If `False`, return long-form names ('Sa', 'Ri1', 'Ri2', 'Ga1', 'Ga2', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

        This only takes effect if `octave=True`.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given frequency/frequencies

    See Also
    --------
    note_to_svara_c
    midi_to_svara_c
    hz_to_svara_h
    hz_to_note
    list_mela

    Examples
    --------
    Convert Sa in three octaves:

    >>> librosa.hz_to_svara_c([261/2, 261, 261*2], Sa=261, mela='kanakangi')
    ['Ṣ', 'S', 'Ṡ']

    Convert one octave worth of frequencies using melakarta #36:

    >>> freqs = librosa.cqt_frequencies(n_bins=12, fmin=261)
    >>> librosa.hz_to_svara_c(freqs, Sa=freqs[0], mela=36)
    ['S', 'R₁', 'R₂', 'R₃', 'G₃', 'M₁', 'M₂', 'P', 'D₁', 'D₂', 'D₃', 'N₃']
    r  )r$   r;   )r   rp  r  rm  r   r   r  s          rH   r?   r?   W  s-    F {#E*R.t$vw rJ   c                    y rD   rE   r   rp  r  rm  r   r   s         rH   r=   r=     r  rJ   c                    y rD   rE   r  s         rH   r=   r=     r  rJ   c                    y rD   rE   r  s         rH   r=   r=     r  rJ   c               P    t        | d      }t        |t        |      ||||      S )u  Convert western notes to Carnatic svara

    Note that this conversion assumes 12-tone equal temperament.

    Parameters
    ----------
    notes : str or iterable of str
        Notes to convert (e.g., `'C#'` or `['C4', 'Db4', 'D4']`

    Sa : str
        Note corresponding to Sa (e.g., `'C'` or `'C5'`).

        If no octave information is provided, it will default to octave 0
        (``C0`` ~= 16 Hz)

    mela : str or int [1, 72]
        Melakarta raga name or index

    abbr : bool
        If `True` (default) return abbreviated names ('S', 'R1', 'R2', 'G1', 'G2', ...)

        If `False`, return long-form names ('Sa', 'Ri1', 'Ri2', 'Ga1', 'Ga2', ...)

    octave : bool
        If `True`, decorate svara in neighboring octaves with over- or under-dots.

        If `False`, ignore octave height information.

    unicode : bool
        If `True`, use unicode symbols to decorate octave information.

        If `False`, use low-order ASCII (' and ,) for octave decorations.

        This only takes effect if `octave=True`.

    Returns
    -------
    svara : str or np.ndarray of str
        The svara corresponding to the given notes

    See Also
    --------
    midi_to_svara_c
    hz_to_svara_c
    note_to_svara_h
    note_to_midi
    note_to_hz
    list_mela

    Examples
    --------
    >>> librosa.note_to_svara_h(['C4', 'G4', 'C5', 'D5', 'G5'], Sa='C5', mela=1)
    ['Ṣ', 'P̣', 'S', 'G₁', 'P']
    Fr   r  )r    r;   )r   rp  r  rm  r   r   r  s          rH   r=   r=     s1    ~ 51E,r"DQX rJ   )r&  unisonr   c                    y rD   rE   r   r&  r  r   s       rH   r'   r'     r`   rJ   c                    y rD   rE   r  s       rH   r'   r'     r`   rJ   c                   |t        j                  |       }|t        |dd      }t        j                  |       r| |z  }nt        j                  |       |z  }t        j                  |||      S )u  Convert one or more frequencies (in Hz) from a just intonation
    scale to notes in FJS notation.

    Parameters
    ----------
    frequencies : float or iterable of float
        Input frequencies, specified in Hz
    fmin : float (optional)
        The minimum frequency, corresponding to a unison note.
        If not provided, it will be inferred as `min(frequencies)`
    unison : str (optional)
        The name of the unison note.
        If not provided, it will be inferred as the scientific pitch
        notation name of `fmin`, that is, `hz_to_note(fmin)`
    unicode : bool
        If `True`, then unicode symbols are used for accidentals.
        If `False`, then low-order ASCII symbols are used for accidentals.

    Returns
    -------
    notes : str or np.ndarray(dtype=str)
        ``notes[i]`` is the closest note name to ``frequency[i]``
        (or ``frequency`` if the input is scalar)

    See Also
    --------
    hz_to_note
    interval_to_fjs

    Examples
    --------
    Get a single note name for a frequency, relative to A=55 Hz

    >>> librosa.hz_to_fjs(66, fmin=55, unicode=True)
    'C₅'

    Get notation for a 5-limit frequency set starting at A=55

    >>> freqs = librosa.interval_frequencies(24, intervals="ji5", fmin=55)
    >>> freqs
    array([ 55.   ,  58.667,  61.875,  66.   ,  68.75 ,  73.333,  77.344,
        82.5  ,  88.   ,  91.667,  99.   , 103.125, 110.   , 117.333,
       123.75 , 132.   , 137.5  , 146.667, 154.687, 165.   , 176.   ,
       183.333, 198.   , 206.25 ])
    >>> librosa.hz_to_fjs(freqs, unicode=True)
    array(['A', 'B♭₅', 'B', 'C₅', 'C♯⁵', 'D', 'D♯⁵', 'E', 'F₅', 'F♯⁵', 'G₅',
       'G♯⁵', 'A', 'B♭₅', 'B', 'C₅', 'C♯⁵', 'D', 'D♯⁵', 'E', 'F₅', 'F♯⁵',
       'G₅', 'G♯⁵'], dtype='<U3')

    F)r   r   )r  r   )rO   minr#   rk  r[   r   interval_to_fjs)r   r&  r  r   	intervalss        rH   r'   r'   #  sk    r |vvk"~D>	{{;$&	JJ{+d2	 ##IfgNNrJ   )rG   r   rA   rN   rB   Optional[int]returnnp.integer[Any])rG   _SequenceLike[_IntLike_co]rA   rN   rB   r  r  
np.ndarray)rG   _ScalarOrSequence[_IntLike_co]rA   rN   rB   r  r  "Union[np.integer[Any], np.ndarray])rU   r   rA   rN   rB   r  r  r  )rU   r  rA   rN   rB   r  r  r  )rU   r  rA   rN   rB   r  r  r  )
rG   r   r]   rv   rA   rN   rB   r  r  np.floating[Any])
rG   r  r]   rv   rA   rN   rB   r  r  r  )
rG   r  r]   rv   rA   rN   rB   r  r  #Union[np.floating[Any], np.ndarray])
rg   r   r]   rv   rA   rN   rB   r  r  r  )
rg   _SequenceLike[_FloatLike_co]r]   rv   rA   rN   rB   r  r  r  )
rg    _ScalarOrSequence[_FloatLike_co]r]   rv   rA   rN   rB   r  r  r  )rg   r   r]   rv   r  r  )rg   r  r]   rv   r  r  )rg   r  r]   rv   r  r  )rU   r   r]   rv   r  r  )rU   r  r]   rv   r  r  )rU   r  r]   rv   r  r  )ry   r   rz   rN   r  r  )ry   r  rz   rN   r  r  )ry   r  rz   rN   r  r  )ry   r   rz   rN   rA   rN   r  r  )ry   r  rz   rN   rA   rN   r  r  )ry   r  rz   rN   rA   rN   r  r  )
ry   r   rz   rN   rA   rN   r]   rv   r  r  )
ry   r  rz   rN   rA   rN   r]   rv   r  r  )
ry   r  rz   rN   rA   rN   r]   rv   r  r  )r   r   r   r	   r  r  )r   _IterableLike[str]r   r	   r  r  )r   -Union[str, _IterableLike[str], Iterable[str]]r   r	   r  r  )r   r   r   boolr  zUnion[float, int])r   r  r   r  r  r  )r   r  r   r  r  zUnion[float, int, np.ndarray])r   r  r   r  r  Union[float, np.ndarray])r   r   r   r  r   r  r   r   r   r  r  r   )r   r  r   r  r   r  r   r   r   r  r  r  )r   r  r   r  r   r  r   r   r   r  r  Union[str, np.ndarray])r   r   r  r  )r   r  r  r  )r   r  r  #Union[np.ndarray, np.floating[Any]])r   r   r  r  )r   r  r  r  )r   r  r  r  )r   r   r   r	   r  r   )r   r  r   r	   r  r  )r   r  r   r	   r  r  )r   r   r   r  r  r  )r   r  r   r  r  r  )r   r  r   r  r  r  )r   r   r   r  r  r  )r   r  r   r  r  r  )r   r  r   r  r  r  )r   r   r  rv   r  rN   r  r  )r   r  r  rv   r  rN   r  r  )r   r  r  rv   r  rN   r  r  )r  r   r  rv   r  rN   r  r  )r  r  r  rv   r  rN   r  r  )r  r  r  rv   r  rN   r  r  )r  r   r  rN   r  r  )r  r  r  rN   r  r  )r  r  r  rN   r  r  )r  r   r  rN   r  r  )r  r  r  rN   r  r  )r  r  r  rN   r  r  )r]   rv   rB   rN   r  r  )
r%  rN   r&  rv   r  rN   r  rv   r  r  )   )
r+  rN   r&  rv   r(  rv   r   r  r  r  )r%  rN   rA   rN   r]   rv   r  r  )r]   rv   r5  rN   rA   rN   r  r  )r   r   r8  Optional[float]r  r  )r   r  r8  r  r  r  )r   r  r8  r  r  r  )r   r   r8  r  r  r  )r   r   rZ  r   r   r	   r  r  )r   r  rZ  r   r   r	   r  r  )r   r  rZ  r   r   r	   r  r  )r   r  ra  zIterable[str]r   r	   r  r  )rh  Union[np.ndarray, float]r]   rv   rA   rN   rB   r  rc  rN   r  r  )
rh  r  rA   rN   rB   r  rc  rN   r  r  )r   r   rp  r   rm  r  r   r  r   r  r  r   )r   r  rp  r   rm  r  r   r  r   r  r  r  )r   z Union[_FloatLike_co, np.ndarray]rp  r   rm  r  r   r  r   r  r  r  )r   r   rp  r   rm  r  r   r  r   r  r  r   )r   r  rp  r   rm  r  r   r  r   r  r  r  )r   r  rp  r   rm  r  r   r  r   r  r  r  )r   r   rp  r   rm  r  r   r  r   r  r  r   )r   r  rp  r   rm  r  r   r  r   r  r  r  )r   Union[str, _IterableLike[str]]rp  r   rm  r  r   r  r   r  r  r  )r   r   rp  r   r  Union[int, str]rm  r  r   r  r   r  r  r   )r   r  rp  r   r  r  rm  r  r   r  r   r  r  r  )r   r  rp  r   r  r  rm  r  r   r  r   r  r  r  )r   rv   rp  rv   r  r  rm  r  r   r  r   r  r  r   )r   r  rp  rv   r  r  rm  r  r   r  r   r  r  r  )r   r  rp  rv   r  r  rm  r  r   r  r   r  r  r  )r   r   rp  r   r  Union[str, int]rm  r  r   r  r   r  r  r   )r   r  rp  r   r  r  rm  r  r   r  r   r  r  r  )r   r  rp  r   r  r  rm  r  r   r  r   r  r  r  )
r   r   r&  r  r  Optional[str]r   r  r  r   )
r   r  r&  r  r  r  r   r  r  r  )
r   r  r&  r  r  r  r   r  r  r  )H__doc__
__future__r   ru  numpyrO   r   r   util.exceptionsr   util.decoratorsr   typingr	   r
   r   r   r   r   r   r   _typingr   r   r   r   r   __all__r   r   r   r   r   r   r   r   r   r   r    r"   r!   r$   r#   r%   r(   r&   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   rY  __annotations__r6   r7   r9   r8   r:   r>   r<   r;   r?   r=   r'   rE   rJ   rH   <module>r     s     " 	   , ' R R R +\ 
.1$(+:G 
 
 	&  	
  
 	)E*)E )E 	)E
 ()EX 
/23),;H 
 
 	'  	
  
 
 	+  	
 ( 
 	4M+4M 4M 	4M
 (4Mn 
  	 	
   
 
 & 	 	
   
 
 * 	 	
  ) 
 *+**+ 	*+ 	*+
 *+ )*+Z 
  	 	
   
 
 ' 	 	
   
 
 + 	 	
  ( 
 1J+1J 	1J 	1J
 1J (1Jh 
9<  
 
8;'05 
 
<?+49' 
 =B3+3493'3> 
9<  
 
8;'05 
 
<?+49( 
 =B#.+#.49#.(#.L 
 
 
&9< 
 
*=@' 
#0*#0=@#0'#0L 
*-;> 
 
&9<JM 
 
*=@NQ' 
*<**<=@*<NQ*<'*<Z 
*-;>DI 
 
&9<JMSX 
 
*  	
 	 ) 
2+*2+ 2+ 	2+
 	2+ )2+j 
 
 
 
 

7CF( 
#4
7#4CF#4(#4L 
25  
 
AD  
 
OR
7HL" 
 PTm
7mHLmm` 
 
  	
 
  	 
 
 
&  	
 
   
 
 
*  	
 
   
 9: a
*a a 	a
 
a a a ;aH 
 
 
 
 
+( 
C+C(CB 
 
 
 
 
1( 
1(@ 
 
 
 
 
1=@ 
+;1+;=@+;+;\ 
9<  
 
>A-7; 
 
BE1;?( 
 CH616;?6(6r 
25  
 
AD  
 
;>
*48( 
 <A4
*4484(4n 
36s+0IL 
 
 	-  	
  
 
 	1  	
 ) 
 	$1$ $ 	$
 )$N 
,/
$)BE 
 
 	
&  	
  
 
 	
*  	
 ) 
 	%=
*%= %= 	%=
 )%=P 
>A  
 
@C$:= 
 
DG(>A( 
 EG1(1>A1(1h 
58/2 
 
DG(>A 
 
HK,BE( 
 IK1D,1DBE1D(1Dh $)t 02 9;C#+#+#+25#+DI#+#+N Q(+7PUQQ %Q38QIMQQj '*u## ##/4##N C3MM&)M=@MMB 
=@+: 
 
LO-:I 
 
PS1>M( 
 QV7+17+>M7+(7+t 
=@+: 
 
LO-:I 
 
PS1>M( 
 QV3F13F>M3F(3Fl 
=@+: 
 
LO-:I 
 
PS1>M( 
 QV1F11F>M1F(1Fh 
=@+: 
 
LO-:I 
 
PS1>M( 
 QV9+19+>M9+(9+z 6:$+$+#2$+$+T 
				
   	 
/2),>A 
 
>A-8;MP 
 
BE1<?QT( 
 CF*<1*<<?*<QT*<(*<` !010 0 	0
 0l 99 	9 	9
 9 9 9~ 8I8I 8I 	8I
 8I 8Iv 

 
 	 	
   	 
 

 
 	 	
    
 

 
* 	 	
    
 78
 o
*o 	o 	o
 o o o 9od 

  	 	
   	 
 

 - 	 	
    
 

 1 	 	
    
 A1A 	A 	A
 A A AH 
),SRU"&6:KO 
 

  	 	
    
 

 ) 	 	
    
 >)> 	> 	>
 > > >B 
 	
	 		 		
 	 	 	 		 
	 
 	
	 		 		
 	 	 	 	 
	 
 	
"	 		 		
 	 	 	 	 
	 ?@ G
"G 	G 	G
 G G G G AGT 
 		 		 		
 	 	 	 		 
	 
 		 		 		
 	 	 	 	 
	 
 	)	 		 		
 	 	 	 	 
	" F)F 	F 	F
 F F F FR 
 		 		 		
 	 	 	 		 
	 
 		 		 		
 	 	 	 	 
	 
 	)	 		 		
 	 	 	 	 
	" C)C 	C 	C
 C C C CL 
    	
  	 
 
  -  	
   
 ! FO1FO FO 	FO
 FO FOrJ   