§
    ƒØj<(  ã                  ór  — d dl m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  G d„ dej        j	        ¦  «        Z
e
j        d	e
j        d
e
j        de
j        de
j        de
j        de
j        de
j        de
j        de
j        de
j        diZe
j        de
j        de
j        de
j        de
j        de
j        de
j        diZi e¥e¥Ze
j        de
j        de
j        de
j        de
j        de
j        de
j        diZi e¥e¥Z	 d,d-d!„Z 	 d.d/d(„Z! G d)„ d*ej"        ¦  «        Z#e$d+k    rd dlZ ej%        e#¦  «         dS dS )0é    )ÚannotationsN)Úcommon)Úkey)Úroman)Úscalec                  óV   — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdS )ÚHarmonicFunctionÚTÚTpÚTgÚtÚtPÚtGÚSÚSpÚSgÚsÚsPÚsGÚDÚDpÚDgÚdÚdPÚdGN)Ú__name__Ú
__module__Ú__qualname__ÚTONIC_MAJORÚTONIC_MAJOR_PARALLELKLANG_MINORÚTONIC_MAJOR_GEGENKLANG_MINORÚTONIC_MINORÚTONIC_MINOR_PARALLELKLANG_MAJORÚTONIC_MINOR_GEGENKLANG_MAJORÚSUBDOMINANT_MAJORÚ%SUBDOMINANT_MAJOR_PARALLELKLANG_MINORÚ"SUBDOMINANT_MAJOR_GEGENKLANG_MINORÚSUBDOMINANT_MINORÚ%SUBDOMINANT_MINOR_PARALLELKLANG_MAJORÚ"SUBDOMINANT_MINOR_GEGENKLANG_MAJORÚDOMINANT_MAJORÚ"DOMINANT_MAJOR_PARALLELKLANG_MINORÚDOMINANT_MAJOR_GEGENKLANG_MINORÚDOMINANT_MINORÚ"DOMINANT_MINOR_PARALLELKLANG_MAJORÚDOMINANT_MINOR_GEGENKLANG_MAJOR© ó    ú–/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/analysis/harmonicFunction.pyr	   r	      sx   € € € € € Ø€KØ&*Ð#Ø#'Ð à€KØ&*Ð#Ø#'Ð àÐØ,0Ð)Ø)-Ð&àÐØ,0Ð)Ø)-Ð&à€NØ)-Ð&Ø&*Ð#à€NØ)-Ð&Ø&*Ð#Ð#Ð#r2   r	   ÚIÚiÚbIIÚiiÚIVÚivÚVÚvÚviÚbviiÚbIIIÚiiiÚbVIÚbVIIÚIIIz#iiiÚVIÚVIIÚCÚthisHarmonicFunctionÚ
keyOrScaleú#key.Key | scale.ConcreteScale | strÚreturnúroman.RomanNumeral | Nonec                ó  — t          |t          ¦  «        rt          j        |¦  «        }t          }t          |t          j        ¦  «        r|j        dk    rt          }	 ||          }n# t          $ r Y dS w xY wt          j	        ||¦  «        S )u?  
    Takes harmonic function labels (such as 'T' for major tonic)
    with a key (keyOrScale, default = 'C') and
    returns the corresponding :class:`~music21.roman.RomanNumeral` object.

    >>> analysis.harmonicFunction.functionToRoman('T')
    <music21.roman.RomanNumeral I in C major>

    The harmonicFunction argument can be a string (as shown),
    though strictly speaking, it's handled through a special HarmonicFunction enum object.

    >>> fn = analysis.harmonicFunction.HarmonicFunction.TONIC_MAJOR
    >>> str(fn)
    'T'

    >>> analysis.harmonicFunction.functionToRoman(fn).figure
    'I'

    As with Roman numerals, this is case sensitive.
    For instance, 't' indicates a minor tonic
    as distinct from the major tonic, 'T'.

    >>> analysis.harmonicFunction.functionToRoman('t').figure
    'i'

    There are 18 main functional labels supported in all, for
    the three functional categories
    (T for tonic, S for subdominant, and D for dominant) and
    three relevant transformation types (none, P, and G)
    all in upper and lower case (for major/minor):
    T, Tp, Tg, t, tP, tG,
    S, Sp, Sg, s, sP, sG,
    D, Dp, Dg, d, dP, dG.

    Note that this module uses terminology from modern German music theory
    where Functional notation ('HarmonicFunctionstheorie') is typically used
    throughout the curriculum in preference over Roman numerals ('Stufentheorie').

    First, note the false friend: here 'P' for 'Parallel'
    connects a major triad with the minor triad a minor third below (e.g. C-a).
    (in English-speaking traditions this would usually be 'relative').

    Second, note that this module uses
    'G' (and 'g'), standing for
    'GegenklÃ¤nge' or 'Gegenparallelen'.
    'L' (and 'l') for LeittonwechselklÃ¤nge is equivalent to this.
    (Again, 'G' is more common in modern German-language music theory).

    Use the keyOrScale argement to specify a key.
    This makes a difference where 6th and 7th degrees of minor are involved.

    >>> analysis.harmonicFunction.functionToRoman('sP', keyOrScale='C').figure
    'bVI'

    >>> analysis.harmonicFunction.functionToRoman('sP', keyOrScale='a').figure
    'VI'

    Some of the 18 main functions overlap, with two functional labels
    referring to the same Roman numeral figure.
    For instance both 'Tg' and 'Dp' simply map to 'iii':

    >>> analysis.harmonicFunction.functionToRoman('Tp').figure
    'vi'

    >>> analysis.harmonicFunction.functionToRoman('Sg').figure
    'vi'

    The reverse operation is handled by the complementary
    :func:`~music21.analysis.harmonicFunction.romanToFunction`.
    In this case, :func:`~music21.analysis.harmonicFunction.romanToFunction`
    follows the convention of preferring the P-version over alternatives.

    >>> rn = roman.RomanNumeral('vi')
    >>> str(analysis.harmonicFunction.romanToFunction(rn))
    'Tp'

    ÚminorN)
Ú
isinstanceÚstrr   ÚKeyÚfunctionFigureTuplesMajorÚmodeÚfunctionFigureTuplesMinorÚKeyErrorr   ÚRomanNumeral)rF   rG   ÚreferenceTuplesÚfigures       r3   ÚfunctionToRomanrW   g   s—   € õ` �*�cÑ"Ô"ð )Ý”W˜ZÑ(Ô(ˆ
å/€OÝ�*�cœgÑ&Ô&ð 4¨:¬?¸gÒ+EÐ+EÝ3ˆðØ Ð!5Ô6ˆˆøÝð ð ð ØˆtˆtðøøøåÔ˜f jÑ1Ô1Ð1s   ÁA' Á'
A5Á4A5FÚrnúroman.RomanNumeralÚonlyHauptHarmonicFunctionÚboolúHarmonicFunction | Nonec                óî   — t           }| j        r| j        j        dk    rt          }|                     ¦   «         D ]:\  }}| j        |k    r*|r$t          t          |¦  «        d         ¦  «        c S |c S Œ;dS )a*  
    Takes a Roman numeral and returns a corresponding harmonic function label.

    >>> rn1 = roman.RomanNumeral('VI', 'a')
    >>> fn1 = analysis.harmonicFunction.romanToFunction(rn1)
    >>> fn1
    <HarmonicFunction.SUBDOMINANT_MINOR_PARALLELKLANG_MAJOR>

    This can be converted into a string:

    >>> str(fn1)
    'sP'

    Optionally, set onlyHauptHarmonicFunction to True to return
    a simplified version with only the HauptHarmonicFunction
    (one of t, T, s, S, d, D: major and minor forms of the tonic, subdominant and dominant).

    >>> fn1 = analysis.harmonicFunction.romanToFunction(rn1, onlyHauptHarmonicFunction=True)
    >>> fn1
    <HarmonicFunction.SUBDOMINANT_MINOR>

    >>> str(fn1)
    's'

    Inversions are not currently considered (they may be in a future version of this).
    This function simply uses the romanNumeral attribute of the roman.RomanNumeral object.
    This excludes inversions, but
    includes, where applicable, the frontAlterationAccidental.modifier.

    >>> rn2 = roman.RomanNumeral('bII6', 'g')
    >>> fn2 = analysis.harmonicFunction.romanToFunction(rn2)
    >>> fn2
    <HarmonicFunction.SUBDOMINANT_MINOR_GEGENKLANG_MAJOR>

    >>> str(fn2)
    'sG'

    See further notes on the complementary
    :func:`~music21.analysis.harmonicFunction.functionToRoman`.
    rL   r   N)rP   r   rQ   rR   ÚitemsÚromanNumeralr	   rN   )rX   rZ   rU   ÚthisKeyÚ	thisValues        r3   ÚromanToFunctionrb   Å   s�   € õX 0€OØ	„vð 8ØŒ6Œ;˜'Ò!Ð!Ý7ˆOà-×3Ò3Ñ5Ô5ð ð Ñˆ�ØŒ?˜iÒ'Ð'Ø(ð Ý'­¨G©¬°Q¬Ñ8Ô8Ð8Ð8Ð8à���ð	 (ð ˆ4r2   c                  ó&   — e Zd Zd„ Zd„ Zd„ Zd„ ZdS )ÚTestc                ó°   — t           D ]}t          |¦  «         Œt          D ]}t          |¦  «         Œd}|                      t          t          |¦  «         dS )zË
        Test that all the entries in the functionFigureTuples
        (both major and minor) are represented in the HarmonicFunction enum.

        Also tests one fake (invalid) function label.
        ÚTPGN)rP   r	   rR   ÚassertRaisesÚ
ValueError)ÚselfrF   ÚfakeExamples      r3   ÚtestAllFunctionLabelsInEnumz Test.testAllFunctionLabelsInEnum  sn   € õ %>ð 	3ð 	3Ð ÝÐ1Ñ2Ô2Ð2Ð2Ý$=ð 	3ð 	3Ð ÝÐ1Ñ2Ô2Ð2Ð2ð ˆØ×Ò�*Õ&6¸ÑDÔDÐDÐDÐDr2   c                ój   — |                       t          t          j        ¦  «        j        d¦  «         d S )Nr4   )ÚassertEqualrW   r	   r   rV   ©ri   s    r3   ÚtestFunctionToRomanzTest.testFunctionToRoman  s-   € Ø×Ò�Õ)9Ô)EÑFÔFÔMÈsÑSÔSÐSÐSÐSr2   c                ó|  — t          j        dd¦  «        }t          |¦  «        }|                      |t          j        ¦  «         |                      t          |¦  «        d¦  «         t          |d¬¦  «        }|                      |t          j        ¦  «         |                      t          |¦  «        d¦  «         d S )NrB   Úfr   T)rZ   r   )	r   rT   rb   ÚassertIsr	   r#   rm   rN   r"   )ri   rX   Úfn1Úfn2s       r3   ÚtestSimplifiedzTest.testSimplified  s¡   € ÝÔ  sÑ+Ô+ˆå˜bÑ!Ô!ˆØ�Š�cÕ+ÔKÑLÔLÐLØ×Ò�˜S™œ 4Ñ(Ô(Ð(å˜b¸DÐAÑAÔAˆØ�Š�cÕ+Ô7Ñ8Ô8Ð8Ø×Ò�˜S™œ 3Ñ'Ô'Ð'Ð'Ð'r2   c                óp   — |                       t          t          j        d¦  «        ¦  «        d¦  «         d S )NÚi6r   )rm   rb   r   rT   rn   s    r3   ÚtestIgnoresInversionzTest.testIgnoresInversion!  s1   € Ø×Ò�­Ô);¸DÑ)AÔ)AÑBÔBÀCÑHÔHÐHÐHÐHr2   N)r   r   r   rk   ro   ru   rx   r1   r2   r3   rd   rd     s[   € € € € € ðEð Eð Eð"Tð Tð Tð	(ð 	(ð 	(ðIð Ið Ið Ið Ir2   rd   Ú__main__)rE   )rF   r	   rG   rH   rI   rJ   )F)rX   rY   rZ   r[   rI   r\   )&Ú
__future__r   ÚunittestÚmusic21r   r   r   r   ÚenumsÚStrEnumr	   r   r"   r*   r&   r%   r(   r+   r.   r    r'   r-   Ú_functionFigureTuplesKeyNeutralr#   r0   r,   r!   r)   r$   r/   rP   rR   rW   rb   ÚTestCaserd   r   ÚmainTestr1   r2   r3   ú<module>r‚      sa  ðð #Ð "Ð "Ð "Ð "Ð "à €€€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð+ð +ð +ð +ð +�v”|Ô+ñ +ô +ð +ð6 Ô  #ØÔ  #àÔ7¸àÔ:¸DàÔ&¨ØÔ&¨àÔ# SØÔ# SàÔ4°dØÔ7¸àÔ4°fð##Ð ð* Ô4°fØÔ4°fàÔ7¸ØÔ1°5àÔ:¸EØÔ1°5àÔ7¸ðÐ ðØðà%ðÐ ð Ô4°eØÔ4°eàÔ7¸ØÔ1°6àÔ:¸DØÔ1°4àÔ7¸ðÐ ðØðà%ðÐ ð CFð[2ð [2ð [2ð [2ð [2ð~ 7<ð8ð 8ð 8ð 8ð 8ðx!Ið !Ið !Ið !Ið !Iˆ8Ôñ !Iô !Ið !IðJ ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr2   