
    3jk             
         d dl mZ d dlmZ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 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 ej<                  rd dlm Z  d dl
m!Z! d dl"m#Z#  ejH                  e%      Z&dddd	 	 	 	 	 	 	 	 	 d7dZ'dddddddd	 	 	 d8dZ(dddddd	 	 	 d8dZ)dddejT                  fd	 	 	 d8d Z+dd!d8d"Z,d9d#Z-	 d:	 d;d$Z.d<d%Z/dddddddddd&		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d'Z0d>d(Z1ddddddddd)	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d?d*Z2	 	 d@	 	 	 dAd+Z3ddd,	 	 	 dBd-Z4ddd,	 	 	 dCd.Z5ddd/	 	 	 	 	 	 	 dDd0Z6ddd1	 	 	 	 	 	 	 dEd2Z7ejp                  dFd3       Z9 G d4 d5e	jt                        Z;e<d6k(  rd dl
Z
 e
jz                  e;       yy)G    )annotations)Iterable	GeneratorN)beam)clef)common)chord)defaults)duration)environment)expressions)key)meter)note)pitch)opFrac)
StreamTypeOffsetQL)StreamExceptionFractionstream)StreamIteratorFT)inPlacesetStemDirectionsfailOnNoTimeSignaturec               n   ddl m} |s| j                  d      }n| }t        ||j                        r|g}n8t        |j                  |j                              }|s |j                  d      d}|D ]  }|j                  xs |j                  t        j                        }||r |j                  d      Hg }	|j                         r;|j                  D ]+  }
|	j                  |
j                  j                                - n)|	j                  |j                  j                                |	D ]T  }t!        |      dk  rg }|D ]E  }|j"                  j$                  r|j'                  |       +|j                  |j"                         G t)        |D cg c]  }|j*                   c}      }t-        t-        |            }|j.                  j*                  }||kD  rd}|j0                  dk7  rt-        |j0                        }n.|j2                  dk7  rn|j4                  |k  r||j4                  z
  }|j7                  ||	      }t9        |      D ]-  \  }}||   }|||_        t=        j>                         |_        / W  ~|rtA        |       d
|jB                  _        |s|S yc c}w )a  
    Return a new Measure, or Stream of Measures, with beams applied to all
    notes. Measures with Voices will process voices independently.

    Note that `makeBeams()` is automatically called in show('musicxml') and
    other formats if there is no beaming information in the piece (see
    `haveBeamsBeenMade`).

    If `inPlace` is True, this is done in-place; if `inPlace` is False,
    this returns a modified deep copy.

    .. note:: Before Version 1.6, `inPlace` default was `True`; now `False`
        like most `inPlace` options in music21.  Also, in 1.8, no tuplets are made
        automatically.  Use makeTupletBrackets()

    See :meth:`~music21.meter.TimeSignature.getBeams` for the algorithm used.

    >>> aMeasure = stream.Measure()
    >>> aMeasure.timeSignature = meter.TimeSignature('4/4')
    >>> aNote = note.Note()
    >>> aNote.quarterLength = 0.25
    >>> aMeasure.repeatAppend(aNote, 16)
    >>> bMeasure = aMeasure.makeBeams(inPlace=False)

    >>> for i in range(4):
    ...   print(f'{i} {bMeasure.notes[i].beams!r}')
    0 <music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>
    1 <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/stop>>
    2 <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/start>>
    3 <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>

    This was formerly a bug -- we could not have a partial-left beam at the start of a
    beam group.  Now merges across the archetypeSpan

    >>> aMeasure = stream.Measure()
    >>> aMeasure.timeSignature = meter.TimeSignature('4/4')
    >>> for i in range(4):
    ...     aMeasure.append(note.Rest(quarterLength=0.25))
    ...     aMeasure.repeatAppend(note.Note('C4', quarterLength=0.25), 3)
    >>> bMeasure = aMeasure.makeBeams(inPlace=False).notes
    >>> for i in range(6):
    ...   print(f'{i} {bMeasure[i].beams!r}')
    0 <music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>
    1 <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/continue>>
    2 <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>
    3 <music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>
    4 <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/continue>>
    5 <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>

    Grace notes no longer interfere with beaming:

    >>> m = stream.Measure()
    >>> m.timeSignature = meter.TimeSignature('3/4')
    >>> m.repeatAppend(note.Note(quarterLength=0.25), 4)
    >>> m.repeatAppend(note.Rest(), 2)
    >>> gn = note.Note(duration=duration.GraceDuration())
    >>> m.insert(0.25, gn)
    >>> m.makeBeams(inPlace=True)
    >>> [n.beams for n in m.notes]
    [<music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>,
    <music21.beam.Beams>,
    <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/stop>>,
    <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/start>>,
    <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>]

    OMIT_FROM_DOCS
    TODO: inPlace=False does not work in many cases  ?? still an issue? 2017
    r   r   	makeBeamszEcannot process a stream that is neither a Measure nor has no MeasuresN:cannot process beams in a Measure without a time signature           )measureStartOffsetT)"music21r   coreCopyAsDerivation
isinstanceMeasurelistgetElementsByClassr   timeSignaturegetContextByClassr   TimeSignature	hasVoicesvoicesappendnotesAndRestslenr   isGraceremovesumquarterLengthr   barDurationpaddingLeftpaddingRighthighestTimegetBeams	enumeratebeamsr   BeamssetStemDirectionForBeamGroupsstreamStatus)sr   r   r   r   	returnObjmColllastTimeSignaturem
noteGroupsv
noteStreamdurListndsummeddurSumbarQLoffset	beamsListi	thisBeamss                         H/DATA/.local/lib/python3.12/site-packages/music21/stream/makeNotation.pyr   r   3   s   X  **;7		 )V^^,Y11&..AB(&((WY Y   OOWq/B/B5CVCV/W$$,f,,PR R
;;=XX!!!//"8"8":;  aoo4467 %J:!#G::%%%%a(qzz*	   7;7a!//7;<F F6N+F%11??E~  &)F}}#.3&''%/!7!77)22:RX2YI!*-1%aL	('AG"jjlAG ._ %) T 	%i0#'I [ <s   J2finalmeterStreamrefStreamOrTimeRangesearchContextinnerBarlinefinalBarlinebestClefr   c          
        ddl m} ddl m}	 d}
| j                         rM|r| }nt	        j
                  |       }|j                  d      D ]  }|j                  ||||||d        |ry|S | j                         r| }n| j                         }|j                  s|j                         }|st	        j
                  |      }t        |j                        }||j                  ddd	      }nht        |t         j"                        r&|} |	j$                         }|j'                  d|       n(t        ||	j$                        s |	j(                  d
      |j+                         }|j,                  xs |j/                  t,        j0                        }|U|j                  t,        j0                        j3                  d      j5                         }|st-        j6                  |d      }|j9                         }|r$t;        |D cg c]  }|j<                   c}      }nd}|:t        ||	j$                        r|j>                  }nt;        |      }t;        ||      }| jA                         }| |jB                  _"        d|jB                  _#        d}d}d}	  |	jH                         }|dz   |_%        |jM                  |      }|| |	j(                  d      ||ur||}t	        j
                  |      |_'        |dk(  rG||_        |dkD  r;| jP                  /|j'                  dt	        j
                  | jP                               tS        |      D ],  } |	jT                         }||_+        |jY                  d|       . |r|j[                          |j\                  j^                  dk(  r |	j(                  d|d      |jY                  ||       ||j\                  j^                  z  }||k\  rn|dz  }c|j[                          t        |      }g }t!        j"                  d      }tS        |      D ]^  } ||    }|jN                  |jN                  }|ja                  |      }
|
|j\                  j^                  z   }!|jc                  ||
|!d       ` |D ]  }"|"\  }#}$}%}t        |#|jd                        r|jc                  |#       3d}&tS        |      D ](  } ||    }'|'d   }
|'d   }!|'d   }|
|$cxk  r|!k  s#n &d}& n |&s<|$|%cxk(  r|k(  rn n|jg                  |#        |	j(                  d|# d|$ d|% d      |$|
z
  }(|j,                  |#u r|(dk(  rt        |#t         j"                        r||j'                  |(|#       |j                  |   j'                  |(|#        |D ]  })|jc                  |)        ~t        |j                  |	jH                              dz
  }*ti        |j                  |	jH                              D ]@  \  } }| |*k7  r|dvr||_5        n|dvr||_5        |s%t-        j6                  |d      |_        B |s|jm                  dd       |S g | _7        g | _8        | j[                          |j                  r|}+n|j                         }+|+D ]#  }#| j'                  |ja                  |#      |#       % yc c}w )a  
    Takes a stream and places all of its elements into
    measures (:class:`~music21.stream.Measure` objects)
    based on the :class:`~music21.meter.TimeSignature` objects
    placed within
    the stream. If no TimeSignatures are found in the
    stream, a default of 4/4 is used.

    If `inPlace` is True, the original Stream is modified and lost
    if `inPlace` is False, this returns a modified deep copy.

    Many advanced features are available:

    (1) If a `meterStream` is given, the TimeSignatures in this
    stream are used instead of any found in the Stream.
    Alternatively, a single TimeSignature object
    can be provided in lieu of the stream. This feature lets you
    test out how a group of notes might be interpreted as measures
    in a number of different metrical schemes.

    (2) If `refStreamOrTimeRange` is provided, this Stream or List
    is used to give the span that you want to make measures as
    necessary to fill empty rests at the ends or beginnings of
    Streams, etc.  Say for instance you'd like to make a complete
    score from a short ossia section, then you might use another
    Part from the Score as a `refStreamOrTimeRange` to make sure
    that the appropriate measures of rests are added at either side.

    (3) If `innerBarline` is not None, the specified Barline object
    or string-specification of Barline style will be used to create
    Barline objects between every created Measure. The default is None.

    (4) If `finalBarline` is not None, the specified Barline object or
    string-specification of Barline style will be used to create a Barline
    objects at the end of the last Measure. The default is 'final'.

    The `searchContext` parameter determines whether context
    searches are used to find Clef and other notation objects.

    Here is a simple example of makeMeasures:

    A single measure of 4/4 is created from a Stream
    containing only three quarter notes:

    >>> sSrc = stream.Stream()
    >>> sSrc.append(note.Note('C4', type='quarter'))
    >>> sSrc.append(note.Note('D4', type='quarter'))
    >>> sSrc.append(note.Note('E4', type='quarter'))
    >>> sMeasures = sSrc.makeMeasures()
    >>> sMeasures.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
        {1.0} <music21.note.Note D>
        {2.0} <music21.note.Note E>
        {3.0} <music21.bar.Barline type=final>

    Notice that the last measure is incomplete -- makeMeasures
    does not fill up incomplete measures.

    We can also check that the measure created has
    the correct TimeSignature:

    >>> sMeasures[0].timeSignature
    <music21.meter.TimeSignature 4/4>

    Now let's redo this work in 2/4 by putting a TimeSignature
    of 2/4 at the beginning of the stream and rerunning
    makeMeasures. Now we will have two measures, each with
    correct measure numbers:

    >>> sSrc.insert(0.0, meter.TimeSignature('2/4'))
    >>> sMeasuresTwoFour = sSrc.makeMeasures()
    >>> sMeasuresTwoFour.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 2/4>
        {0.0} <music21.note.Note C>
        {1.0} <music21.note.Note D>
    {2.0} <music21.stream.Measure 2 offset=2.0>
        {0.0} <music21.note.Note E>
        {1.0} <music21.bar.Barline type=final>

    Let us put 10 quarter notes in a Part.

    >>> sSrc = stream.Part()
    >>> n = note.Note('E-4')
    >>> n.quarterLength = 1
    >>> sSrc.repeatAppend(n, 10)

    After we run makeMeasures, we will have
    3 measures of 4/4 in a new Part object. This experiment
    demonstrates that running makeMeasures does not
    change the type of Stream you are using:

    >>> sMeasures = sSrc.makeMeasures()
    >>> len(sMeasures.getElementsByClass(stream.Measure))
    3
    >>> sMeasures.__class__.__name__
    'Part'

    Demonstrate what `makeMeasures` will do with `inPlace` = True:

    >>> sScr = stream.Score()
    >>> sPart = stream.Part()
    >>> sPart.insert(0, clef.TrebleClef())
    >>> sPart.insert(0, meter.TimeSignature('3/4'))
    >>> sPart.append(note.Note('C4', quarterLength = 3.0))
    >>> sPart.append(note.Note('D4', quarterLength = 3.0))
    >>> sScr.insert(0, sPart)
    >>> sScr.makeMeasures(inPlace=True)
    >>> sScr.show('text')
    {0.0} <music21.stream.Part 0x...>
        {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>
        {3.0} <music21.stream.Measure 2 offset=3.0>
            {0.0} <music21.note.Note D>
            {3.0} <music21.bar.Barline type=final>

    If after running makeMeasures you run makeTies, it will also split
    long notes into smaller notes with ties.  Lyrics and articulations
    are attached to the first note.  Expressions (fermatas,
    etc.) will soon be attached to the last note but this is not yet done:

    >>> p1 = stream.Part()
    >>> p1.append(meter.TimeSignature('3/4'))
    >>> longNote = note.Note('D#4')
    >>> longNote.quarterLength = 7.5
    >>> longNote.articulations = [articulations.Staccato()]
    >>> longNote.lyric = 'hi'
    >>> p1.append(longNote)
    >>> partWithMeasures = p1.makeMeasures()
    >>> partWithMeasures is not p1
    True
    >>> dummy = partWithMeasures.makeTies(inPlace=True)
    >>> partWithMeasures.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 D#>
    {3.0} <music21.stream.Measure 2 offset=3.0>
        {0.0} <music21.note.Note D#>
    {6.0} <music21.stream.Measure 3 offset=6.0>
        {0.0} <music21.note.Note D#>
        {1.5} <music21.bar.Barline type=final>

    >>> allNotes = partWithMeasures.flatten().notes
    >>> allNotes[0].articulations
    []

    >>> allNotes[1].articulations
    []

    >>> allNotes[2].articulations
    [<music21.articulations.Staccato>]

    >>> [allNotes[0].lyric, allNotes[1].lyric, allNotes[2].lyric]
    ['hi', None, None]

    * Changed in v6: all but first attribute are keyword only.
    * Changed in v7: now safe to call `makeMeasures` directly on a score containing parts.
    r   )spannerr   NStreamTrT   F)returnDefaultrW   sortByCreationTime4meterStream is neither a Stream nor a TimeSignature!)recursemakeMeasuresr"   r!   zDfailed to find TimeSignature in meterStream; cannot process Measuresztime signature z has no duration4/4)measuremStartmEndre   rf   rd   zcannot place element z with start/end /z within any measures)regularN)9r$   r\   r   hasPartLikeStreamscopydeepcopyr)   rb   r-   flattenisSortedsortedr1   r.   getTimeSignaturesr&   r   r,   r]   insertr   SpannerBundler   r+   ClefgetElementsByOffsetfirstrZ   	offsetMapmaxendTimer9   	__class__
derivationoriginmethodr'   numbergetElementAtOrBeforer*   keySignaturerangeVoiceid
coreInsertcoreElementsChangedr6   r5   elementOffsetr/   Spanner
storeAtEndr;   rightBarlinesetDerivationMethod	_elements_endElements),r@   rU   rV   rW   rX   rY   rZ   r   r\   r   re   rA   	substreamsrcObj
voiceCounttsspannerBundleAccumclefObjoffsetMapListxoMaxrefStreamHighestTimepostomeasureCountrC   rD   thisTimeSignature
voiceIndexrF   postLenpostMeasureListrP   rf   oneOffsetMapestartendmatchpostMeasureInfooNewsp	lastIndex
postSorteds,                                               rR   rb   rb      s   `  F 	Ia(I"55h?I""{8L1>0<0<,4+/ # % @ ;;= FYY[F]]_F]]6*F'
 ..$ / 
 
K!4!4	5#fmmo1b!+v}}5(&((FH H !..0 kk@V55dii@G++DII6JJ1MSSUmmFD9G $$&M }5}!AII}56 '*FMM:#7#C#C #&';#< 4-. ;;=DDOO+DOOAL
FNN!# (<<Q? $):)B(&((,- - %66%1 1 #mm,=>AO
 1AFA~!.."<DMM!..9:
  
+JAADLLA , !!# ((66!;(&((!"3!66FGI I1	**8889ALm p 	 $iGO++E27^G??& ! ##A&)55CCC 	1*0(, . 	/  &$0!5#z a)%%a(wA-a0O$X.F"6*D	*A%%    #t#",f,,+A3.>ugQseK_`b b v~ 66Q; 19Au':':; HHT1HHZ ''a0u &z !B ! 	 D++FNN;<q@I$11&..AB1	>#44!-#44!-]]1d3AF C    > 	==JJAHHT''*A.  G 6s   [)rV   fillGapstimeRangeFromBarDurationr   	hideRestsc          	     B	   ddl m} |s| j                  d      }n| }d|j                  _        |j                         j                  r:|j                         j                  D ]  }|j                  d||||        |ry|S 	 	 d	 	 	 	 	 dd}	d}
d}|rt        ||j                        r
 |	|	      }nt        ||j                        rst        ||j                        r
 |	|	      }nt        |t        j                        r}d}t        |j                  |j                        r|j                  } |	||
      }nD|j                         r4t        t!        d |j#                  |j                        D                    }|dk(  ri||j$                  }nZt        ||j&                        r|j(                  }
|j$                  }n+t+        j,                  |      rt/        |      }
t1        |      }|j3                         rt5        |j6                        }n.|j                         rt5        |j#                  d            }n|g}d}|D ]  }|j(                  }|j$                  }|j8                  xs |}t        ||j                        rp|xs |}|r	 |	||      }|j6                  D ]  }|j                  d||||        |j(                  }|j$                  }t/        |j:                  j<                  |      }||
z
  }|dkD  rHt?        j@                         }||jB                  _        ||jD                  _#        |jI                  |
|       ||z
  }|dkD  rHt?        j@                         }||jB                  _        ||jD                  _#        |jI                  ||       |sZ|jK                         }|n|D ]h  }t?        j@                         }|jB                  j<                  |jB                  _        ||jD                  _#        |jI                  |jL                  |       j  |j                         re|jO                  t>        j@                  fd       d}|j#                  |j                        D ]#  }|jQ                  ||       ||j$                  z  }% |dur|S y)a)  
    Given a Stream with an offset not equal to zero,
    fill with one Rest preceding this offset.
    This can be called on any Stream,
    a Measure alone, or a Measure that contains
    Voices. This method recurses into Parts, Measures, and Voices,
    since users are unlikely to want "loose" rests outside sub-containers.

    If `refStreamOrTimeRange` is provided as a Stream, this
    Stream is used to get min and max offsets. If a list is provided,
    the list assumed to provide minimum and maximum offsets. Rests will
    be added to fill all time defined within refStream.

    If `fillGaps` is True, this will create rests in any
    time regions that have no active elements.

    If `timeRangeFromBarDuration` is True, and the calling Stream
    is a Measure with a TimeSignature (or a Part containing them),
    the time range will be determined
    by taking the :meth:`~music21.stream.Measure.barDuration` and subtracting
    :attr:`~music21.stream.Measure.paddingLeft` and
    :attr:`~music21.stream.Measure.paddingRight`.
    This keyword takes priority over `refStreamOrTimeRange`.
    If both are provided, `timeRangeFromBarDuration`
    prevails, unless no TimeSignature can be found, in which case, the function
    falls back to `refStreamOrTimeRange`.

    If `inPlace` is True, this is done in-place; if `inPlace` is False,
    this returns a modified deepcopy.

    >>> a = stream.Stream()
    >>> a.insert(20, note.Note())
    >>> len(a)
    1
    >>> a.lowestOffset
    20.0
    >>> a.show('text')
    {20.0} <music21.note.Note C>

    Now make some rests:

    >>> b = a.makeRests(inPlace=False)
    >>> len(b)
    2
    >>> b.lowestOffset
    0.0
    >>> b.show('text')
    {0.0} <music21.note.Rest 20ql>
    {20.0} <music21.note.Note C>
    >>> b[0].duration.quarterLength
    20.0

    Same thing, but this time, with gaps, and hidden rests:

    >>> a = stream.Stream()
    >>> a.insert(20, note.Note('C4'))
    >>> a.insert(30, note.Note('D4'))
    >>> len(a)
    2
    >>> a.lowestOffset
    20.0
    >>> a.show('text')
    {20.0} <music21.note.Note C>
    {30.0} <music21.note.Note D>
    >>> b = a.makeRests(fillGaps=True, inPlace=False, hideRests=True)
    >>> len(b)
    4
    >>> b.lowestOffset
    0.0
    >>> b.show('text')
    {0.0} <music21.note.Rest 20ql>
    {20.0} <music21.note.Note C>
    {21.0} <music21.note.Rest 9ql>
    {30.0} <music21.note.Note D>
    >>> b[0].style.hideObjectOnPrint
    True

    Now with measures:

    >>> a = stream.Part()
    >>> a.insert(4, note.Note('C4'))
    >>> a.insert(8, note.Note('D4'))
    >>> len(a)
    2
    >>> a.lowestOffset
    4.0
    >>> a.insert(0, meter.TimeSignature('4/4'))
    >>> a.makeMeasures(inPlace=True)
    >>> a.show('text', addEndTimes=True)
    {0.0 - 0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0 - 0.0} <music21.clef.TrebleClef>
        {0.0 - 0.0} <music21.meter.TimeSignature 4/4>
    {4.0 - 5.0} <music21.stream.Measure 2 offset=4.0>
        {0.0 - 1.0} <music21.note.Note C>
    {8.0 - 9.0} <music21.stream.Measure 3 offset=8.0>
        {0.0 - 1.0} <music21.note.Note D>
        {1.0 - 1.0} <music21.bar.Barline type=final>
    >>> a.makeRests(fillGaps=True, inPlace=True)
    >>> a.show('text', addEndTimes=True)
    {0.0 - 4.0} <music21.stream.Measure 1 offset=0.0>
        {0.0 - 0.0} <music21.clef.TrebleClef>
        {0.0 - 0.0} <music21.meter.TimeSignature 4/4>
        {0.0 - 4.0} <music21.note.Rest whole>
    {4.0 - 8.0} <music21.stream.Measure 2 offset=4.0>
        {0.0 - 1.0} <music21.note.Note C>
        {1.0 - 4.0} <music21.note.Rest dotted-half>
    {8.0 - 12.0} <music21.stream.Measure 3 offset=8.0>
        {0.0 - 1.0} <music21.note.Note D>
        {1.0 - 4.0} <music21.note.Rest dotted-half>
        {4.0 - 4.0} <music21.bar.Barline type=final>

    * Changed in v6: all but first attribute are keyword only.
    * Changed in v7:
      - `inPlace` defaults False.
      - Recurses into parts, measures, voices.
      - Gave priority to `timeRangeFromBarDuration` over `refStreamOrTimeRange`.
    * Changed in v8: scores (or other streams having parts) edited `inPlace` return `None`.
    r   r   	makeRestsNT)r   r   r   rV   r   c                    d}||j                   j                  }n| | j                   j                  }| )|| j                  z  }|| j                  z  }t	        |      }t        |d      S )zd
        Needed for timeRangeFromBarDuration.
        Returns 0.0 if no meter can be found.
        r"   )r6   r5   r7   r8   r   rv   )rD   r   r   s      rR   oHighTargetForMeasurez(makeRests.<locals>.oHighTargetForMeasure^  sg     >>>//D]==..D=AMM!DANN"D$<D4~    r"   )rD   )rD   r   c              3  H   K   | ]  }|j                   j                    y wN)r6   r5   ).0rD   s     rR   	<genexpr>zmakeRests.<locals>.<genexpr>  s      %5a++5as    "r'   )classFilterListr   )NN)rD   zstream.Measure | Noner   zmeter.TimeSignature | Nonereturnr   ))r$   r   r%   r?   tupletsiterpartsr   r&   r'   r   r   r,   
activeSitehasMeasuresr   r4   r)   r9   r]   lowestOffsetr   
isIterableminrv   r-   r(   r.   r*   r6   r5   r   Restr   stylehideObjectOnPrintrp   findGapsrN   makeTiessetElementOffset)r@   rV   r   r   r   r   r   rA   
inner_partr   
oLowTargetoHighTargetmaybe_measurebundlerC   	componentoLowoHights_or_measureinner_voiceqLenr	gapStreamr   accumulatedTimerD   s                             rR   r   r     sU   ~ **;7		 &*I"~~#..*00J  !#%9)A !  1  "&'+$ 
( JKi0/)<K	6<<0.?36JK0%2E2EF59i22FNNC$-$8$8M3mH\]""$ ! %5>5Q5QRXR`R`5a% " K
 c'#//K,fmm<-::J.::K3412J23K i&&'				 i229=>26	%%%%%33H7Hi0-:M'3I?PQ(//%%d/709;H?W	 & (  0 ))D))Em77EE{SK j !8		A'+AJJ$(1AGG% Z+ U"!8		A'+AJJ$(1AGG%UA&!**,I$"A		A/0zz/G/GAJJ,09AGG-$$QXXq1	 #Y d DII<F --fnn=A&&q/:q}},O > d r   rU   r   displayTiedAccidentalsr   c               "   ddl m} |s| j                  d      }n| }|s |j                  d      t	        j
                  |      s|g}t        ||j                        rC|j                  D ]  }|j                  |d||        |st        j                  t        |      S y|j                         r:|j                  |j                        D ]  }|j                  |d||        |s|S y|j!                         s |j                  d      ||j#                  dd	
      }nJ|sHt%        j&                  t(        j*                   dt(        j,                         }	|j/                  d|	       d}
t1        |j                  |j2                              }|
t5        |      k  r7||
   }|j7                  |j8                        }|
dz   t5        |      k  r||
dz      }d	}nQ |j2                         }|j8                  }||j:                  j<                  z   |_        |j>                  dz   |_        d}|jA                         rd}nd	}|j:                  j<                  }|jA                         r|jB                  }d}n|g}d	}|D ]@  }|D ]7  }|jD                  jG                  |      r |jH                  }|jK                  |      }tM        ||jN                  j<                  z         }||z
  }|dk  rj||k\  rp||z
  }|jQ                  |d|      \  }}|rD|r2t        |tR              s|jB                  |   }nA|jU                  |      }n/|jB                  d   }n|rtW        |       |jB                  d   }nd}||}|j/                  d|       |s|j/                  |j8                  |       |jY                  |       : C |
dz  }
|
t5        |      k  r7|j                  |j2                        D ]  }|j[                  d        |s|S y)a  
    Given a stream containing measures, examine each element in the
    Stream. If the element's duration extends beyond the measure's boundary,
    create a tied entity, placing the split Note in the next Measure.

    Note that this method assumes that there is appropriate space in the
    next Measure: this will not shift Note objects, but instead allocate
    them evenly over barlines.

    If `inPlace` is True, this is done in-place;
    if `inPlace` is False, this returns a modified deep copy.

    Put a 12-quarter-note-long note into a Stream w/ 4/4 as the duration.

    >>> d = stream.Stream()
    >>> d.insert(0, meter.TimeSignature('4/4'))
    >>> n = note.Note('C4')
    >>> n.quarterLength = 12
    >>> d.insert(0, n)
    >>> d.show('text')
    {0.0} <music21.meter.TimeSignature 4/4>
    {0.0} <music21.note.Note C>

    After running makeMeasures, we get nice measures, a clef, but only one
    way-too-long note in Measure 1:

    >>> x = d.makeMeasures()
    >>> x.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
    {4.0} <music21.stream.Measure 2 offset=4.0>
    <BLANKLINE>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.bar.Barline type=final>
    >>> n2 = x.measure(1).notes[0]
    >>> n2.duration.quarterLength
    12.0
    >>> n2 is n
    False

    But after running makeTies, all is good:

    >>> x.makeTies(inPlace=True)
    >>> x.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Note C>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Note C>
        {4.0} <music21.bar.Barline type=final>
    >>> m = x.measure(1).notes[0]
    >>> m.duration.quarterLength
    4.0
    >>> m is n
    False
    >>> m.tie
    <music21.tie.Tie start>
    >>> x.measure(2).notes[0].tie
    <music21.tie.Tie continue>
    >>> x.measure(3).notes[0].tie
    <music21.tie.Tie stop>

    Same experiment, but with rests:

    >>> d = stream.Stream()
    >>> d.insert(0, meter.TimeSignature('4/4'))
    >>> r = note.Rest()
    >>> r.quarterLength = 12
    >>> d.insert(0, r)
    >>> x = d.makeMeasures()
    >>> x.makeTies(inPlace=True)
    >>> x.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Rest whole>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Rest whole>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Rest whole>
        {4.0} <music21.bar.Barline type=final>

    Notes: uses base.Music21Object.splitAtQuarterLength() once it has figured out
    what to split.

    * Changed in v4: inPlace = False by default.
    * Changed in v6: all but first attribute are keyword only.
    * New in v7: `classFilterList` acts as a filter on what elements will
      be operated on (i.e. have durations split and/or ties made).
      The default `(note.GeneralNote,)` includes Notes, Chords, and Rests.

    Here will we split and make ties only on Notes, leaving the too-long
    rest in measure 1 alone.

    >>> p = stream.Part()
    >>> p.append(meter.TimeSignature('2/4'))
    >>> p.insert(0.0, note.Rest(quarterLength=3.0))
    >>> p.insert(3.0, note.Note(quarterLength=3.0))
    >>> p.makeMeasures(inPlace=True)
    >>> p.makeTies(classFilterList=[note.Note], inPlace=True)
    >>> p.show('text', addEndTimes=True)
    {0.0 - 3.0} <music21.stream.Measure 1 offset=0.0>
        {0.0 - 0.0} <music21.clef.TrebleClef>
        {0.0 - 0.0} <music21.meter.TimeSignature 2/4>
        {0.0 - 3.0} <music21.note.Rest dotted-half>
    {2.0 - 4.0} <music21.stream.Measure 2 offset=2.0>
        {1.0 - 2.0} <music21.note.Note C>
    {4.0 - 6.0} <music21.stream.Measure 3 offset=4.0>
        {0.0 - 2.0} <music21.note.Note C>
        {2.0 - 2.0} <music21.bar.Barline type=final>
    >>> p.measure(3).notes[0].tie
    <music21.tie.Tie stop>

    OMIT_FROM_DOCS

    configure ".previous" and ".next" attributes

    Previously a note tied from one voice could not make ties into a note
    in the next measure outside of voices.  Fixed May 2017

    >>> p = stream.Part()
    >>> m1 = stream.Measure(number=1)
    >>> m2 = stream.Measure(number=2)
    >>> m1.append(meter.TimeSignature('1/4'))
    >>> v1 = stream.Voice(id='v1')
    >>> v2 = stream.Voice(id=2)  # also test problems with int voice ids
    >>> n1 = note.Note('C4')
    >>> n1.tie = tie.Tie('start')
    >>> n2 = note.Note('D--4')
    >>> n2.tie = tie.Tie('start')
    >>> v1.append(n1)
    >>> v2.append(n2)
    >>> n3 = note.Note('C4')
    >>> n3.tie = tie.Tie('stop')
    >>> m2.append(n3)
    >>> m1.insert(0, v1)
    >>> m1.insert(0, v2)
    >>> p.append([m1, m2])
    >>> p2 = p.makeTies()

    test same thing with needed makeTies:

    >>> p = stream.Part()
    >>> m1 = stream.Measure(number=1)
    >>> m2 = stream.Measure(number=2)
    >>> m1.append(meter.TimeSignature('1/4'))
    >>> v1 = stream.Voice(id='v1')
    >>> v2 = stream.Voice(id=2)  # also test problems with int voice ids
    >>> n1 = note.Note('C4', quarterLength=2)
    >>> n2 = note.Note('B4')
    >>> v1.append(n1)
    >>> v2.append(n2)
    >>> m1.insert(0, v1)
    >>> m1.insert(0, v2)
    >>> p.append(m1)
    >>> p.insert(1.0, m2)
    >>> p2 = p.makeTies()
    >>> p2.show('text')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.meter.TimeSignature 1/4>
        {0.0} <music21.stream.Voice v1>
            {0.0} <music21.note.Note C>
        {0.0} <music21.stream.Voice 2>
            {0.0} <music21.note.Note B>
    {1.0} <music21.stream.Measure 2 offset=1.0>
        {0.0} <music21.note.Note C>

    >>> for n in p2.recurse().notes:
    ...     print(n, n.tie)
    <music21.note.Note C> <music21.tie.Tie start>
    <music21.note.Note B> None
    <music21.note.Note C> <music21.tie.Tie stop>

    Be helpful and wrap `classFilterList` in a list if need be.

    >>> m = stream.Measure([note.Note(quarterLength=8.0)])
    >>> m.insert(0, meter.TimeSignature('4/4'))
    >>> p = stream.Part([m])
    >>> p.makeTies(inPlace=True, classFilterList='Note')
    >>> len(p.getElementsByClass(stream.Measure))
    2
    >>> p.recurse().last().tie
    <music21.tie.Tie stop>
    r   r   r   zcannot process an empty streamTr   Nz(cannot process a stream without measuresF)r_   rW   rg   r!   )retainOriginr   r   ).r$   r   r%   r   r   r   r&   Opusscoresr   tcastr   ri   r)   r]   r   ro   r   r,   r
   meterNumeratormeterDenominatorBeatTyperp   r(   r'   r1   r}   rN   r6   r5   r|   r-   r.   classSet
isdisjointr   r   r   r   splitAtQuarterLengthintgetElementByIdmoveNotesToVoicesr/   flattenUnnecessaryVoices)r@   rU   r   r   r   r   rA   subScorepr   mCountmeasureListrD   activeTSmNextmNextAddmOffsetmNextHasVoicesrf   r   
mHasVoicesrF   r   vIdeOffseteEndovershotqLenWithinMeasureeRemaindstrd   s                                  rR   r   r     s   L 
 **:6		$f$$%EFF_-*+)V[[)!((H+&*5K.=    ) 66*i00##% --fmm<AJJ;#.D'6   =    "$f$$%OPP 11T@E 2 G  &&'q)J)J(KL
 	1b!Fy33FNNCDK
3{#
#33AHH= A:K((
+EH"FNN$EhhG#&22@@AEL 88a<ELH??!N"N ##11 ;;=XXFJSFJA::((9dd
 //!,g

(@(@@A$;q=d? %)7N!33%!%+A 4 
7 "!)#s3"',,s"3C"'"6"6s";C $ll1o ")%0#ll1o";C
 

1g&
  $$U\\59&&u-I  L 	!] 3{#
#` //?(((6 @ r   r   c               "   g }|s| j                  d      }n| }|j                  D ]4  }|j                  j                  r|j	                  |j                         6 g }|D ]t  }|j
                  }|s|j	                  d|f       %t        |      dkD  r,t        j                  d|       |j	                  d|f       _|j	                  |d   |f       v d}d}	d}
t        |      D ]  \  }\  }}|t        |      dz
  k  r||dz      d   }nd}|et        ||j                  z         }|
|	+|d|_        d|_        d}n6d	|_        |j                         }	n|||	k\  rd
|_        d}	d}n|
	|d|_        |}
 d|j                  _        |s|S y)a  
    Given a flat Stream of mixed durations, designates the first and last tuplet of any group
    of tuplets as the start or end of the tuplet, respectively.

    >>> n = note.Note()
    >>> n.duration.quarterLength = 1/3
    >>> s = stream.Stream()
    >>> s.insert(0, meter.TimeSignature('2/4'))
    >>> s.repeatAppend(n, 6)
    >>> tupletTypes = [x.duration.tuplets[0].type for x in s.notes]
    >>> tupletTypes
    [None, None, None, None, None, None]
    >>> stream.makeNotation.makeTupletBrackets(s, inPlace=True)
    >>> tupletTypes = [x.duration.tuplets[0].type for x in s.notes]
    >>> tupletTypes
    ['start', None, 'stop', 'start', None, 'stop']

    The tuplets must already be coherent.  See :class:`~music21.duration.TupletFixer`
    for how to get that set up.

    TODO: does not handle nested tuplets

    * Changed in v1.8: `inPlace` is False by default.
    * Changed in v7: Legacy behavior of taking in a list of durations removed.
    makeTupletBracketsNr!   z3got multi-tuplet duration; cannot yet handle this. r   r"   	startStopFr   stopT)r%   r0   r   r2   r/   r   r1   environLocalwarnr;   r   r5   typebrackettotalTupletLengthr?   )r@   r   durationListrA   rI   	tupletMapdur
tupletListcompletionCountcompletionTargettupletPreviousrP   	tupletObj
tupletNexts                 rR   r   r   Y  s   6 -/L **+?@		 $$::AJJ' % GII[[
dC[)_q  Ej^T dC[)jmS12  !$O&*+/N(3Iss9~!!"1q5)!,J J  $_s7H7H%HIO %)9)A%%0IN(-I%&)O%,IN'0'B'B'D$ #:J'J!'	#' "%  +
0F!%	"i  4l &*I" r   c                    | j                  d      | j                  _        fd}| D ]O  }|j                  rj                  t	        |             *t        |d      r	 ||       ?j                  |       Q S )a-  
    Realize all ornaments on a stream

    Creates a new stream that contains all realized ornaments in addition
    to other elements in the original stream.

    >>> s1 = stream.Stream()
    >>> m1 = stream.Measure()
    >>> m1.number = 1
    >>> m1.append(meter.TimeSignature('4/4'))
    >>> n1 = note.Note('C4', type='whole')
    >>> n1.expressions.append(expressions.Mordent())
    >>> m1.append(n1)
    >>> m2 = stream.Measure()
    >>> m2.number = 2
    >>> n2 = note.Note('D4', type='whole')
    >>> m2.append(n2)
    >>> s1.append(m1)
    >>> s1.append(m2)
    >>> for x in s1.recurse(includeSelf=True):
    ...     x
    <music21.stream.Stream ...>
    <music21.stream.Measure 1 offset=0.0>
    <music21.meter.TimeSignature 4/4>
    <music21.note.Note C>
    <music21.stream.Measure 2 offset=4.0>
    <music21.note.Note D>

    >>> s2 = stream.makeNotation.realizeOrnaments(s1)
    >>> for x in s2.recurse(includeSelf=True):
    ...     x
    <music21.stream.Stream ...>
    <music21.stream.Measure 1 offset=0.0>
    <music21.meter.TimeSignature 4/4>
    <music21.note.Note C>
    <music21.note.Note B>
    <music21.note.Note C>
    <music21.stream.Measure 2 offset=4.0>
    <music21.note.Note D>

    TODO: does not work for Gapful streams because it uses append rather
       than the offset of the original
    realizeOrnaments)derivationMethodc                &   d}| j                   D ]i  }t        |d      s|j                  |       \  }}}d}|D ]  }j                  |        |j                  |       |D ]  }j                  |        k |du rj                  |        y y )NFrealizeT)r   hasattrr	  r/   )innerElementelementHasBeenRealizedexpbeforeduringafterrI   	newStreams          rR   realizeElementExpressionsz3realizeOrnaments.<locals>.realizeElementExpressions  s    !&++C3	*$'KK$=!FFE%)"  # !  (  #  , "U*\* +r   r   )
cloneEmptyrN   isStreamr/   r  r
  )r@   r  elementr  s      @rR   r  r    sy    X .@AIxxI+& -g67w.)'2  )  r   c                    ddl m}  |       }t        | j                  |            }|D ]4  }|j	                  | j                  |      |       | j                  |       6 | j	                  d|       y)zH
    Move notes into voices.  Happens inplace always.  Returns None
    r   )r   N)music21.streamr   r(   r)   rp   r   r3   )sourcer   r   r   affectedElementsr   s         rR   r   r   "  se    
 %
'C F55oFG

6''*A.a  MM!Sr   c                z   t        | t        j                        syt               }t        | t        j
                        rt        |       }n| g}|D ]g  }|j                  3|j                  j                  dk(  st        |t        j                        rC|j                  |j                  j                         i |S )a  
    helper method for makeAccidentals to get the tie pitch set (or None)
    from the prior

    >>> n1 = note.Note('C4')
    >>> n2 = note.Note('D4')
    >>> n2.tie = tie.Tie('start')
    >>> n3 = note.Note('E4')
    >>> n3.tie = tie.Tie('stop')
    >>> n4 = note.Note('F4')
    >>> n4.tie = tie.Tie('continue')
    >>> c = chord.Chord([n1, n2, n3, n4])
    >>> tps = stream.makeNotation.getTiePitchSet(c)
    >>> isinstance(tps, set)
    True
    >>> sorted(tps)
    ['D4', 'F4']

    Non tie possessing objects return None

    >>> r = bar.Repeat()
    >>> stream.makeNotation.getTiePitchSet(r) is None
    True

    Note or Chord without ties, returns an empty set:

    >>> n = note.Note('F#5')
    >>> stream.makeNotation.getTiePitchSet(n)
    set()

    >>> pChord = percussion.PercussionChord([note.Unpitched('D4'), note.Note('E5')])
    >>> stream.makeNotation.getTiePitchSet(pChord)
    set()

    Rest returns None

    >>> r = note.Rest()
    >>> stream.makeNotation.getTiePitchSet(r) is None
    True
    Nr   )r&   r   NotRestsetr	   	ChordBaser(   tier   	Unpitchedaddr   nameWithOctave)priortiePitchSetpreviousNotesrI   s       rR   getTiePitchSetr%  3  s    T eT\\*%K%)U55=AEEJJ&0Jq$..4Q../  r   )		pitchPastpitchPastMeasureuseKeySignaturealteredPitchescautionaryPitchClasscautionaryAlloverrideStatuscautionaryNotImmediateRepeatr#  c       	        n   ddl m}
m} d}g }t        |t        j
                        r3|}|j                         j                  D cg c]  }|j                   }}t        | j                  |
            }t        |      D ]g  \  }}|dkD  r|j                  %||dz
     j                  t        ||dz
           z   }nA|r?||dz
     j                  t        ||dz
           z   D cg c]  }|j                  |vr| }}	 ||dz
     t        j                     d   }t!        |      }	|	[|j                  O|j                  j                         j                  D cg c]  }|j                   }}|	D ch c]	  }||v s| }	}|j                  =|j                  }|j                         j                  D cg c]  }|j                   }}|j'                  ||||d||d|||	       j t        | |      rd| j(                  _        yyc c}w c c}w c c}w c c}w # t"        t$        f$ r Y w xY wc c}w )	a:  
    Makes accidentals in place on a stream that contains Measures.
    Helper for Stream.makeNotation and Part.makeAccidentals.

    The function walks measures in order to update the values for the following keyword
    arguments of :meth:`~music21.stream.base.makeAccidentals` and calls
    that method on each Measure. (For this reason, the values supplied
    for these arguments in the method signature will be used on the first
    measure only, or in the case of `useKeySignature`, not at all if the first
    measure contains a `KeySignature`.)::

        pitchPastMeasure
        useKeySignature
        tiePitchSet

    Operates on the measures in place; make a copy first if this is not desired.

    * Changed in v8: the Stream may have other elements besides measures and the method
        will still work.
    r   )r'   r]   FNr!   T)r&  r'  r(  r)  searchKeySignatureByContextr*  r+  r   r,  r-  r#  )r  r'   r]   r&   r   KeySignaturegetScalepitchesnamer(   r)   r;   r~   ornamentalPitchesr   r  r%  
IndexErrorr   makeAccidentalsr?   accidentals)r@   r&  r'  r(  r)  r*  r+  r,  r-  r#  r'   r]   ksLastksLastDiatonicr   measuresOnlyrP   rD   previousNoteOrChordksNewDiatonictps                        rR   makeAccidentalsInMeasureStreamr?  l  s[   B /
 %*F "N/3#3#34 *0//*;*C*CD*CQ!&&*CD"&q';';G'D"EL,'1 q5~~% Q'//2CLQRUVQVDW2XX !  !Q'//2CLQRUVQVDW2XX$5X +,vv^3 %&X ! $5
&21q5&9$,,&G&K#,-@A*q~~/I 67^^5L5L5N5V5V$W5VQVV5VM$W0;"S"r]?R2K"S >>%^^F.4oo.?.G.GH.Gaff.GNH	-")(-!5'))E# 	 	
E (^ !V%)" e E"$5 %X"S0 
 IsI   H	$H>AHH,H2	H<H H6H2
HH/.H/c                .   ddl m} g }| j                  D ]}  }t        ||      r|j	                  t        |             *t        |d      s7|j                  D ]8  }t        |t        j                        s|j	                  |j
                         :  |S )aP  
    Returns all ornamental :class:`~music21.pitch.Pitch` objects found in any
    ornaments in notes/chords in the stream (and substreams) as a Python list.

    Very much like the pitches property, except that instead of returning all
    the pitches found in notes and chords, it returns the ornamental pitches
    found in the ornaments on the notes and chords.

    If you want a list of _all_ the pitches in a stream, including the ornamental
    pitches, you can call s.pitches and makeNotation.ornamentalPitches(s),
    and then combine the two resulting lists into one big list.
    r   )r]   r   )	r  r]   elementsr&   extendr5  r
  r   Ornament)r@   r]   r   r   orns        rR   r5  r5    sw     &DZZa KK)!,-Q&}}c;#7#78KK 5 56 %  Kr   )r&  r'  otherSimultaneousPitchesr)  r*  r+  r,  r-  c          
         | j                   D ]e  }	t        |	t         j                        s|	j                  |        |	j                  s<|	j                  |||||||       |W||	j                  z  }g y)a  
        Makes accidentals for the ornamental pitches for any Ornaments on noteOrChord.
        This is very similar to the processing in pitch.updateAccidentalDisplay, except
        that there is no tie processing, since ornamental pitches cannot be tied.
    )r&  r'  r)  r*  r+  r,  r-  N)r   r&   rC  resolveOrnamentalPitchesr5  updateAccidentalDisplay)
noteOrChordr&  r'  rE  r)  r*  r+  r,  r-  rD  s
             rR   makeOrnamentalAccidentalsrJ    s    " &&#{334$$[1$$##-)!5'))E 	$ 	G  ...I% 'r   c              #  v  K   |r| j                         n| j                         }g }d}|j                  D ]y  }d}|j                  r6|j                  j	                  d      r|j                  j                  d      }|dk(  rd}|r|j                  |       |dk(  r	| g }d}o|rr|ru|g { |r| yyw)a  
    Generator that yields a List of NotRest objects that fall within a beam group.

    If `skipNoBeams` is True, then NotRest objects that have no beams are skipped.

    Recurse is True by default.

    Unclosed beam groups (like start followed by a Rest before a stop), currently
    will continue to yield until the first stop, but this behavior may change at any time in
    the future as beaming-over-barlines with multiple voices or beaming across
    Parts or PartStaffs is supported.

    >>> from music21.stream.makeNotation import iterateBeamGroups
    >>> sc = converter.parse('tinyNotation: 3/4 c8 d e f g4   a4 b8 a16 g16 f4')
    >>> sc.makeBeams(inPlace=True)
    >>> for beamGroup in iterateBeamGroups(sc):
    ...     print(beamGroup)
    [<music21.note.Note C>, <music21.note.Note D>]
    [<music21.note.Note E>, <music21.note.Note F>]
    [<music21.note.Note B>, <music21.note.Note A>, <music21.note.Note G>]

    >>> for beamGroup in iterateBeamGroups(sc, skipNoBeams=False):
    ...     print(beamGroup)
    [<music21.note.Note C>, <music21.note.Note D>]
    [<music21.note.Note E>, <music21.note.Note F>]
    [<music21.note.Note G>]
    [<music21.note.Note A>]
    [<music21.note.Note B>, <music21.note.Note A>, <music21.note.Note G>]
    [<music21.note.Note F>]

    If recurse is False, assumes a flat Score:

    >>> for beamGroup in iterateBeamGroups(sc, recurse=False):
    ...     print(beamGroup)

    >>> for beamGroup in iterateBeamGroups(sc.flatten(), recurse=False):
    ...     print(beamGroup)
    [<music21.note.Note C>, <music21.note.Note D>]
    [<music21.note.Note E>, <music21.note.Note F>]
    [<music21.note.Note B>, <music21.note.Note A>, <music21.note.Note G>]

    * New in v6.7.
    FNr!   r   Tr   )ra   r   notesr<   getByNumbergetTypeByNumberr/   )r@   skipNoBeamsra   iteratorcurrent_beam_groupin_beam_groupelfirst_el_types           rR   iterateBeamGroupsrU  
  s     ` IPUVU[U[U]H-/Mnn"&88,,Q/HH44Q7MG# M%%b)F"$$!#!M]$J      s   B$B9'B9*B9setNewStems overrideConsistentStemDirectionsc               F    t        | dd      D ]  }t        |||        y)a  
    Find all beam groups and set all the `stemDirection` tags for notes/chords
    in a beam group to point either up or down.  If any other stem direction is
    encountered ('double', 'noStem', etc.) that note is skipped.

    If all notes have the same (non-unspecified) direction, then they are left alone unless
    `overrideConsistentStemDirections` is True (default: False).  For instance,
    :meth:`~music21.clef.Clef.getStemDirectionForPitches` might say "down" but
    if everything in the beamGroup is either

    if `setANewStems` is True (as by default), then even notes with stemDirection
    of 'unspecified' get a stemDirection.

    The method currently assumes that the clef does not change within a beam group.  This
    assumption may change in the future without notice.

    Operates in place.  Run `copy.deepcopy(s)` beforehand for a non-inPlace version.

    * New in v6.7.
    T)rO  ra   rV  N)rU  setStemDirectionOneGroup)r@   rW  rX  	beamGroups       rR   r>   r>   Q  s)    6 'qdDI	 #-M	
 Jr   c                  | sy| D ch c]  }|j                   dv r|j                    }}d|v rd}nt        |      dk  rd}nd}| d   j                  t        j                        }|y|}g }| D ]  }|j                  |j                          |sy|j                  |      }	| D ]+  }|j                   }
|
dk(  r|s|
dv r|s|r |
dv s%|	|_         - yc c}w )	z
    Helper function to set stem directions for one beam group (or perhaps a beat, etc.)

    See setStemDirectionForBeamGroups for detailed information.

    * New in v6.7.
    N)updownunspecifiedr_  F   Tr   )r]  r^  )stemDirectionr1   r+   r   rr   rB  r3  getStemDirectionForPitches)grouprW  rX  rI   stem_directionshas_consistent_stem_directionsoptional_clef_contextclef_context	pitchListgroupStemDirectionnoteDirections              rR   rZ  rZ  t  s    05 L1//-JJ O L').&	_		!)-&).& -2!H,F,Ftyy,Q$3L#%I# %@@KM)+~-60;;0AO /Ls   !C)ra   addTiesc                  |r| j                  dd      }n| g}|D ]  }t        |j                        }d}d}|D ]  }|j                  j                  rf|j                  j
                  rP|||j                  j                  d   k(  r2|j                  j                  d   }t        |j                  |z         }nd}d}t        |j                  j                  d   j                         |z
        }	|	dk(  rd}d}|j                  t        j                  d      }
|
r1|
j                  t        |j                  |j                  z         k7  r|
s|
j                  j
                  s2d|	cxk  r|
j                  k  sIn M|
j                  |	|      \  }}|j                  |
j                  |	z   |         y)a  
    Split notes or rests if doing so will complete any incomplete tuplets.
    The element being split must have a duration that exceeds the
    remainder of the incomplete tuplet.

    The first note is edited; the additional notes are inserted in place.
    (Destructive edit, so make a copy first if desired.)
    Relies on :meth:`~music21.stream.base.splitAtQuarterLength`.

    * New in v8.

    >>> from music21.stream.makeNotation import splitElementsToCompleteTuplets
    >>> s = stream.Stream(
    ...    [note.Note(quarterLength=1/3), note.Note(quarterLength=1), note.Note(quarterLength=2/3)]
    ... )
    >>> splitElementsToCompleteTuplets(s)
    >>> [el.quarterLength for el in s.notes]
    [Fraction(1, 3), Fraction(2, 3), Fraction(1, 3), Fraction(2, 3)]
    >>> [el.tie for el in s.notes]
    [None, <music21.tie.Tie start>, <music21.tie.Tie stop>, None]

    With `recurse`:

    >>> m = stream.Measure([note.Note(quarterLength=1/6)])
    >>> m.insert(5/6, note.Note(quarterLength=1/6))
    >>> m.makeRests(inPlace=True, fillGaps=True)
    >>> p = stream.Part([m])
    >>> splitElementsToCompleteTuplets(p, recurse=True)
    >>> [el.quarterLength for el in p.recurse().notesAndRests]
    [Fraction(1, 6), Fraction(1, 3), Fraction(1, 3), Fraction(1, 6)]
    TstreamsOnlyincludeSelfNr"   r   )activeSiteOnly)rk  )ra   r(   r0   r   r   expressionIsInferredr   r5   r   nextr   GeneralNoterN   r   rp   )r@   ra   rk  rP  	containergeneral_noteslast_tupletpartial_tuplet_sumgnql_to_completenext_gnunused_left_edited_in_placerights                rR   splitElementsToCompleteTupletsr}    s   N 9949@3	Y445,0'*B##KK44 (K2;;;N;Nq;Q,Q kk11!4%+B,<,<?Q,Q%R""%("###A&88:=OOQN$"%("ggd..tgDG7>>VBII@P@P4P-QQ7++@@~=(=(===9@9U9U& :V :96/$$W^^n%DeL3  	 r   ra   
onlyIfTiedc                  t        j                  |      }|r| j                  dd      }n| g}|D ]  }|j                          |j                  D ]  }|j                  |       |j                  |      r	 |j                  |       n|j                  r|j                          |j                  |j                  k(  sn|j                         x}rmd|j                  _        |d   }|dd D ]  }	|j!                  |	        |j                   j#                          d|j                   _        |j                  |_        |j                           ! y# t        $ r Y w xY w)	a  
    Locate consecutive notes or rests in `s` (or its substreams if `recurse` is True)
    that are unnecessarily expressed as tuplets and replace them with a single
    element. These groups must:

        - be consecutive (with respect to :class:`~music21.note.GeneralNote` objects)
        - be all rests, or all :class:`~music21.note.NotRest`s with equal `.pitches`
        - all have :attr:`~music21.duration.Duration.expressionIsInferred` = `True`.
        - not begin during a tuplet
        - sum to the tuplet's total length
        - if `NotRest`, all must be tied (if `onlyIfTied` is True)

    The groups are consolidated by prolonging the first note or rest in the group
    and removing the subsequent elements from the stream. (Destructive edit,
    so make a copy first if desired.)

    * New in v8.

    >>> s = stream.Stream()
    >>> r = note.Rest(quarterLength=1/6)
    >>> s.repeatAppend(r, 5)
    >>> s.insert(5/6, note.Note(duration=r.duration))
    >>> from music21.stream.makeNotation import consolidateCompletedTuplets
    >>> consolidateCompletedTuplets(s)
    >>> [el.quarterLength for el in s.notesAndRests]
    [0.5, Fraction(1, 6), Fraction(1, 6), Fraction(1, 6)]

    `onlyIfTied` is `True` by default:

    >>> s2 = stream.Stream()
    >>> n = note.Note(quarterLength=1/3)
    >>> s2.repeatAppend(n, 3)
    >>> consolidateCompletedTuplets(s)
    >>> [el.quarterLength for el in s2.notesAndRests]
    [Fraction(1, 3), Fraction(1, 3), Fraction(1, 3)]

    >>> consolidateCompletedTuplets(s2, onlyIfTied=False)
    >>> [el.quarterLength for el in s2.notesAndRests]
    [1.0]

    Does nothing if tuplet definitions are not the same. (In which case, see
    :class:`~music21.duration.TupletFixer` instead).

    >>> s3 = stream.Stream([note.Rest(quarterLength=1/3), note.Rest(quarterLength=1/6)])
    >>> for my_rest in s3.notesAndRests:
    ...   print(my_rest.duration.tuplets)
    (<music21.duration.Tuplet 3/2/eighth>,)
    (<music21.duration.Tuplet 3/2/16th>,)
    >>> consolidateCompletedTuplets(s)
    >>> [el.quarterLength for el in s3.notesAndRests]
    [Fraction(1, 3), Fraction(1, 6)]

    Does nothing if there are multiple (nested) tuplets.
    )r  Trm  Fr   r!   N )r   TupletSearchStatera   resetr0   advance_tuplet_sumshould_be_testedr/   
ValueErrorto_consolidatemark_no_consolidationrw  completion_targetget_consolidatable_notesr?   r   r3   clearr5   )
r@   ra   r  search_staterP  rt  rx  consolidatableNotesfirst_note_in_group
other_notes
             rR   consolidateCompletedTupletsr    sN   z --DL9949@3	))B++B/,,R0 ''+ ,,224..,2P2PP*6*O*O*QQ&Q5:I**2*=a*@'&9!"&=
!((4 '>'00668;='0088D8V8V'5""$- *  " s   8E	E! E!c              #    K   i }| j                   D ]?  }|j                  #|j                  j                  |t        |      <   2d|t        |      <   A 	 d | j                   D ]  }|j                  +|j	                  t        |      d      |j                  _        :|j	                  t        |      d      du sXt        j                  d      |_        d|j                  _         y# | j                   D ]  }|j                  +|j	                  t        |      d      |j                  _        :|j	                  t        |      d      du sXt        j                  d      |_        d|j                  _         w xY ww)a.  
    Restore accidental displayStatus on a Stream after an (inPlace) operation
    that sets accidental displayStatus (e.g. a transposition).  Note that you
    should not do this unless you know that the displayStatus values will still
    be valid after the operation.

    >>> sc = corpus.parse('bwv66.6')
    >>> intv = interval.Interval('P8')
    >>> classList = (key.KeySignature, note.Note)
    >>> with stream.makeNotation.saveAccidentalDisplayStatus(sc):
    ...     sc.transpose(intv, inPlace=True, classFilterList=classList)

    * New in v9.
    NFTr   )r3  
accidentaldisplayStatusr   getr   
Accidental)r@   displayStatusesr   s      rR   saveAccidentalDisplayStatusr  Q  s4      -/OYY<<#%&\\%?%?OBqE"!&1	 	2A||'-<-@-@A-M*""2a5%0D8$//2-1* A||'-<-@-@A-M*""2a5%0D8$//2-1* s,   AF C* A#F <.F *A$E=.E==F c                  \    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y)Testz>
    Note: most Stream tests are found in stream/tests.py
    zGtinyNotation: 2/2 c8 d e f   trip{a b c' a b c'}  f' e' d' G  a b c' d'c                   ddl m}  |j                         }t        j                         }|j                  |d       | j                  t        |      d       t        |       | j                  t        |      d       | j                  |d   j                  d   d       | j                  t        |d         d       | j                  t        t        |j                  d   j                              d       y )Nr   r      r!   r   z\[<music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>])r$   r   r]   r   NoterepeatAppendassertEqualr1   r   classesstrr(   r.   r0   )selfr   r@   n1s       rR   testNotesToVoiceszTest.testNotesToVoices|  s    "FMMOYY[	r1Q#!Q#1a'2QqTA&T!((1+";";<=K	Lr   c                d    ddl m} |j                   j                        }|j	                  dd       t        |      \  }}}} fd} ||dgdz         t        |d	        ||dgdz         t        |        ||d
gdz         |D ]	  }d|_         t        |        ||dgdz         t        |d        ||d
gdz         t        |        ||dgdz         t        |        ||d
gdz         g d}	t        |      D ]  \  }
}|	|
   |_         t        |        ||g d       y )Nr   	converterTFr   r   c                    j                  t        |       t        |             t        | |      D ]!  \  }}j                  |j                  |       # y r   )r  r1   zipra  )rc  expected	groupNoteexpectedStemDirectionr  s       rR   testDirectionsz9Test.testSetStemDirectionOneGroup.<locals>.testDirections  sJ    SZX747x4H0	0  !8!8:OP 5Ir   r_  r  )rW  r]  r^  )rX     r^  noStemdoubler]  r^  r  r  r^  )	r$   r  parseallaBreveBeamTestr   rU  rZ  ra  r;   )r  r  r   abcrJ   r  rI   dStemsrP   s   `          rR   testSetStemDirectionOneGroupz!Test.testSetStemDirectionOneGroup  s2   %OOD223	DE:&q)
1a	Q
 	q=/A-. 6q=/A-. #q4&1*%A$AO  #q6(Q,' TJq4&1*% #q6(Q,' 	!#q4&1*%3aLDAq$QiAO ! #q>?r   c                   ddl m} |j                  | j                        }|j	                  dd       t        t        |            d   }g d}t        |      D ]  \  }}||   |_         t        |       | j                  |j                         j                  D cg c]  }|j                   c}dgd	z  d
gdz  z   dgd	z  z   g dz          y c c}w )Nr   r  TFr  r/  r  r]  r  r^  r  r  )r$   r  r  r  r   r(   rU  r;   ra  r>   r  rl   rL  )r  r  r   rJ   r  rP   rI   s          rR   !testSetStemDirectionForBeamGroupsz&Test.testSetStemDirectionForBeamGroups  s    %OOD223	DE:"1%&r*3aLDAq$QiAO ! 	&a(199;3D3DE3Da!//3DE!vhl2dVaZ??@	Es   Cc                   ddl m} |j                  d      }|j                  d       | j	                  |j                         j                  D cg c]  }|j                   c}g d       g d}t        |j                         j                  |      D ]  \  }}||_         t        |dd	       | j	                  |j                         j                  D cg c]  }|j                   c}g d
       yc c}w c c}w )z
        Stems that would all be up, starting from scratch,
        but because of overrideConsistentStemDirections=False,
        we only change the first group with an "unspecified" direction
        r   r  ztinyNotation: 2/4 b8 f8 a8 b8Tr   )r]  r]  r]  r]  )r^  r_  r^  r^  FrV  )r]  r]  r^  r^  N)
r$   r  r  r   r  rl   rL  ra  r  r>   )r  r  r   rI   r  stemDirs         rR   testSetStemDirectionConsistencyz$Test.testSetStemDirectionConsistency  s     	&OO;<	D!&'iik&7&78&7Q__&78$	
 9aiik//8JAw%AO 9 	&aT\ab&'iik&7&78&7Q__&78(	
 9 9s   C8C=c                   ddl m} |j                  | j                        }g d}t	        |j                         j                  dd        D ]  \  }}||   |_         |j                  d       | j                  |j                         j                  D cg c]  }|j                   c}dgdz  d	gd
z  z   dgdz  z   g dz          y c c}w )Nr   r  r  Tr   r]  r  r^  r  r  )
r$   r  r  r  r;   rl   rL  ra  r   r  )r  r  r   r  rP   rI   s         rR   testMakeBeamsWithStemDirectionz#Test.testMakeBeamsWithStemDirection  s    %OOD2233aiik//45DAq$QiAO 6	D!199;3D3DE3Da!//3DE!"8a<( 6A:& @@	Es   C
c                d   ddl m} |j                  d      }t        j                  d      }d|_        t        j                  d      }d|_        |j                  d      j                  d|       |j                  d      j                  d|       g |j                         j                  d   _	        g |j                         j                  d   _	        |j                  d       | j                  |j                         j                  D cg c]  }|j                   c}d	d	g       y c c}w )
Nr   r  ztinyNotation: 4/4zd fg      ?r!   Tr   r_  )r$   r  r  r	   Chordr5   rd   rp   rl   rL  makeNotationr  ra  )r  r  r   c1c2rI   s         rR   testMakeBeamsOnEmptyChordzTest.testMakeBeamsOnEmptyChord  s    %OO/0[[[[			!Ar"			!C$%'		!"%'		!"	t$&'iik&7&78&7Q__&78M*	
8s   D-c                   ddl m} ddl m} |j                  d      }||j                     j                         }| j                  |j                         |j                  j                         }| j                  t        |j                  j                        d       |j                         }|j                  j                         }| j                  t        |j                  j                        d       ||j                     j                         }d |_        d}	| j                  |j                   |	      5  |j                  d       d d d        y # 1 sw Y   y xY w)	Nr   r  r   z tinyNotation: 2/4 r2 d8 d8 d8 d8r!   r    T)r   )r$   r  r   r  r'   lastassertIsNoner*   rL  rt   r  r1   r<   rO   r   assertRaisesRegexr   )
r  r  r   r   rD   m_n0m2m2_n0m1msgs
             rR   'testMakeBeamsFromTimeSignatureInContextz,Test.testMakeBeamsFromTimeSignatureInContext  s    %"OO>?fnn""$!//*ww}}TZZ112A6[[] U[[223Q7 v~~$$&J##F$:$:C@LLtL4 A@@s   :EEc                D   ddl m} ddl m} |j                  | j                        }| j                  |j                        5 }|j                  t        j                                d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nr   r  r   )rU   r`   )r$   r  r   r  r  assertRaisesr   rb   r   Durationr  r  	exception)r  r  r   r   cms        rR   testStreamExceptionszTest.testStreamExceptions	  st    %"OOD223v556"NNx'8'8':N; 7R\\*B	D 76s   %BBc                   ddl m}  |j                         } |j                  d      }|j	                  dt        j                  d             |j	                  dt        j                  dd              |j                  d	      }|j	                  dt        j                  d
             |j	                  dt        j                  dd              |j                  d      }|j	                  dt        j                  dd             |j                  |||g       |j                         }| j                  t        ||j                           d       | j                  ||j                     j                         j                  j                         j                  j                   d       | j                  ||j                     d   j                  j                         j                  j                   d       | j                  t        ||j                     d	   j                        d       | j                  ||j                     d	   j                  j                         j                  j                   d       y)z
        From a real-world failure.  Should not be
        making ties in an example that starts with a short TS
        but moves to a longer one and all is valid.
        r   r   r!   r|   z3/4C4g      @)r5   r`  z6/1D4g      8@   E4N)r$   r   Partr'   rp   r   r,   r   r  r/   r   r  r1   rt   rL  r   r5   )r  r   r   r  r  m3pps          rR   "testMakeTiesChangingTimeSignaturesz'Test.testMakeTiesChangingTimeSignatures	  s    	#FKKMV^^1%
		!U((/0
		!TYYt378V^^1%
		!U((/0
		!TYYt489V^^1%
		!TYYt489	"b"ZZ\R/0!4FNN+11399??AJJXXZ]^FNN+A.44::<EESSUYZR/28891=FNN+A.44::<EESSUYZr   c                B   ddl m} ddlm} |j	                  d      }|t
        j                     D ]  }d|j                  _         t        |dd       | j                  |t
        j                     D cg c]  }|j                   c} |dd	      gd
z         y c c}w )Nr   r   r  z/tinyNotation: 2/4 trip{c8 d8 e8} trip{e8 e8 r8}TFr~  r!   r  r  )	fractionsr   r$   r  r  r   rs  r   rq  r  r  r5   )r  r   r  r@   rS  rx  s         rR   .testConsolidateCompletedTupletsNoFalsePositivez3Test.testConsolidateCompletedTupletsNoFalsePositive,	  s    &%OOMND$$%B/3BKK, &#AtF 	()$*:*:(;<(;"R(;<a^q 	
<s   5Bc                   ddl m} ddl m}  |j                  t	        j
                  d      t        j                  d      t        j                  d      g      }d|j                  d   j                  _
        d|j                  d   j                  j                  _        d|j                  d   j                  _
        d	|j                  d   j                  j                  _        t        j                  t        j                  t        j                  f}t        |      5  |j!                  |j#                  d
      d|       | j%                  |j                  d   j&                  d       | j)                  |j                  d   j                  j                  j                         | j%                  |j                  d   j&                  d       | j)                  |j                  d   j                  j                  j                         d d d        | j%                  |j                  d   j&                  d       | j+                  |j                  d   j                  j                  j                  d       | j%                  |j                  d   j&                  d       | j+                  |j                  d   j                  j                  j                  d	       y # 1 sw Y   xY w)Nr   )intervalr   CC2D2Tr!   Fr  )r   r   zD-2zE-2)r$   r  r   r'   r   Keyr   r  rL  r   r  r  r	   r  r1  r  	transposeIntervalr  r!  r  assertIs)r  r  r   rD   	classLists        rR   testSaveAccidentalDisplayStatusz$Test.testSaveAccidentalDisplayStatus;	  s   $"FNNCGGCL$))D/499T?KL&'
#48
##1&'
#49
##1YYS-=-=>	(+KK))$/yKYQWWQZ66>aggaj..99GGHQWWQZ66>aggaj..99GGH , 	22E:aggaj&&11??F22E:aggaj&&11??G ,+s   !C.K$$K-c                  	 ddl mm	 	fd} |       }|j                  d       |j	                         }| j                  |j                         j                  d   j                  	j                  d             | j                  |j                         j                  d   j                  	j                  d	             | j                  |j                         j                  d   j                         |j	                  d       | j                  |j                         j                  d   j                  	j                  d             | j                  |j                         j                  d   j                  	j                  d	              j                         } |       }d
|_         |       }d|_        |j                  d|       |j                  |       |j                  d       |j	                         }| j                  |j                  j                         t         j"                     d   j                  	j                  d             | j                  |j                  j                         t         j"                     d   j                         |j	                  d       | j                  |j                  d   t         j"                     d   j                  	j                  d	             y )Nr   )r   r  c                     j                   d      }  j                  d      } j                  d      }|j                  t	        j
                  d             t        j                  ddd	      }t        j                  d
d      }	j                  d      |_	        |j                  ||g        j                  d      }t        j                  d
d      }	j                  d      |_	        t        j                  dd      }|j                  ||g       |j                  ||g       | j                  d|       | S )N	mainScore)r   part0r!   r  rc   Dhalf)r   dotsr  quarter)r   r   r`  r   r   )Scorer  r'   r/   r   r,   r   r  Tier  rp   )
scp0m01d1r  m02r  c3r   r  s
           rR   getScorez0Test.testMakeNotationRecursive.<locals>.getScoreT	  s    -B(B &..*CJJu**5123V!4B3Y/BWWW%BFJJBx  &..*C3Y/BWWV_BF3V,BJJBx IIsCj!IIaIr   Tr   r!   r   r`  r   score1score2)r$   r   r  	stripTiesr   r  rl   rL  r  r  r   r   rp   r/   r   rt   r   r  )
r  r   r@   ssops1s2oppr   r  s
           @@rR   testMakeNotationRecursivezTest.testMakeNotationRecursiveQ	  s"   '	( J	D!ZZ\++A.22CGGG4DE++A.22CGGFOD!))+++A.223	

4
 **1-1137773CD**1-113776?CV[[]ZZ
		!R
		"
T"kkm))+DII6q9==swww?OP"))//+DII6q9==>
D!1dii0377Ir   N)__name__
__module____qualname____doc__r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r   rR   r  r  v  sS     bL "@H
2
"5(D[0
H,.Jr   r  __main__)
r@   r   r   boolr   r  r   r  r   StreamType | None)r@   r   r   r  )r@   r   r   r   ))rs  )r  r   r   None)r"  z'music21.note.NotRest'r   set[str] | None)r@   zStreamType | StreamIteratorr&  list[pitch.Pitch] | Noner'  r  r(  zbool | key.KeySignaturer)  r  r*  r  r+  r  r,  r  r-  r  r#  r  r   r  )r@   r   r   zlist[pitch.Pitch])rI  znote.Note | chord.Chordr&  r  r'  r  rE  r  r)  r  r*  r  r+  r  r,  r  r-  r  )TT)r@   r   r   z)Generator[list[note.NotRest], None, None])r@   r   r   r  )rc  zlist[note.NotRest]r   r  )r@   stream.Streamra   r  rk  r  r   r  )r@   r  ra   r  r  r  r   r  )r   zt.Generator[None, None, None])>
__future__r   collections.abcr   r   
contextlibrj   typingr   unittestr$   r   r   r   r	   r
   r   r   r   r   r   r   r   music21.common.numberToolsr   music21.common.typesr   r   music21.exceptions21r   TYPE_CHECKINGr  r   r   music21.stream.iteratorr   Environment__file__r   r   rb   r   rs  r   r   r  r   r%  r?  r5  rJ  rU  r>   rZ  r}  r  contextmanagerr  TestCaser  r
  mainTestr  r   rR   <module>r$     s   # /                 - 5 0 ??"6 '{&&x0 ""'rr r 	r
  r rp ]] ]D "RR Rn  %%'{{ {| 27 xvK^ '7;?"7x )-/3-1-1!% )-!%^* ^* &^* -	^*
 +^* +^* ^* ^* ^* #'^* ^* 
^*@8 )-/37;-1!% )-#/&#/ &#/ -	#/
 5#/ +#/ #/ #/ #/ #'#/N D!D! /	D!T %*	 
 

 
 
L %*	0101
 
01l 	IMIM IM 	IM
 
IM^ 	[%[% [% 	[%
 
[%| 2 2HIJ8 IJZ zGT r   