§
    ƒØj»  ã                  ó   — d dl mZ d dlZd dlmZ d dlZd dlmZ d dlmZ d dlm	Z	  ej
        d¦  «        Z G d„ d	¦  «        Z G d
„ de¦  «        Z G d„ d¦  «        Z G d„ dej        ¦  «        Zedk    rd dlZ ej        e¦  «         dS dS )é    )ÚannotationsN)Úinf)Úenvironment)Úpitch)Úmusedatazanalysis.enharmonicsc                  ó   — e Zd Zd„ ZdS )ÚEnharmonicScoreRulesc                ó>   — d| _         d| _        d| _        d| _        d S )NFé   é   )ÚsameStaffLineÚalterationPenaltyÚaugDimPenaltyÚmixSharpsFlatsPenalty©Úselfs    ú‘/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/analysis/enharmonics.pyÚ__init__zEnharmonicScoreRules.__init__   s(   € Ø"ˆÔØ!"ˆÔØˆÔØ%*ˆÔ"Ð"Ð"ó    N)Ú__name__Ú
__module__Ú__qualname__r   © r   r   r	   r	      s#   € € € € € ð+ð +ð +ð +ð +r   r	   c                  ó   ‡ — e Zd Zˆ fd„Zˆ xZS )ÚChordEnharmonicScoreRulesc                óV   •— t          ¦   «                              ¦   «          d| _        d S )Nr   )Úsuperr   r   )r   Ú	__class__s    €r   r   z"ChordEnharmonicScoreRules.__init__    s'   ø€ Ý‰Œ×ÒÑÔÐØ%&ˆÔ"Ð"Ð"r   )r   r   r   r   Ú__classcell__)r   s   @r   r   r      s8   ø€ € € € € ð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'ð 'r   r   c                  ó@   — e Zd ZdZefd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	S )
ÚEnharmonicSimplifiera³  
    Takes any pitch list input and returns the best enharmonic respelling according to the input
    criteria and rule weightings.
    Those criteria and rule weightings are currently fixed, but in future the user should be able
    to select their own combination and weighting of rules according to preferences,
    with predefined defaults for melodic and harmonic norms.
    Note: EnharmonicSimplifier itself returns nothing.
    c                óÄ   — t          |d         t          ¦  «        rd„ |D ¦   «         }|| _         |¦   «         | _        d | _        g | _        |                      ¦   «          d S )Nr   c                ó6   — g | ]}t          j        |¦  «        ‘ŒS r   )r   ÚPitch©Ú.0Úps     r   ú
<listcomp>z1EnharmonicSimplifier.__init__.<locals>.<listcomp>/   s    € Ð;Ð;Ð;¨A�œ Q™œÐ;Ð;Ð;r   )Ú
isinstanceÚstrÚ	pitchListÚ
ruleObjectÚallPossibleSpellingsÚallSpellingsÚgetRepresentations)r   r+   Ú	ruleClasss      r   r   zEnharmonicSimplifier.__init__-   sg   € Ý�i ”l¥CÑ(Ô(ð 	<Ø;Ð;°Ð;Ñ;Ô;ˆIà"ˆŒØ#˜)™+œ+ˆŒØ$(ˆÔ!ØˆÔØ×ÒÑ!Ô!Ð!Ð!Ð!r   c                óˆ   — g }| j         D ]0}|g|                     d¦  «        z   }|                     |¦  «         Œ1|| _        dS )z™
        Takes a list of pitches or pitch names and retrieves all enharmonic spellings.
        Note: getRepresentations itself returns nothing.
        é   N)r+   ÚgetAllCommonEnharmonicsÚappendr.   )r   r.   r'   Ú	spellingss       r   r/   z'EnharmonicSimplifier.getRepresentations7   sY   € ð
 ˆØ”ð 	+ð 	+ˆAØ˜˜a×7Ò7¸Ñ:Ô:Ñ:ˆIØ×Ò 	Ñ*Ô*Ð*Ð*Ø(ˆÔÐÐr   c                óZ   — t          t          j        | j        Ž ¦  «        | _        | j        S )N)ÚlistÚ	itertoolsÚproductr.   r-   r   s    r   Ú
getProductzEnharmonicSimplifier.getProductB   s&   € Ý$(­Ô):¸DÔ<MÐ)NÑ$OÔ$OˆÔ!ØÔ(Ð(r   c                óö   — |                       ¦   «          g }t          }| j        D ]S}|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }||z   |z   }||k     r|}|}ŒT|S )aR  
        Returns a list of pitches in the best enharmonic
        spelling according to the input criteria.

        >>> pList1 = [pitch.Pitch('C'), pitch.Pitch('D'), pitch.Pitch('E')]
        >>> es = analysis.enharmonics.EnharmonicSimplifier(pList1)
        >>> es.bestPitches()
        (<music21.pitch.Pitch C>, <music21.pitch.Pitch D>, <music21.pitch.Pitch E>)
        >>> pList2 = ['D--', 'E', 'F##']
        >>> es = analysis.enharmonics.EnharmonicSimplifier(pList2)
        >>> es.bestPitches()
        (<music21.pitch.Pitch C>, <music21.pitch.Pitch E>, <music21.pitch.Pitch G>)
        )r:   r   r-   ÚgetAugDimScoreÚgetAlterationScoreÚgetMixSharpFlatsScore)r   ÚbestPitchesÚminScoreÚpossibilityÚthisAugDimScoreÚthisAlterationScoreÚthisMixSharpsFlatScoreÚ	thisScores           r   r?   z EnharmonicSimplifier.bestPitchesF   s˜   € ð 	�ŠÑÔÐØˆÝˆØÔ4ð 	*ð 	*ˆKØ"×1Ò1°+Ñ>Ô>ˆOØ"&×"9Ò"9¸+Ñ"FÔ"FÐØ%)×%?Ò%?ÀÑ%LÔ%LÐ"Ø'Ð*=Ñ=Ð@VÑVˆIØ˜8Ò#Ð#Ø$�Ø)�øØÐr   c                óâ   — | j         j        du rdS d                     d„ |D ¦   «         ¦  «        }|                     d¦  «        }|                     d¦  «        }||z   dz   | j         j        z  }|S )zÄ
        Returns a score according to the number of sharps and flats in a possible spelling.
        The score is the sum of the flats and sharps + 1, multiplied by the alterationPenalty.
        Fr2   Ú c                ó   — g | ]	}|j         ‘Œ
S r   ©Únamer%   s     r   r(   z;EnharmonicSimplifier.getAlterationScore.<locals>.<listcomp>i   ó   € Ð$AÐ$AÐ$A° Q¤VÐ$AÐ$AÐ$Ar   ú-ú#)r,   r   ÚjoinÚcount©r   rA   ÚjoinedPossibilityÚ	flatCountÚ
sharpCountÚscores         r   r=   z'EnharmonicSimplifier.getAlterationScorea   s~   € ð
 Œ?Ô,°Ð5Ð5Ø�1àŸGšGÐ$AÐ$A°[Ð$AÑ$AÔ$AÑBÔBÐØ%×+Ò+¨CÑ0Ô0ˆ	Ø&×,Ò,¨SÑ1Ô1ˆ
Ø˜ZÑ'¨!Ñ+¨t¬Ô/PÑPˆØˆr   c                óô   — | j         j        du rdS d                     d„ |D ¦   «         ¦  «        }|                     d¦  «        }|                     d¦  «        }t	          ||g¦  «        | j         j        z  }|S )zì
        Returns a score based on the mixture of sharps and flats in a possible spelling:
        the score is given by the number of the lesser used accidental (sharps or flats)
        multiplied by the mixSharpsFlatsPenalty.
        Fr2   rG   c                ó   — g | ]	}|j         ‘Œ
S r   rI   r%   s     r   r(   z>EnharmonicSimplifier.getMixSharpFlatsScore.<locals>.<listcomp>x   rK   r   rL   rM   )r,   r   rN   rO   ÚminrP   s         r   r>   z*EnharmonicSimplifier.getMixSharpFlatsScoreo   s�   € ð Œ?Ô0°EÐ9Ð9Ø�1àŸGšGÐ$AÐ$A°[Ð$AÑ$AÔ$AÑBÔBÐØ%×+Ò+¨CÑ0Ô0ˆ	Ø&×,Ò,¨SÑ1Ô1ˆ
Ý�Y 
Ð+Ñ,Ô,¨t¬Ô/TÑTˆØˆr   c                óÚ  — | j         j        du rdS d}t          t          |¦  «        dz
  ¦  «        D ]y}t          j        j        ||         j                 }t          j        j        ||dz            j                 }||z
  dz  }|t          j        j         	                    |d¦  «        z  }Œz| 
                    d¦  «        }| 
                    d¦  «        }||z   dz   | j         j        z  }	|	S )z•
        Returns a score based on the number of augmented and diminished intervals between
        successive pitches in the given spelling.
        Fr2   rG   é(   ÚdddÚAÚd)r,   r   ÚrangeÚlenr   Úbase40Úbase40RepresentationrJ   Úbase40IntervalTableÚgetrO   )
r   rA   ÚintervalStrÚiÚp0Úp1Ú
base40diffÚdimCountÚaugCountrT   s
             r   r<   z#EnharmonicSimplifier.getAugDimScore~   sç   € ð
 Œ?Ô(¨EÐ1Ð1Ø�1àˆÝ•s˜;Ñ'Ô'¨!Ñ+Ñ,Ô,ð 	Vð 	VˆAÝ”Ô5°kÀ!´nÔ6IÔJˆBÝ”Ô5°kÀ!ÀaÁ%Ô6HÔ6MÔNˆBØ˜r™' R™ˆJØ�8œ?Ô>×BÒBÀ:ÈuÑUÔUÑUˆKˆKØ×$Ò$ SÑ)Ô)ˆØ×$Ò$ SÑ)Ô)ˆØ˜HÑ$ qÑ(¨D¬OÔ,IÑIˆØˆr   N)r   r   r   Ú__doc__r	   r   r/   r:   r?   r=   r>   r<   r   r   r   r!   r!   $   s’   € € € € € ðð ð -Að "ð "ð "ð "ð	)ð 	)ð 	)ð)ð )ð )ðð ð ð6ð ð ðð ð ðð ð ð ð r   r!   c                  ó&   — e Zd Zd„ Zd„ Zd„ Zd„ ZdS )ÚTestc                óš  — t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}t          |¦  «        }|                     ¦   «         }|                      t          |¦  «        d¦  «         |                      t          |¦  «        d¦  «         |                      |d         t           j        ¦  «         d S )NÚCÚDÚEé   r   )r   r$   r!   r?   ÚassertEqualr^   ÚassertIsInstance)r   ÚpListÚesÚbestPitchLists       r   ÚtestBestPitcheszTest.testBestPitches”   s¥   € Ý”˜SÑ!Ô!¥5¤;¨sÑ#3Ô#3µU´[ÀÑ5EÔ5EÐFˆÝ! %Ñ(Ô(ˆØŸšÑ(Ô(ˆà×Ò�˜U™œ QÑ'Ô'Ð'Ø×Ò�˜]Ñ+Ô+¨QÑ/Ô/Ð/Ø×Ò˜m¨AÔ.µ´Ñ<Ô<Ð<Ð<Ð<r   c                ó¶  — t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}t          |¦  «        }t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}|                     |¦  «        }|                      t          |¦  «        d¦  «         |                      |t          ¦  «         d S ©Nrn   ro   rp   rq   )r   r$   r!   r=   rr   r^   rs   Úint)r   rt   ru   ÚpossÚtestAltScores        r   ÚtestGetAlterationScorezTest.testGetAlterationScore�   s®   € Ý”˜SÑ!Ô!¥5¤;¨sÑ#3Ô#3µU´[ÀÑ5EÔ5EÐFˆÝ! %Ñ(Ô(ˆÝ”˜CÑ Ô ¥%¤+¨cÑ"2Ô"2µE´KÀÑ4DÔ4DÐEˆØ×,Ò,¨TÑ2Ô2ˆà×Ò�˜U™œ QÑ'Ô'Ð'Ø×Ò˜l­CÑ0Ô0Ð0Ð0Ð0r   c                ó¶  — t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}t          |¦  «        }t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}|                     |¦  «        }|                      t          |¦  «        d¦  «         |                      |t          ¦  «         d S ry   )r   r$   r!   r>   rr   r^   rs   rz   )r   rt   ru   r{   ÚtestMixScores        r   ÚtestGetMixSharpFlatsScorezTest.testGetMixSharpFlatsScore¦   s®   € Ý”˜SÑ!Ô!¥5¤;¨sÑ#3Ô#3µU´[ÀÑ5EÔ5EÐFˆÝ! %Ñ(Ô(ˆÝ”˜CÑ Ô ¥%¤+¨cÑ"2Ô"2µE´KÀÑ4DÔ4DÐEˆØ×/Ò/°Ñ5Ô5ˆà×Ò�˜U™œ QÑ'Ô'Ð'Ø×Ò˜l­CÑ0Ô0Ð0Ð0Ð0r   c                ó¶  — t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}t          |¦  «        }t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}|                     |¦  «        }|                      t          |¦  «        d¦  «         |                      |t          ¦  «         d S ry   )r   r$   r!   r<   rr   r^   rs   rz   )r   rt   ru   r{   ÚtestAugDimScores        r   ÚtestGetAugDimScorezTest.testGetAugDimScore¯   s®   € Ý”˜SÑ!Ô!¥5¤;¨sÑ#3Ô#3µU´[ÀÑ5EÔ5EÐFˆÝ! %Ñ(Ô(ˆÝ”˜CÑ Ô ¥%¤+¨cÑ"2Ô"2µE´KÀÑ4DÔ4DÐEˆØ×+Ò+¨DÑ1Ô1ˆà×Ò�˜U™œ QÑ'Ô'Ð'Ø×Ò˜o­sÑ3Ô3Ð3Ð3Ð3r   N)r   r   r   rw   r}   r€   rƒ   r   r   r   rl   rl   ’   sP   € € € € € ð=ð =ð =ð1ð 1ð 1ð1ð 1ð 1ð4ð 4ð 4ð 4ð 4r   rl   Ú__main__)Ú
__future__r   r8   Úmathr   ÚunittestÚmusic21r   r   r   ÚEnvironmentÚenvironLocalr	   r   r!   ÚTestCaserl   r   ÚmainTestr   r   r   ú<module>r�      sr  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø €€€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à&ˆ{Ô&Ð'=Ñ>Ô>€ð+ð +ð +ð +ð +ñ +ô +ð +ð'ð 'ð 'ð 'ð 'Ð 4ñ 'ô 'ð 'ð
kð kð kð kð kñ kô kð kð\$4ð $4ð $4ð $4ð $4ˆ8Ôñ $4ô $4ð $4ðP ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr   