§
    „Øj�š  ã            	      óh  — d Z ddlmZ ddlmZ ddlmZ ddlZddl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 dd
lmZ ddlmZ ddlmZmZ ddlmZmZ g d¢Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ d edg d¢¦  «        ¦  «        Z G d„ d¦  «        Zd8d„Z d„ Z!d„ Z"d„ Z#d„ Z$d„ Z%d„ Z&d„ Z'd9d!„Z(d9d"„Z)d9d#„Z*d9d$„Z+d9d%„Z,d:d*„Z-d;d<d.„Z.d=d/„Z/d=d0„Z0d9d1„Z1 G d2„ d3ej2        ¦  «        Z3 G d4„ d5e
j4        ¦  «        Z5g d6¢Z6e7d7k    rddlZ ej8        e5¦  «         dS dS )>zn
base classes for searching scores.

See User's Guide, Chapter 43: Searching in and Among Scores for details.
é    )Úannotations)Ú
namedtuple)ÚCallableN)Úwindowed)Úbase)Úexceptions21)Úchord)Úduration)Únote)ÚMeasureÚStream)ÚfiltersÚiterator)ÚSearchExceptionÚSearchMatchÚStreamSearcherÚWildcardÚWildcardDurationÚapproximateNoteSearchÚapproximateNoteSearchNoRhythmÚapproximateNoteSearchOnlyRhythmÚapproximateNoteSearchWeightedÚmostCommonMeasureRhythmsÚnoteNameRhythmicSearchÚnoteNameSearchÚrhythmicSearchÚstreamSearchBaseÚtranslateDiatonicStreamToStringÚtranslateDurationToBytesÚtranslateIntervalsAndSpeedÚtranslateNoteTieToByteÚtranslateNoteToByteÚ translateNoteWithDurationToBytesÚtranslateStreamToStringÚtranslateStreamToStringNoRhythmÚ!translateStreamToStringOnlyRhythmc                  ó   — e Zd ZdZdS )r   zº
    a wildcard duration (it might define a duration
    in itself, but the methods here will see that it
    is a wildcard of some sort)

    No difference from any other duration.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úˆ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/search/base.pyr   r   =   s   € € € € € ðð ð 	€Dr-   r   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r   aY  
    An object that may have some properties defined, but others not that
    matches a single object in a music21 stream.  Equivalent to the
    regular expression "."

    >>> wc1 = search.Wildcard()
    >>> wc1.pitch = pitch.Pitch('C')
    >>> st1 = stream.Stream()
    >>> st1.append(note.Note('D', type='half'))
    >>> st1.append(wc1)
    c                ó`   •—  t          ¦   «         j        di |¤Ž t          ¦   «         | _        d S )Nr,   )ÚsuperÚ__init__r   r
   )ÚselfÚkeywordsÚ	__class__s     €r.   r2   zWildcard.__init__T   s1   ø€ Ø�‰ŒÔÐ$Ð$˜8Ð$Ð$Ð$Ý(Ñ*Ô*ˆŒˆˆr-   )r(   r)   r*   r+   r2   Ú__classcell__)r5   s   @r.   r   r   H   sB   ø€ € € € € ð
ð 
ð+ð +ð +ð +ð +ð +ð +ð +ð +r-   r   c                  ó6   — e Zd ZU dZdZdddddœZded	<   d
„ ZdS )r   ze
    A lightweight object representing the match (if any) for a search.  Derived from namedtuple
    r,   z(The first element that matches the list.z%A tuple of all the matching elements.zAThe index in the iterator at which the first element can be foundz+The iterator which produced these elements.©ÚelStartÚelsÚindexr   zdict[str, str]Ú	_DOC_ATTRc                ó^   — | j         }t          | j        ¦  «        }| j        }d|›d|› d|›d�S )NzSearchMatch(elStart=z
, els=len(z	), index=z, iterator=[...]))r9   Úlenr:   r;   )r3   ÚesÚelÚixs       r.   Ú__repr__zSearchMatch.__repr__e   s>   € ØŒ\ˆÝ�”‰]Œ]ˆØŒZˆØZ bÐZÐZ°bÐZÐZÀ2ÐZÐZÐZÐZr-   N)r(   r)   r*   r+   Ú	__slots__r<   Ú__annotations__rB   r,   r-   r.   r   r   Y   sg   € € € € € € ðð ð €IàAØ:ØXØEð	!ð !€Ið ð ð ñ ð[ð [ð [ð [ð [r-   r   r8   c                  ó:   — e Zd ZdZdd„Zdd	„Zdd„Zdd„Zdd„ZdS )r   a²  
    An object that can search through streams for a set of elements
    or notes or something of that sort.

    Create a basic Stream first:

    >>> thisStream = converter.parse('tinynotation: 3/4 c4. d8 e4 g4. a8 f4. c4. d4')
    >>> thisStream.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 3/4>
        {0.0} <music21.note.Note C>
        {1.5} <music21.note.Note D>
        {2.0} <music21.note.Note E>
    {3.0} <music21.stream.Measure 2 offset=3.0>
        {0.0} <music21.note.Note G>
        {1.5} <music21.note.Note A>
        {2.0} <music21.note.Note F>
    {6.0} <music21.stream.Measure 3 offset=6.0>
        {0.5} <music21.note.Note C>
        {2.0} <music21.note.Note D>
        {3.0} <music21.bar.Barline type=final>

    Let's create something to search for:

    >>> c = note.Note('C', quarterLength=1.5)
    >>> d = note.Note('D', quarterLength=0.5)
    >>> searchList = [c, d]

    Now create a StreamSearcher:

    >>> ss = search.StreamSearcher(thisStream, searchList)

    `searchList` could also be a Stream in itself.

    Let's configure it for recursive search and to filter so only notes are there:

    >>> ss.recurse = True
    >>> ss.filterNotes = True  # or `.filterNotesAndRests`

    Alternatively, we could have passed in a StreamIterator instead of `thisStream`.

    Now let's configure the algorithms:

    >>> ss.algorithms
    [<function StreamSearcher.wildcardAlgorithm at 0x111b6e340>]

    Wildcard search is a default algorithm that lets you use wildcards.
    I suggest you leave it in place and add to the algorithms list.  We can add the
    `rhythmAlgorithm` to it:

    >>> ss.algorithms.append(search.StreamSearcher.rhythmAlgorithm)
    >>> ss.algorithms
    [<function StreamSearcher.wildcardAlgorithm at 0x111b6e340>,
     <function StreamSearcher.rhythmAlgorithm at 0x11200000>]

    Now run it:

    >>> results = ss.run()
    >>> results
    [SearchMatch(elStart=<music21.note.Note C>, els=len(2), index=0, iterator=[...]),
     SearchMatch(elStart=<music21.note.Note G>, els=len(2), index=3, iterator=[...])]

    >>> results[0].elStart.measureNumber
    1
    >>> results[1].elStart.measureNumber
    2

    Wildcards can be useful:

    >>> searchStream2 = stream.Stream()
    >>> searchStream2.append(note.Note(quarterLength=0.5))
    >>> searchStream2.append(search.Wildcard())
    >>> searchStream2.append(note.Note(quarterLength=1.5))

    >>> ss.searchList = searchStream2
    >>> results = ss.run()
    >>> results
    [SearchMatch(elStart=<music21.note.Note D>, els=len(3), index=1, iterator=[...]),
     SearchMatch(elStart=<music21.note.Note A>, els=len(3), index=4, iterator=[...])]
    >>> results[0].els
    (<music21.note.Note D>, <music21.note.Note E>, <music21.note.Note G>)
    >>> [n.duration.quarterLength for n in results[0].els]
    [0.5, 1.0, 1.5]

    OMIT_FROM_DOCS

    >>> emptyS = stream.Stream()
    >>> ss.searchList = emptyS
    >>> ss.run()
    Traceback (most recent call last):
    music21.search.base.SearchException: the search Stream or list cannot be empty

    why doesn't this work?  thisStream[found].expressions.append(expressions.TextExpression('*'))
    ÚstreamSearchr   Ú
searchListúlist[m21Base.Music21Object]c                ó~   — || _         || _        d| _        d| _        d| _        t
          j        g| _        d | _        d S )NF)	rF   rG   ÚrecurseÚfilterNotesÚfilterNotesAndRestsr   ÚwildcardAlgorithmÚ
algorithmsÚactiveIterator)r3   rF   rG   s      r.   r2   zStreamSearcher.__init__Í   sK   € Ø<HˆÔØ7AˆŒØ"ˆŒØ!&ˆÔØ).ˆÔ õ
 Ô-Ð.ð 	Œð
 =AˆÔÐÐr-   Úreturnúlist[SearchMatch]c                óÐ  — t          | j        t          j        ¦  «        r| j        }n·| j        r| j                             ¦   «         }n| j                             ¦   «         }| j        r2|                     t          j	        t          j        ¦  «        ¦  «        }nD| j        r=|                     t          j	        t          j        t          j        g¦  «        ¦  «        }|| _        t#          |¦  «        }t%          |¦  «        }t%          | j        ¦  «        }|dk    rt)          d¦  «        ‚g }||k    r|S t+          t-          ||¦  «        ¦  «        D ]‘\  }}d }t/          |¦  «        D ]D}	||	         }
|
€d} n5| j        |	         }| j        D ]} || |
|¦  «        }|� nŒ|du r n|du rd }ŒE|dur2t3          |d         ||| j        ¦  «        }|                     |¦  «         Œ’|S )Nr   ú)the search Stream or list cannot be emptyFT)Ú
isinstancerF   r   ÚStreamIteratorrJ   ÚiterrL   Ú	addFilterr   ÚClassFilterr   ÚGeneralNoterK   ÚNoter	   ÚChordrO   Úlistr>   rG   r   Ú	enumerater   ÚrangerN   r   Úappend)r3   ÚthisStreamIteratorÚstreamIteratorElsÚstreamLengthÚsearchLengthÚfoundElsÚstartPositionÚ	streamElsÚresultÚjÚstreamElÚsearchElÚthisAlgorithmÚsms                 r.   ÚrunzStreamSearcher.runÛ   s)  € å�dÔ'­Ô)@ÑAÔAð 	Ø!%Ô!2ÐÐàŒ|ð >Ø%)Ô%6×%>Ò%>Ñ%@Ô%@Ð"Ð"à%)Ô%6×%;Ò%;Ñ%=Ô%=Ð"àÔ'ð Ø%7×%AÒ%AÝÔ'­Ô(8Ñ9Ô9ñ&ô &Ð"Ð"ð Ô!ð Ø%7×%AÒ%AÝÔ'­¬µE´KÐ(@ÑAÔAñ&ô &Ð"ð 1ˆÔå9=Ð>PÑ9QÔ9QÐÝÐ,Ñ-Ô-ˆÝ˜4œ?Ñ+Ô+ˆà˜1ÒÐÝ!Ð"MÑNÔNÐNà&(ˆØ˜,Ò&Ð&ØˆOå(1µ(Ð;LÈlÑ2[Ô2[Ñ(\Ô(\ð 	$ð 	$Ñ$ˆM˜9ØˆFÝ˜<Ñ(Ô(ð "ð "�à$ Qœ<�ØÐ#ð #�FØ�Eàœ?¨1Ô-�Ø%)¤_ð ð �MØ*˜]¨4°¸8ÑDÔD�FØÐ)Ø˜ð *à˜U�?�?Ø�EØ˜T�>�>Ø!�Føà˜UÐ"Ð"Ý  ¨1¤¨y¸-ÈÔI\Ñ]Ô]�Ø—’ Ñ#Ô#Ð#øàˆr-   ri   úm21Base.Music21Objectrj   c                ó4   — t          |t          ¦  «        rdS dS )zb
        An algorithm that supports Wildcards -- added by default to the search function.
        TN)rT   r   ©r3   ri   rj   s      r.   rM   z StreamSearcher.wildcardAlgorithm  s    € õ �h¥Ñ)Ô)ð 	Ø�4à�4r-   c                óv   — t          |j        t          ¦  «        rdS |j        j        |j        j        k    rdS d S )NTF)rT   r
   r   ÚquarterLengthrp   s      r.   ÚrhythmAlgorithmzStreamSearcher.rhythmAlgorithm  s>   € Ý�hÔ'Õ)9Ñ:Ô:ð 	Ø�4ØÔÔ*¨hÔ.?Ô.MÒMÐMØ�5Øˆtr-   c                ór   — t          |d¦  «        sdS t          |d¦  «        sdS |j        |j        k    rdS d S )NÚnameF)Úhasattrru   rp   s      r.   ÚnoteNameAlgorithmz StreamSearcher.noteNameAlgorithm&  sI   € Ý�x Ñ(Ô(ð 	Ø�5Ý�x Ñ(Ô(ð 	Ø�5ØŒ=˜HœMÒ)Ð)Ø�5Øˆtr-   N)rF   r   rG   rH   )rP   rQ   )ri   rn   rj   rn   )	r(   r)   r*   r+   r2   rm   rM   rs   rw   r,   r-   r.   r   r   l   sŠ   € € € € € ð^ð ^ð@Að Að Að Að9ð 9ð 9ð 9ðvð ð ð ðð ð ð ðð ð ð ð ð r-   r   c                óÜ  — |€t          d¦  «        ‚d}d| j        v r| }n|                      ¦   «         }t          |¦  «        }t	          |¦  «        }t	          |¦  «        }|dk    rt          d¦  «        ‚g }||k    r|S t          t          ||¦  «        ¦  «        D ]N\  }	}
t          |¦  «        D ]"}|
|         }||         } |||¦  «        }|s nŒ#|r|                     |	¦  «         ŒO|S )zä
    A basic search function that is used by other search mechanisms,
    which takes in a stream or StreamIterator and a searchList or stream
    and an algorithm to run on each pair of elements to determine if they match.
    Nz%algorithm must be a function not NonerU   r   rS   )	r   ÚclassesrJ   r\   r>   r]   r   r^   r_   )ÚthisStreamOrIteratorrG   Ú	algorithmrg   r`   ra   rb   rc   rd   re   rf   rh   ri   rj   s                 r.   r   r   0  s2  € ð ÐÝÐEÑFÔFÐFà€FØÐ/Ô7Ð7Ð7Ø1ÐÐà1×9Ò9Ñ;Ô;ÐåÐ/Ñ0Ô0ÐÝÐ(Ñ)Ô)€LÝ�z‘?”?€LØ�qÒÐÝÐIÑJÔJÐJà€HØ�lÒ"Ð"Øˆå$-­hÐ7HÈ,Ñ.WÔ.WÑ$XÔ$Xð +ð +Ñ ˆ�yÝ�|Ñ$Ô$ð 	ð 	ˆAØ  ”|ˆHØ! !”}ˆHØ�Y˜x¨Ñ2Ô2ˆFØð Ø�ðàð 	+Ø�OŠO˜MÑ*Ô*Ð*øØ€Or-   c                ó,   — d„ }t          | ||¬¦  «        S )a#  
    Takes two streams -- the first is the stream to be searched and the second
    is a stream of elements whose rhythms must match the first.  Returns a list
    of indices which begin a successful search.

    searches are made based on quarterLength.
    thus a dotted sixteenth-note and a quadruplet (4:3) eighth
    will match each other.

    Example 1: First we will set up a simple stream for searching:

    >>> thisStream = converter.parse('tinynotation: 3/4 c4. d8 e4 g4. a8 f4. c4. r4')
    >>> thisStream.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 3/4>
        {0.0} <music21.note.Note C>
        {1.5} <music21.note.Note D>
        {2.0} <music21.note.Note E>
    {3.0} <music21.stream.Measure 2 offset=3.0>
        {0.0} <music21.note.Note G>
        {1.5} <music21.note.Note A>
        {2.0} <music21.note.Note F>
    {6.0} <music21.stream.Measure 3 offset=6.0>
        {0.5} <music21.note.Note C>
        {2.0} <music21.note.Rest quarter>
        {3.0} <music21.bar.Barline type=final>

    Now we will search for all dotted-quarter/eighth elements in the Stream:

    >>> thisStreamIter = thisStream.recurse().notes

    >>> searchStream1 = stream.Stream()
    >>> searchStream1.append(note.Note(quarterLength=1.5))
    >>> searchStream1.append(note.Note(quarterLength=0.5))

    >>> l = search.rhythmicSearch(thisStreamIter, searchStream1)
    >>> l
    [0, 3]
    >>> stream.Stream(thisStreamIter[3:5]).show('text')
    {0.0} <music21.note.Note G>
    {1.5} <music21.note.Note A>

    Slightly more advanced search: we will look for any instances of eighth,
    followed by a note (or other element) of any length, followed by a dotted quarter
    note.  Again, we will find two instances; this time we will tag them both with
    a TextExpression of "*" and then show the original stream:

    >>> searchStream2 = stream.Stream()
    >>> searchStream2.append(note.Note(quarterLength=0.5))
    >>> searchStream2.append(search.Wildcard())
    >>> searchStream2.append(note.Note(quarterLength=1.5))
    >>> l = search.rhythmicSearch(thisStreamIter, searchStream2)
    >>> l
    [1, 4]
    >>> for found in l:
    ...     thisStreamIter[found].lyric = '*'
    >>> #_DOCS_SHOW thisStream.show()

    .. image:: images/searchRhythmic1.*
        :width: 221

    Now we can test the search on a real dataset and show the types
    of preparation that are needed to make it most likely a success.
    We will look through the first movement of Corelli Trio Sonata op. 3 no. 1 (F major)
    looking to see how much more common the first search term (dotted-quarter, eighth)
    is than the second (eighth, anything, dotted-quarter).  In fact, my hypothesis
    was wrong, and the second term is actually more common than the first! (n.b. rests
    are being counted here as well as notes)

    >>> grave = corpus.parse('corelli/opus3no1/1grave')
    >>> term1results = []
    >>> term2results = []
    >>> for p in grave.parts:
    ...    pf = p.flatten().stripTies().notesAndRests  # consider tied notes as one long note
    ...    temp1 = search.rhythmicSearch(pf, searchStream1)
    ...    temp2 = search.rhythmicSearch(pf, searchStream2)
    ...    for found in temp1:
    ...        term1results.append(found)
    ...    for found in temp2:
    ...        term2results.append(found)
    >>> term1results
    [0, 7, 13, 21, 42, 57, 64, 66, 0, 5, 7, 19, 21, 40, 46, 63, 0, 8, 31, 61, 69, 71, 73, 97]
    >>> term2results
    [5, 29, 95]
    >>> float(len(term1results)) / len(term2results)
    8.0
    c                ó^   — d|j         j        v rdS |j         j        | j         j        k    rdS dS )Nr   TF)r
   ry   rr   ©ri   rj   s     r.   rs   z'rhythmicSearch.<locals>.rhythmAlgorithm®  s9   € Ø Ô!2Ô!:Ð:Ð:Ø�4ØÔÔ*¨hÔ.?Ô.MÒMÐMØ�5Øˆtr-   ©r{   ©r   )rz   rG   rs   s      r.   r   r   U  s*   € ðrð ð õ Ð0°*ÈÐXÑXÔXÐXr-   c                ó,   — d„ }t          | ||¬¦  «        S )a¹  
    >>> thisStream = converter.parse('tinynotation: 3/4 c4 d8 e c d e f c D E c c4 d# e')
    >>> searchList = [note.Note('C'), note.Note('D'), note.Note('E')]
    >>> thisStreamIter = thisStream.recurse().notes

    >>> search.noteNameSearch(thisStreamIter, searchList)
    [0, 3, 7]
    >>> searchList2 = [note.Note('C'), search.Wildcard(), note.Note('E')]
    >>> search.noteNameSearch(thisStreamIter, searchList2)
    [0, 3, 7, 11]
    c                óˆ   — d|j         v rdS t          |d¦  «        sdS t          | d¦  «        sdS |j        | j        k    rdS dS )Nr   Tru   F)ry   rv   ru   r~   s     r.   rw   z)noteNameSearch.<locals>.noteNameAlgorithmÅ  s\   € Ø˜Ô)Ð)Ð)Ø�4Ý�x Ñ(Ô(ð 	Ø�5Ý�x Ñ(Ô(ð 	Ø�5àŒ=˜HœMÒ)Ð)Ø�5Øˆtr-   r   r€   )rz   rG   rw   s      r.   r   r   ¸  s*   € ð
ð 
ð 
õ Ð0°*ÐHYÐZÑZÔZÐZr-   c                ó,   — d„ }t          | ||¬¦  «        S )a÷  
    >>> thisStream = converter.parse('tinynotation: 3/4 c4 d8 e c d e f c D E c c4 d# e')
    >>> searchList = [note.Note('C'), note.Note('D'), note.Note('E')]
    >>> for n in searchList:
    ...     n.duration.type = 'eighth'
    >>> thisStreamIter = thisStream.recurse().notes

    >>> search.noteNameRhythmicSearch(thisStreamIter, searchList)
    [3, 7]

    >>> searchList[0].duration = search.WildcardDuration()
    >>> search.noteNameRhythmicSearch(thisStreamIter, searchList)
    [0, 3, 7]
    c                óà   — d|j         v rdS t          |d¦  «        sdS t          | d¦  «        sdS |j        | j        k    rdS d|j        j         v rdS |j        j        | j        j        k    rdS dS )Nr   Tru   Fr   )ry   rv   ru   r
   rr   r~   s     r.   ÚnoteNameRhythmAlgorithmz7noteNameRhythmicSearch.<locals>.noteNameRhythmAlgorithmä  sŽ   € Ø˜Ô)Ð)Ð)Ø�4Ý�x Ñ(Ô(ð 	Ø�5Ý�x Ñ(Ô(ð 	Ø�5àŒ=˜HœMÒ)Ð)Ø�5à Ô!2Ô!:Ð:Ð:Ø�4ØÔÔ*¨hÔ.?Ô.MÒMÐMØ�5àˆtr-   r   r€   )rz   rG   r…   s      r.   r   r   Ô  s*   € ð ð ð õ$ Ð0°*ÐH_Ð`Ñ`Ô`Ð`r-   c                ó€  — d}|                       ¦   «         j        }t          |¦  «        }g }|D ]p}|                      ¦   «         j        }t          |¦  «        }t          j        |||¦  «                             ¦   «         }	|	|_        |                     |	|f¦  «         Œqt          |d„ ¬¦  «        }
d„ |
D ¦   «         }|S )aÀ  
    searches the list of otherStreams and returns an ordered list of matches
    (each stream will have a new property of matchProbability to show how
    well it matches)

    >>> s = converter.parse("tinynotation: 4/4 c4 d8 e16 FF a'4 b-")
    >>> o1 = converter.parse("tinynotation: 4/4 c4 d8 e GG a' b-4")
    >>> o1.id = 'o1'
    >>> o2 = converter.parse("tinynotation: 4/4 d#2 f A a' G b")
    >>> o2.id = 'o2'
    >>> o3 = converter.parse("tinynotation: 4/4 c8 d16 e32 FF32 a'8 b-8")
    >>> o3.id = 'o3'
    >>> l = search.approximateNoteSearch(s, [o1, o2, o3])
    >>> for i in l:
    ...     print(f'{i.id} {i.matchProbability!r}')
    o1 0.666666...
    o3 0.333333...
    o2 0.083333...
    Nc                ó   — d| d         z
  S ©Né   r   r,   ©Úxs    r.   ú<lambda>z'approximateNoteSearch.<locals>.<lambda>  ó   € °!°a¸´d±(€ r-   ©Úkeyc                ó   — g | ]
}|d          ‘ŒS ©r‰   r,   ©Ú.0r‹   s     r.   ú
<listcomp>z)approximateNoteSearch.<locals>.<listcomp>  ó   € Ð.Ð.Ð.˜a�Q�q”TÐ.Ð.Ð.r-   )	ÚflattenÚnotesAndRestsr$   ÚdifflibÚSequenceMatcherÚratioÚmatchProbabilityr_   Úsorted©Ú
thisStreamÚotherStreamsÚisJunkÚnÚthisStreamStrÚ
sorterListÚsÚsnÚthatStreamStrrš   Ú
sortedListÚsortedStreamss               r.   r   r   ù  sÍ   € ð* €FØ×ÒÑÔÔ*€AÝ+¨AÑ.Ô.€MØ€JØð &ð &ˆØ�YŠY‰[Œ[Ô&ˆÝ/°Ñ3Ô3ˆÝÔ'¨°¸}ÑMÔM×SÒSÑUÔUˆØ"ˆÔØ×Ò˜5 !˜*Ñ%Ô%Ð%Ð%Ý˜
Ð(:Ð(:Ð;Ñ;Ô;€JØ.Ð. :Ð.Ñ.Ô.€MØÐr-   c                óÈ  — d}|                       ¦   «         j                             ¦   «         }t          |¦  «        }g }|D ]‚}|                      ¦   «         j                             ¦   «         }t          |¦  «        }t	          j        |||¦  «                             ¦   «         }	|	|_        |                     |	|f¦  «         Œƒt          |d„ ¬¦  «        }
d„ |
D ¦   «         }|S )a»  
    searches the list of otherStreams and returns an ordered list of matches
    (each stream will have a new property of matchProbability to show how
    well it matches)

    >>> s = converter.parse("tinynotation: 4/4 c4 d8 e16 FF a'4 b-")
    >>> o1 = converter.parse("tinynotation: 4/4 c4 d8 e GG a' b-4")
    >>> o1.id = 'o1'
    >>> o2 = converter.parse("tinynotation: 4/4 d#2 f A a' G b")
    >>> o2.id = 'o2'
    >>> o3 = converter.parse("tinynotation: 4/4 c4 d e GG CCC r")
    >>> o3.id = 'o3'
    >>> l = search.approximateNoteSearchNoRhythm(s, [o1, o2, o3])
    >>> for i in l:
    ...     print(f'{i.id} {i.matchProbability!r}')
    o1 0.83333333...
    o3 0.5
    o2 0.1666666...
    Nc                ó   — d| d         z
  S rˆ   r,   rŠ   s    r.   rŒ   z/approximateNoteSearchNoRhythm.<locals>.<lambda><  r�   r-   rŽ   c                ó   — g | ]
}|d          ‘ŒS r‘   r,   r’   s     r.   r”   z1approximateNoteSearchNoRhythm.<locals>.<listcomp>=  r•   r-   )
r–   r—   Ústreamr%   r˜   r™   rš   r›   r_   rœ   r�   s               r.   r   r     så   € ð* €FØ×ÒÑÔÔ*×1Ò1Ñ3Ô3€AÝ3°AÑ6Ô6€MØ€JØð &ð &ˆØ�YŠY‰[Œ[Ô&×-Ò-Ñ/Ô/ˆÝ7¸Ñ;Ô;ˆÝÔ'¨°¸}ÑMÔM×SÒSÑUÔUˆØ"ˆÔØ×Ò˜5 !˜*Ñ%Ô%Ð%Ð%Ý˜
Ð(:Ð(:Ð;Ñ;Ô;€JØ.Ð. :Ð.Ñ.Ô.€MØÐr-   c                óÈ  — d}|                       ¦   «         j                             ¦   «         }t          |¦  «        }g }|D ]‚}|                      ¦   «         j                             ¦   «         }t          |¦  «        }t	          j        |||¦  «                             ¦   «         }	|	|_        |                     |	|f¦  «         Œƒt          |d„ ¬¦  «        }
d„ |
D ¦   «         }|S )a®  
    searches the list of otherStreams and returns an ordered list of matches
    (each stream will have a new property of matchProbability to show how
    well it matches)

    >>> s = converter.parse("tinynotation: 4/4 c4 d8 e16 FF a'4 b-")
    >>> o1 = converter.parse("tinynotation: 4/4 c4 d8 e GG a' b-4")
    >>> o1.id = 'o1'
    >>> o2 = converter.parse("tinynotation: 4/4 d#2 f A a' G b")
    >>> o2.id = 'o2'
    >>> o3 = converter.parse("tinynotation: 4/4 c4 d e GG CCC r")
    >>> o3.id = 'o3'
    >>> l = search.approximateNoteSearchOnlyRhythm(s, [o1, o2, o3])
    >>> for i in l:
    ...     print(f'{i.id} {i.matchProbability!r}')
    o1 0.5
    o3 0.33...
    o2 0.0
    Nc                ó   — d| d         z
  S rˆ   r,   rŠ   s    r.   rŒ   z1approximateNoteSearchOnlyRhythm.<locals>.<lambda>`  r�   r-   rŽ   c                ó   — g | ]
}|d          ‘ŒS r‘   r,   r’   s     r.   r”   z3approximateNoteSearchOnlyRhythm.<locals>.<listcomp>a  r•   r-   )
r–   r—   r¬   r&   r˜   r™   rš   r›   r_   rœ   r�   s               r.   r   r   A  så   € ð* €FØ×ÒÑÔÔ*×1Ò1Ñ3Ô3€AÝ5°aÑ8Ô8€MØ€JØð &ð &ˆØ�YŠY‰[Œ[Ô&×-Ò-Ñ/Ô/ˆÝ9¸"Ñ=Ô=ˆÝÔ'¨°¸}ÑMÔM×SÒSÑUÔUˆØ"ˆÔØ×Ò˜5 !˜*Ñ%Ô%Ð%Ð%Ý˜
Ð(:Ð(:Ð;Ñ;Ô;€JØ.Ð. :Ð.Ñ.Ô.€MØÐr-   c                óF  — d}|                       ¦   «         j                             ¦   «         }t          |¦  «        }t	          |¦  «        }g }|D ]²}|                      ¦   «         j        }t          |¦  «        }	t	          |¦  «        }
t          j        |||	¦  «                             ¦   «         }t          j        |||
¦  «                             ¦   «         }d|z  |z   dz  }||_        | 	                    ||f¦  «         Œ³t          |d„ ¬¦  «        }d„ |D ¦   «         }|S )a7  
    searches the list of otherStreams and returns an ordered list of matches
    (each stream will have a new property of matchProbability to show how
    well it matches)

    >>> s = converter.parse("tinynotation: 4/4 c4 d8 e16 FF a'4 b-")
    >>> o1 = converter.parse("tinynotation: 4/4 c4 d8 e GG2 a' b-4")
    >>> o1.id = 'o1'
    >>> o2 = converter.parse("tinynotation: 4/4 AAA4 AAA8 AAA16 AAA16 AAA4 AAA4")
    >>> o2.id = 'o2'
    >>> o3 = converter.parse("tinynotation: 4/4 c8 d16 e32 FF32 a'8 b-8")
    >>> o3.id = 'o3'
    >>> o4 = converter.parse("tinynotation: 4/4 c1 d1 e1 FF1 a'1 b-1")
    >>> o4.id = 'o4'
    >>> l = search.approximateNoteSearchWeighted(s, [o1, o2, o3, o4])
    >>> for i in l:
    ...     print(f'{i.id} {i.matchProbability!r}')
    o3 0.83333...
    o1 0.75
    o4 0.75
    o2 0.25
    Né   g      @c                ó   — d| d         z
  S rˆ   r,   rŠ   s    r.   rŒ   z/approximateNoteSearchWeighted.<locals>.<lambda>“  r�   r-   rŽ   c                ó   — g | ]
}|d          ‘ŒS r‘   r,   r’   s     r.   r”   z1approximateNoteSearchWeighted.<locals>.<listcomp>”  r•   r-   )r–   r—   r¬   r%   r&   r˜   r™   rš   r›   r_   rœ   )rž   rŸ   r    r¡   ÚthisStreamStrPitchesÚthisStreamStrDurationr£   r¤   r¥   ÚthatStreamStrPitchesÚthatStreamStrDurationÚratioPitchesÚratioDurationrš   r§   r¨   s                   r.   r   r   e  sC  € ð0 €FØ×ÒÑÔÔ*×1Ò1Ñ3Ô3€AÝ:¸1Ñ=Ô=ÐÝ=¸aÑ@Ô@Ðð €JØð &ð &ˆØ�YŠY‰[Œ[Ô&ˆÝ>¸rÑBÔBÐÝ AÀ"Ñ EÔ EÐõ Ô.¨vØ/CØ/CñEô EçEJÂUÁWÄWð 	õ  Ô/°Ø0EØ0EñGô GçGLÂuÁwÄwð 	ð �\Ñ! MÑ1°SÑ8ˆØ"ˆÔØ×Ò˜5 !˜*Ñ%Ô%Ð%Ð%Ý˜
Ð(:Ð(:Ð;Ñ;Ô;€JØ.Ð. :Ð.Ñ.Ô.€MØÐr-   Fc                ó€   — d}g }| D ]0}|t          |¦  «        z  }|r|                     |j        ¦  «         Œ1|s|S ||fS )aÖ  
    takes a stream (or streamIterator) of notesAndRests only and returns
    a string for searching on.

    >>> s = converter.parse("tinynotation: 3/4 c4 d8 r16 FF8. a'8 b-2.")
    >>> sn = s.flatten().notesAndRests
    >>> streamString = search.translateStreamToString(sn)
    >>> print(streamString)
    <P>F<)KQFF_
    >>> len(streamString)
    12

    Chords give the pitch only of the first note and Unpitched objects are
    treated as rests:

    >>> s = stream.Stream([note.Note('C4'), note.Rest(),
    ...                    chord.Chord(['C4', 'E4']), note.Unpitched()])
    >>> streamString = search.translateStreamToString(s)
    >>> list(streamString.encode('utf-8'))
    [60, 80, 127, 80, 60, 80, 127, 80]
    Ú )r#   r_   ÚmeasureNumber)ÚinputStreamOrIteratorÚreturnMeasuresÚbÚmeasuresr¡   s        r.   r$   r$   ™  sd   € ð, 	€AØ€HØ"ð -ð -ˆØ	Õ-¨aÑ0Ô0Ñ0ˆØð 	-Ø�OŠO˜AœOÑ,Ô,Ð,øØð Øˆà�8ˆ}Ðr-   c                ó&  — g }g }d}d}d}| D ]è}d}|r|j         }|j        r0|rŒd}|                     d¦  «         |                     |¦  «         ŒDd}|r|j        �|j        j        dk    rd}Œb|j        �d}|j        j        }	|�||	k    rd}
n||	k    rd}
nd}
|	}t          t          |j	        d         j
        ¦  «        |
z   ¦  «        }|                     |¦  «         |                     |¦  «         Œéd	                     |¦  «        }|s|S ||fS )
a�  
    Translates a Stream or StreamIterator of Notes and Rests only into a string,
    encoding only the .step (no accidental or octave) and whether
    the note is slower, faster, or the same speed as the previous
    note.

    Skips all but the first note of tie. Skips multiple rests in a row

    Each note gets one byte:

    A-G = note of same length as previous
    H-N = note of longer length than previous
    O-U = note of shorter length than previous
    Z = rest

    >>> s = converter.parse("tinynotation: 3/4 c4 d8~ d16 r16 FF8 F#8 a'8 b-2.")
    >>> streamString = search.translateDiatonicStreamToString(s.recurse().notesAndRests)
    >>> print(streamString)
    CRZFFAI
    >>> len(streamString)
    7

    If returnMeasures is True, returns an array of measureNumbers where each entry represents
    the measure number of the measure of the object at that character position :

    >>> streamString2, measures = search.translateDiatonicStreamToString(s.recurse().notesAndRests,
    ...                                    returnMeasures=True)
    >>> streamString == streamString2
    True
    >>> measures
    [1, 1, 1, 1, 1, 2, 2]
    FNTÚZÚstopr   é   é   r»   )r¼   ÚisRestr_   ÚtieÚtyper
   rr   ÚchrÚordÚpitchesÚstepÚjoin)r½   r¾   r¿   rÀ   ÚpreviousRestÚpreviousTieÚ
previousQLr¡   ÚmNumÚqlÚascShiftÚnewNameÚjoineds                r.   r   r   »  sb  € ðD 	€AØ€HØ€LØ€KØ€JØ"ð ð ˆØˆØð 	#Ø”?ˆDàŒ8ð 		!Øð Øà#�Ø—’˜‘”�Ø—’ Ñ%Ô%Ð%Øà ˆLØð 	ØŒuˆ} ¤¤
¨fÒ 4Ð 4Ø#�ØØŒUÐØˆKØŒZÔ%ˆØÐ ¨rÒ!1Ð!1ØˆHˆHØ˜"Š_ˆ_ØˆHˆHàˆHØˆ
Ý•c˜!œ) Aœ,Ô+Ñ,Ô,¨xÑ7Ñ8Ô8ˆØ�Š˜ÑÔÐØ	�Š�ÑÔÐÐà�WŠW�Q‰ZŒZ€FØð "Øˆà˜Ð!Ð!r-   c                óÒ  — g }g }d}d}d}d}|                       t          j        ¦  «        D ]}|j        d         j        } | D �]}d}	|r|j        }	|j        r0|rŒd}|                     d¦  «         |                     |	¦  «         ŒEd}|r|j        �|j        j	        dk    rd}Œc|j        �d}|j
        j        }
|�||
k    rd}n||
k    rd	}nd
}|
}||j        d         j        z
  }|dk    rd}n|dk     rd}|j        d         j        }t          d|z   |z   ¦  «        }|                     |	¦  «         |                     |¦  «         �Œ	d                     |¦  «        }|s|S ||fS )a¥  
    Translates a Stream (not StreamIterator) of Notes and Rests only into a string,
    encoding only the chromatic distance from the last note and whether
    the note is slower, faster, or the same speed as the previous
    note.

    Skips all but the first note of tie. Skips multiple rests in a row

    Each note gets one byte and encodes up from -13 to 13 (all notes > octave are 13 or -13)

    >>> s = converter.parse("tinynotation: 3/4 c4 d8~ d16 r16 F8 F#8 F8 a'8 b-2")
    >>> sn = s.flatten().notesAndRests.stream()
    >>> streamString = search.translateIntervalsAndSpeed(sn)
    >>> print(streamString)
    Ib RHJ<9
    >>> print([ord(x) for x in streamString])
    [73, 98, 32, 82, 72, 74, 60, 57]
    >>> len(streamString)
    8

    If returnMeasures is True, returns a triplet of whether the last note
    was a rest, whether the last note was tied, what the last quarterLength was, and what the
    last pitches' midi number was

    which can be fed back into this algorithm:

    >>> streamString2, measures = search.translateIntervalsAndSpeed(sn, returnMeasures=True)
    >>> streamString == streamString2
    True
    >>> measures
    [1, 1, 1, 1, 1, 2, 2, 2]
    FNé<   r   Tú rÃ   é)   éD   rÄ   é   ióÿÿÿé    r»   )ÚgetElementsByClassr   rZ   rË   Úmidir¼   rÆ   r_   rÇ   rÈ   r
   rr   rÉ   rÍ   )ÚinputStreamr¾   r¿   rÀ   rÎ   rÏ   rÐ   ÚpreviousMidir¡   rÑ   rÒ   rÓ   ÚpitchDifferencerÔ   rÕ   s                  r.   r    r    
  sÎ  € ðD 	€AØ€Hà€LØ€KØ€JØ€LØ×+Ò+­D¬IÑ6Ô6ð ð ˆØ”y ”|Ô(ˆØàð $ñ $ˆØˆØð 	#Ø”?ˆDØŒ8ð 		!Øð Øà#�Ø—’˜‘”�Ø—’ Ñ%Ô%Ð%Øà ˆLØð 	ØŒuˆ} ¤¤
¨fÒ 4Ð 4Ø#�ØØŒUÐØˆKØŒZÔ%ˆØÐ ¨rÒ!1Ð!1ØˆHˆHØ˜"Š_ˆ_Ø"ˆHˆHàˆHØˆ
Ø&¨¬°1¬Ô):Ñ:ˆØ˜RÒÐØ ˆOˆOØ˜sÒ"Ð"Ø!ˆOØ”y ”|Ô(ˆÝ�b˜?Ñ*¨XÑ5Ñ6Ô6ˆØ�Š˜ÑÔÐØ	�Š�ÑÔÐÑà�WŠW�Q‰ZŒZ€FØð "Øˆà˜Ð!Ð!r-   c                ó€   — d}g }| D ]0}|t          |¦  «        z  }|r|                     |j        ¦  «         Œ1|r||fS |S )aó  
    takes a stream or streamIterator of notesAndRests only and returns
    a string for searching on, using translateNoteToByte.

    >>> s = converter.parse("tinynotation: 4/4 c4 d e FF a'2 b-2")
    >>> sn = s.flatten().notesAndRests
    >>> search.translateStreamToStringNoRhythm(sn)
    '<>@)QF'

    With returnMeasures, will return a tuple of bytes and a list of measure numbers:

    >>> search.translateStreamToStringNoRhythm(sn, returnMeasures=True)
    ('<>@)QF', [1, 1, 1, 1, 2, 2])
    r»   )r"   r_   r¼   ©rß   r¾   r¿   rÀ   r¡   s        r.   r%   r%   d  sd   € ð 	€AØ€HØð -ð -ˆØ	Õ  Ñ#Ô#Ñ#ˆØð 	-Ø�OŠO˜AœOÑ,Ô,Ð,øØð Ø�8ˆ}Ðàˆr-   c                ó€   — d}g }| D ]0}|t          |¦  «        z  }|r|                     |j        ¦  «         Œ1|r||fS |S )ag  
    takes a stream or streamIterator of notesAndRests only and returns
    a string for searching on.

    >>> s = converter.parse("tinynotation: 3/4 c4 d8 e16 FF8. a'8 b-2.")
    >>> sn = s.flatten().notesAndRests
    >>> streamString = search.translateStreamToStringOnlyRhythm(sn)
    >>> print(streamString)
    PF<KF_
    >>> len(streamString)
    6
    r»   )r   r_   r¼   rã   s        r.   r&   r&     sd   € ð 	€AØ€HØð -ð -ˆØ	Õ% aÑ(Ô(Ñ(ˆØð 	-Ø�OŠO˜AœOÑ,Ô,Ð,øØð Ø�8ˆ}Ðàˆr-   r¡   únote.GeneralNoterP   Ústrc                ó$  — t          | t          j        ¦  «        rt          | j        j        ¦  «        S t          | t          j        ¦  «        r5| j        rt          | j        d         j        ¦  «        S t          d¦  «        S t          d¦  «        S )a·  
    takes a note.Note object and translates it to a single byte representation in a string.

    currently returns the chr() for the note's midi number. or chr(127) for rests
    and unpitched.

    >>> n = note.Note('C4')
    >>> b = search.translateNoteToByte(n)
    >>> b
    '<'
    >>> ord(b)
    60
    >>> ord(b) == n.pitch.midi
    True

    Chords are currently just searched on the first Note (or treated as a Rest if None)
    r   é   )	rT   r   rZ   rÉ   ÚpitchrÞ   r	   r[   rË   ©r¡   s    r.   r"   r"   ˜  su   € õ& �!•T”YÑÔð Ý�1”7”<Ñ Ô Ð Ý	�A•u”{Ñ	#Ô	#ð ØŒ9ð 	Ý�q”y ”|Ô(Ñ)Ô)Ð)å�s‘8”8ˆOå�3‰xŒxˆr-   TÚincludeTieByteÚboolc                óz   — t          | ¦  «        }t          | ¦  «        }t          | ¦  «        }|r||z   |z   S ||z   S )aG  
    takes a note.Note object and translates it to a three-byte representation as a string.

    currently returns the chr() for the note's midi number. or chr(127) for rests
    followed by the log of the quarter length (fitted to 1-127, see
    :func:`~music21.search.base.translateDurationToBytes`)
    followed by 's', 'c', or 'e' if includeTieByte is True and there is a tie.

    >>> n = note.Note('C4')
    >>> n.duration.quarterLength = 3  # dotted half
    >>> trans = search.translateNoteWithDurationToBytes(n)
    >>> trans
    '<_'
    >>> (2**(ord(trans[1])/10.0))/256  # approximately 3
    2.828...

    >>> n.tie = tie.Tie('stop')
    >>> trans = search.translateNoteWithDurationToBytes(n)
    >>> trans
    '<_e'

    >>> trans = search.translateNoteWithDurationToBytes(n, includeTieByte=False)
    >>> trans
    '<_'
    )r"   r   r!   )r¡   rë   Ú	firstByteÚ
secondByteÚ	thirdBytes        r.   r#   r#   µ  sN   € õ6 $ AÑ&Ô&€IÝ)¨!Ñ,Ô,€JÝ& qÑ)Ô)€IØð &Ø˜:Ñ%¨	Ñ1Ð1à˜:Ñ%Ð%r-   c                ó„   — | j         €dS | j         j        dk    rdS | j         j        dk    rdS | j         j        dk    rdS dS )	aë  
    takes a note.Note object and returns a one-byte representation
    of its tie status.
    's' if start tie, 'e' if stop tie, 'c' if continue tie, and '' if no tie

    >>> n = note.Note('E')
    >>> search.translateNoteTieToByte(n)
    ''

    >>> n.tie = tie.Tie('start')
    >>> search.translateNoteTieToByte(n)
    's'

    >>> n.tie.type = 'continue'
    >>> search.translateNoteTieToByte(n)
    'c'

    >>> n.tie.type = 'stop'
    >>> search.translateNoteTieToByte(n)
    'e'
    Nr»   Ústartr¤   ÚcontinueÚcrÃ   Úe)rÇ   rÈ   rê   s    r.   r!   r!   Ù  sQ   € ð. 	„u€}ØˆrØ	
ŒŒ�wÒ	Ð	ØˆsØ	
ŒŒ�zÒ	!Ð	!ØˆsØ	
ŒŒ�vÒ	Ð	Øˆsàˆrr-   c                óÞ   — d}| j         j        rOt          t          j        | j         j        dz  ¦  «        dz  ¦  «        }t          t          |d¦  «        d¦  «        }t          |¦  «        }|S )aÜ  
    takes a note.Note object and translates it to a two-byte representation

    currently returns the chr() for the note's midi number. or chr(127) for rests
    followed by the log of the quarter length (fitted to 1-127, see formula below)

    >>> n = note.Note('C4')
    >>> n.duration.quarterLength = 3  # dotted half
    >>> trans = search.translateDurationToBytes(n)
    >>> trans
    '_'
    >>> (2 ** (ord(trans[0]) / 10)) / 256  # approximately 3
    2.828...

    r‰   é   é
   rè   )r
   rr   ÚintÚmathÚlog2ÚmaxÚminrÉ   )r¡   Úduration1to127rï   s      r.   r   r   ü  sh   € ð" €NØ„zÔð :Ý�TœY q¤zÔ'?À#Ñ'EÑFÔFÈÑKÑLÔLˆÝ�S °Ñ5Ô5°qÑ9Ô9ˆÝ�^Ñ$Ô$€JØÐr-   c                ó8  — g }| t                    D ]ö}t          |j        ¦  «        }d}|D ]=}|d         |k    r/d}|dxx         dz  cc<   |d                              |¦  «          nŒ>|sœd|dœ}|j        }|D ]m}	t          |	t          j        ¦  «        rQd|d	         j        j	        z
  }
t          j        |¦  «        }|j        D ]}|                     |
d¬
¦  «         Œ||d<    nŒn||d<   |g|d<   |                     |¦  «         Œ÷t          |d„ d¬¦  «        }|S )aõ  
    returns a sorted list of dictionaries
    of the most common rhythms in a stream where
    each dictionary contains:

    number: the number of times a rhythm appears
    rhythm: the rhythm found (with the pitches of the first instance of the rhythm transposed to C5)
    measures: a list of measures containing the rhythm
    rhythmString: a string representation of the rhythm (see translateStreamToStringOnlyRhythm)

    >>> bach = corpus.parse('bwv1.6')
    >>> sortedRhythms = search.mostCommonMeasureRhythms(bach)
    >>> for in_dict in sortedRhythms[0:3]:
    ...     number = in_dict['number']
    ...     rhythmString = in_dict['rhythmString']
    ...     measures = in_dict['measures']
    ...     print(
    ...         f'no: {number} '
    ...         f'rhythmString: {rhythmString}'
    ...     )
    ...     bars = [
    ...         (m.number, str(m.getContextByClass(stream.Part).id))
    ...         for m in measures
    ...     ]
    ...     print(f'bars: {bars!r}')
    ...     in_dict['rhythm'].show('text')
    ...     print('-----')
    no: 34 rhythmString: PPPP
    bars: [(1, 'Soprano'), (2, 'Soprano'), (3, 'Soprano'), ..., (1, 'Alto'), ..., (10, 'Bass')]
    {0.0} <music21.note.Note C>
    {1.0} <music21.note.Note A>
    {2.0} <music21.note.Note F>
    {3.0} <music21.note.Note C>
    -----
    no: 7 rhythmString: ZZ
    bars: [(13, 'Soprano'), (14, 'Soprano'), ..., (14, 'Bass')]
    {0.0} <music21.note.Note C>
    {2.0} <music21.note.Note A>
    -----
    no: 6 rhythmString: ZPP
    bars: [(6, 'Soprano'), (12, 'Soprano'), ..., (18, 'Tenor'), ... (12, 'Bass')]
    {0.0} <music21.note.Note C>
    {2.0} <music21.note.Note B->
    {3.0} <music21.note.Note B->
    -----

    * Changed in v7: bars are ordered first by number, then by part.
    FÚrhythmStringTÚnumberr‰   rÀ   )r  r   éH   r   )ÚinPlaceÚrhythmc                ó   — | d         S )Nr  r,   )Úks    r.   rŒ   z*mostCommonMeasureRhythms.<locals>.<lambda>g  s
   € °A°h´K€ r-   )r�   Úreverse)r   r&   r—   r_   ÚnotesrT   r   rZ   ré   ÚpsÚcopyÚdeepcopyÚ	transposerœ   )ÚstreamInÚtransposeDiatonicÚreturnDictsÚthisMeasurer   ÚrhythmFoundÚentryÚnewDictÚmeasureNotesÚmeasureNoteÚdistanceToTransposeÚthisMeasureCopyr¡   ÚsortedDictss                 r.   r   r     sŠ  € ðb €Kà¥Ô(ð (ð (ˆÝ8¸Ô9RÑSÔSˆØˆØ ð 	ð 	ˆEØ�^Ô$¨Ò4Ð4Ø"�Ø�h��” 1Ñ$��‘Ø�jÔ!×(Ò(¨Ñ5Ô5Ð5Ø�ð	 5ð
 ð 	(àØ ,ðð ˆGð 'Ô,ˆLØ+ð 
0ð 
0�Ý˜k­4¬9Ñ5Ô5ð Ø*,¨|¸A¬Ô/DÔ/GÑ*GÐ'Ý&*¤m°KÑ&@Ô&@�OØ,Ô2ð Gð G˜àŸšÐ$7À˜ÑFÔFÐFÐFØ(7�G˜HÑ%Ø�Eðð %0�˜Ñ!Ø#. -ˆG�JÑØ×Ò˜wÑ'Ô'Ð'øå˜Ð*?Ð*?ÈÐNÑNÔN€KØÐr-   c                  ó   — e Zd ZdS )r   N)r(   r)   r*   r,   r-   r.   r   r   k  s   € € € € € Ø€Dr-   r   c                  ó   — e Zd Zd„ ZdS )ÚTestc                óB   — ddl m}  || t          ¦   «         ¦  «         d S )Nr   )ÚtestCopyAll)Úmusic21.test.commonTestr  Úglobals)r3   r  s     r.   ÚtestCopyAndDeepcopyzTest.testCopyAndDeepcopyq  s0   € Ø7Ð7Ð7Ð7Ð7Ð7Øˆ�D�'™)œ)Ñ$Ô$Ð$Ð$Ð$r-   N)r(   r)   r*   r   r,   r-   r.   r  r  o  s#   € € € € € ð%ð %ð %ð %ð %r-   r  )r   r   r   Ú__main__)N)F)r¡   rå   rP   ræ   )T)r¡   rå   rë   rì   rP   ræ   )r¡   rå   )9r+   Ú
__future__r   Úcollectionsr   Úcollections.abcr   r
  r˜   rú   ÚunittestÚmore_itertoolsr   Úmusic21r   Úm21Baser   r	   r
   r   Úmusic21.streamr   r   r   r   Ú__all__ÚDurationr   ÚMusic21Objectr   r   r   r   r   r   r   r   r   r   r   r$   r   r    r%   r&   r"   r#   r!   r   r   ÚMusic21Exceptionr   ÚTestCaser  Ú
_DOC_ORDERr(   ÚmainTestr,   r-   r.   ú<module>r1     sù  ððð ð
 #Ð "Ð "Ð "Ð "Ð "à "Ð "Ð "Ð "Ð "Ð "Ø $Ð $Ð $Ð $Ð $Ð $Ø €€€Ø €€€Ø €€€Ø €€€à #Ð #Ð #Ð #Ð #Ð #à #Ð #Ð #Ð #Ð #Ð #Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,ðð ð €ð6	ð 	ð 	ð 	ð 	�xÔ(ñ 	ô 	ð 	ð+ð +ð +ð +ð +ˆwÔ$ñ +ô +ð +ð"[ð [ð [ð [ð [�*�*˜]Ð,SÐ,SÐ,SÑTÔTñ [ô [ð [ð&Að Að Að Að Añ Aô Að AðH"ð "ð "ð "ðJ`Yð `Yð `YðF[ð [ð [ð8"að "að "aðJ!ð !ð !ðH!ð !ð !ðH!ð !ð !ðH0ð 0ð 0ðhð ð ð ðDL"ð L"ð L"ð L"ð^W"ð W"ð W"ð W"ðtð ð ð ð6ð ð ð ð2ð ð ð ð:!&ð !&ð !&ð !&ð !&ðH ð  ð  ð  ðFð ð ð ð6Qð Qð Qð Qðh	ð 	ð 	ð 	ð 	�lÔ3ñ 	ô 	ð 	ð%ð %ð %ð %ð %ˆ8Ôñ %ô %ð %ðð ð €
ð ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr-   