
    rhf                      % S r SSKJr  SSKJr  SSKrSSKrSSKrSSK	J
r
  SSK	Jr  SSK	Jr  SSK	Jr  SS	K	Jr  SS
K	Jr  SSK	Jr  SSK	Jr  SSK	Jr  SSK	Jr  SSK	Jr  \R*                  (       a  SSK	Jr  / rS\S'    " S S\\R4                  5      r " S S\
R8                  5      r " S S\R<                  5      rS7S jr  " S S\
R8                  5      r! " S S\
R8                  5      r" " S S\"5      r# " S  S!\
R8                  5      r$ " S" S#\R<                  5      r% " S$ S%\$5      r& " S& S'\R<                  5      r' " S( S)\
R8                  5      r( " S* S+\(5      r) " S, S-\)5      r*S.S.S/S/S0.           S8S1 jjr+ " S2 S3\RX                  5      r- " S4 S5\RX                  5      r.\\&\!\"/r/\0S6:X  a  SSK	r	\	Rb                  " \-5        gg)9a  
Objects to represent unique elements in a score that contain special analysis routines
to identify certain aspects of music theory. for use especially with theoryAnalyzer, which will
divide a score up into these segments, returning a list of segments to later analyze

The list of objects included here are:

* :class:`~music21.voiceLeading.VoiceLeadingQuartet` : two by two matrix of notes
* :func:`~music21.voiceLeading.iterateAllVoiceLeadingQuartets` : yields each VLQ in a piece.
* :class:`~music21.voiceLeading.Verticality` : vertical context in a score,
    composed of any music21 objects
* :class:`~music21.voiceLeading.VerticalityNTuplet` : group of three
    contiguous verticality objects
* :class:`~music21.voiceLeading.VerticalityTriplet` : three verticality objects --
    has special features
* :class:`~music21.voiceLeading.NObjectLinearSegment` : n (any number) of music21 objects
* :class:`~music21.voiceLeading.NNoteLinearSegment` : n (any number) of notes
* :class:`~music21.voiceLeading.ThreeNoteLinearSegment` : three notes in the same part of a score
* :class:`~music21.voiceLeading.NChordLinearSegment` :
    preliminary implementation of n(any number) chords
* :class:`~music21.voiceLeading.TwoChordLinearSegment` : 2 chord objects
    )annotations)	GeneratorN)base)chord)clef)common)exceptions21)intervalkey)meter)note)pitch)scalestreamzlist[interval.Interval]intervalCachec                  ,    \ rS rSrSrSrSrSrSrSr	Sr
g	)

MotionTypeC   zAnti-ParallelContraryz	No MotionObliqueParallelSimilar N)__name__
__module____qualname____firstlineno__antiParallelcontrarynoMotionobliqueparallelsimilar__static_attributes__r       N/home/james-whalen/.local/lib/python3.13/site-packages/music21/voiceLeading.pyr   r   C   s     "LHHGHGr'   r   c                  @  ^  \ rS rSr% SrSSS.rS\S'        S5         S6U 4S jjjrS	 r\	S
 5       r
\
R                  S 5       r
    S7S jrS8S jrS9S jr\	" \\SS9rS8S jrS9S jr\	" \\SS9rS8S jrS9S jr\	" \\SS9rS8S jrS9S jr\	" \\SS9rS rSS.S jrS:S jrS:S jrS:S  jr  S; S:S! jjrS:S" jrS:S# jr S:S$ jr!S<S:S% jjr"S:S& jr#S:S' jr$S:S( jr%S:S) jr&S:S* jr'S:S+ jr(S:S, jr)S:S- jr*S:S. jr+S:S/ jr,S:S0 jr-S:S1 jr.S:S2 jr/S:S3 jr0S4r1U =r2$ )=VoiceLeadingQuartetM   a  
An object consisting of four pitches: v1n1, v1n2, v2n1, v2n2
where v1n1 moves to v1n2 at the same time as
v2n1 moves to v2n2.
(v1n1: voice 1(top voice), note 1 (left most note) )

Necessary for classifying types of voice-leading motion.

In general, v1 should be the "higher" voice and v2 the "lower" voice
in order for methods such as `.voiceCrossing` and `isProperResolution`
to make sense.  Most routines will work the other way still though.
z
            A two-element list of the two harmonic intervals present,
            vn1n1 to v2n1 and v1n2 to v2n2.
            z}
            A two-element list of the two melodic intervals present,
            v1n1 to v1n2 and v2n1 to v2n2.
            )
vIntervals
hIntervalsdict[str, str]	_DOC_ATTRc                j  > [         TU ]  " S0 UD6  [        (       d{  [        R                  [        R
                  " S5      5        [        R                  [        R
                  " S5      5        [        R                  [        R
                  " S5      5        [        S   U l        [        S   U l        [        S   U l        S U l	        S U l
        S U l        S U l        Xl        X l        X0l        X@l        / U l        / U l        S U l        Ub  XPl        Ub  Ub  Ub  Ub  U R+                  5         g g g g g )NP1P5P8r         r   )super__init__r   appendr
   Intervalunisonfifthoctave_v1n1_v1n2_v2n1_v2n2v1n1v1n2v2n1v2n2r,   r-   _keyr   _findIntervals)selfrA   rB   rC   rD   analyticKeykeywords	__class__s          r(   r7   VoiceLeadingQuartet.__init__f   s    	$8$}   !2!24!89  !2!24!89  !2!24!89#A&"1%
#A&



				3535	""H 0T5E$JZ! K[5E 0r'   c                f   S nS nS nS n U R                   R                  n U R                  R                  n U R                  R                  n U R
                  R                  nSU SU SU SU 3$ ! [         a     N_f = f! [         a     NXf = f! [         a     NQf = f! [         a     NJf = f)Nzv1n1=z, v1n2=z, v2n1=z, v2n2=)rA   nameWithOctaveAttributeErrorrB   rC   rD   )rG   nameV1n1nameV1n2nameV2n1nameV2n2s        r(   _reprInternal!VoiceLeadingQuartet._reprInternal   s    	yy//H	yy//H	yy//H	yy//H xjz
'(TT%  		
  		
  		
  		sE   A3 B B B# 3
B ?B 
BB
B B #
B0/B0c                    U R                   $ )a  
get or set the key of this VoiceLeadingQuartet, for use in theory analysis routines
such as closesIncorrectly. Can be None

>>> vlq = voiceLeading.VoiceLeadingQuartet('D', 'G', 'B', 'G')
>>> vlq.key is None
True
>>> vlq.key = key.Key('G')
>>> vlq.key
<music21.key.Key of G major>

Key can also be given as a string:

>>> vlq.key = 'd'
>>> vlq.key
<music21.key.Key of d minor>

Incorrect keys raise VoiceLeadingQuartetExceptions
)rE   rG   s    r(   r   VoiceLeadingQuartet.key   s    * yyr'   c                `   [        U[        5      (       a,   [        R                  " [        R                  " U5      5      nO' [        U[        R                  5      nUSL a  [        e Xl        g ! [
         a  n[        SU 35      UeS nAff = f! [         a    [        SSU 3-   5      ef = f)Nz2got a key signature string that is not supported: Fz8got a key signature that is not a string or music21 Key zobject: )	
isinstancestrr   Key"convertKeyStringToMusic21KeyString	ExceptionVoiceLeadingQuartetExceptionrN   rE   )rG   keyValueeisKeys       r(   r   rW      s    h$$773#I#I(#ST#Hcgg6E>(( " 	  2H
S " 2N 
+, s#   *A0 %B 0
B:B		BB-c                   Uc  [        XS 5        g [        U[        5      (       a!  [        X[        R                  " U5      5        g  [        U[        R                  5      (       a  [        XU5        g [        U[
        R                  5      (       a9  [        R                  " 5       nSUR                  l        Xl        [        XU5        g g ! [         a  n[        SU< 35      UeS nAff = f)N         not a valid note specification: )setattrrY   rZ   r   Noter   PitchdurationquarterLengthr]   r^   )rG   valuewhichnr`   s        r(   _setVoiceNote!VoiceLeadingQuartet._setVoiceNote   s    
 =D&s##D5!12eTYY//D/u{{33		A/2AJJ,#GD+	 4
  26ui@s   +C 4AC 
C,C''C,c                    U R                   $ N)r=   rV   s    r(   _getV1n1VoiceLeadingQuartet._getV1n1       zzr'   c                (    U R                  US5        g )Nr=   rm   rG   rj   s     r(   _setV1n1VoiceLeadingQuartet._setV1n1       5'*r'   z
        set note1 for voice 1

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v1n1
        <music21.note.Note C>
        docc                    U R                   $ rp   )r>   rV   s    r(   _getV1n2VoiceLeadingQuartet._getV1n2   rs   r'   c                (    U R                  US5        g )Nr>   ru   rv   s     r(   _setV1n2VoiceLeadingQuartet._setV1n2   ry   r'   z
        set note 2 for voice 1

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v1n2
        <music21.note.Note D>
        c                    U R                   $ rp   )r?   rV   s    r(   _getV2n1VoiceLeadingQuartet._getV2n1  rs   r'   c                (    U R                  US5        g )Nr?   ru   rv   s     r(   _setV2n1VoiceLeadingQuartet._setV2n1  ry   r'   z
        set note 1 for voice 2

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v2n1
        <music21.note.Note E>
        c                    U R                   $ rp   )r@   rV   s    r(   _getV2n2VoiceLeadingQuartet._getV2n2  rs   r'   c                (    U R                  US5        g )Nr@   ru   rv   s     r(   _setV2n2VoiceLeadingQuartet._setV2n2  ry   r'   z
        set note 2 for voice 2

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v2n2
        <music21.note.Note F>
        c                   U R                   R                  [        R                  " U R                  U R
                  5      5        U R                   R                  [        R                  " U R                  U R                  5      5        U R                  R                  [        R                  " U R                  U R                  5      5        U R                  R                  [        R                  " U R
                  U R                  5      5        U R                    H
  nSUl	        M     U R                   H
  nSUl	        M     g )Nharmonicmelodic)
r,   r8   r
   r9   rA   rC   rB   rD   r-   intervalType)rG   vIntvhIntvs      r(   rF   "VoiceLeadingQuartet._findIntervals$  s    x00DIIFGx00DIIFGx00DIIFGx00DIIFG__E!+E %__E!*E %r'   F)allowAntiParallelc                  SnU R                  5       (       a  [        R                  nU$ U R                  5       (       a  [        R                  nU$ U R                  5       (       a  [        R                  nU$ U(       a'  U R                  5       (       a  [        R                  nU$ U R                  5       (       a  [        R                  nU$ U R                  5       (       a  [        R                  nU$ )an  
returns the type of motion from the MotionType Enum object
that exists in this voice leading quartet

>>> for mt in voiceLeading.MotionType:
...     print(repr(mt))
<MotionType.antiParallel: 'Anti-Parallel'>
<MotionType.contrary: 'Contrary'>
<MotionType.noMotion: 'No Motion'>
<MotionType.oblique: 'Oblique'>
<MotionType.parallel: 'Parallel'>
<MotionType.similar: 'Similar'>

>>> n1_d4 = note.Note('D4')
>>> n2_e4 = note.Note('E4')
>>> m1_f4 = note.Note('F4')
>>> m2_b4 = note.Note('B4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_d4, n2_e4, m1_f4, m2_b4)
>>> vl.motionType()
<MotionType.similar: 'Similar'>

>>> n1_a4 = note.Note('A4')
>>> n2_c5 = note.Note('C5')
>>> m1_d4 = note.Note('D4')
>>> m2_f4 = note.Note('F4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_a4, n2_c5, m1_d4, m2_f4)
>>> vl.motionType()
<MotionType.parallel: 'Parallel'>
>>> print(vl.motionType())
MotionType.parallel
>>> vl.motionType() == 'Parallel'
True

Demonstrations of other motion types.

Contrary:

>>> n1_d5 = note.Note('D5')   # D5, C5 against D4, F4
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_d5, n2_c5, m1_d4, m2_f4)
>>> vl.motionType()
<MotionType.contrary: 'Contrary'>

Oblique:

>>> n1_c5 = note.Note('C5')   # C5, C5 against D4, F4
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_c5, n2_c5, m1_d4, m2_f4)
>>> vl.motionType()
<MotionType.oblique: 'Oblique'>

No motion (if I had a dollar for every time I forgot to teach
that this is not a form of oblique motion):

>>> m1_f4 = note.Note('F4')   # C5, C5 against F4, F4
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_c5, n2_c5, m1_f4, m2_f4)
>>> vl.motionType()
<MotionType.noMotion: 'No Motion'>


Anti-parallel motion has to be explicitly enabled to appear:

>>> n1_a5 = note.Note('A5')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1_a5, n2_c5, m1_d4, m2_f4)
>>> vl.motionType()  # anti-parallel fifths
<MotionType.contrary: 'Contrary'>
>>> vl.motionType(allowAntiParallel=True)
<MotionType.antiParallel: 'Anti-Parallel'>

* Changed in v6: anti-parallel motion was supposed to be
  able to be returned in previous versions, but a bug prevented it.
  To preserve backwards compatibility, it must be explicitly enabled.
 )obliqueMotionr   r#   parallelMotionr$   similarMotionr%   antiParallelMotionr    contraryMotionr!   r"   )rG   r   
motionTypes      r(   r   VoiceLeadingQuartet.motionType.  s    P 
#++J    ""#,,J  !!#++J  4#:#:#<#<#00J    ""#,,J  ]]__#,,Jr'   c                N    U R                    H  nUR                  S:w  d  M    g   g)aY  
Returns True if no voice moves in this "voice-leading" moment

>>> n1 = note.Note('G4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('D4')
>>> m2 = note.Note('D4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.noMotion()
True
>>> n2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.noMotion()
False
r1   FT)r-   name)rG   iVs     r(   r"   VoiceLeadingQuartet.noMotion  s%      //Bww$ " r'   c                    U R                  5       (       a  gU R                  S   R                  U R                  S   R                  /nSU;  a  gg)a  
Returns True if one voice remains the same and another moves.  i.e.,
noMotion must be False if obliqueMotion is True.

>>> n1 = note.Note('G4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('D4')
>>> m2 = note.Note('D4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.obliqueMotion()
False
>>> n2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.obliqueMotion()
True
>>> m2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.obliqueMotion()
False
Fr   r4   r1   T)r"   r-   r   )rG   iNamess     r(   r   !VoiceLeadingQuartet.obliqueMotion  sH    * ==??ooa(--tq/A/F/FGF6!r'   c                    U R                  5       (       a  gU R                  S   R                  U R                  S   R                  :X  a  gg)a  
Returns True if the two voices both move in the same direction.
Parallel Motion will also return true, as it is a special case of
similar motion. If there is no motion, returns False.

>>> n1 = note.Note('G4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('G4')
>>> m2 = note.Note('G4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.similarMotion()
False
>>> n2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.similarMotion()
False
>>> m2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.similarMotion()
True
>>> m2 = note.Note('A5')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.similarMotion()
True
Fr   r4   T)r"   r-   	directionrV   s    r(   r   !VoiceLeadingQuartet.similarMotion  s>    4 ==??q!++tq/A/K/KKr'   c                   U R                   S   nUR                  nU R                   S   nUR                  n[        R                  (       a
  Uc   eUc   eU R	                  5       (       d  gUR
                  UR
                  :w  a  U(       d  gUR                  UR                  :w  a  gUc  gSn[        U[        R                  5      (       a  UR                  UR                  :H  n[        U[        5      (       a/  [        R                  " U5      nUR                  UR                  :H  n[        U[        5      (       aQ  [        R                  " U5      nUR                  UR                  :H  =(       a    UR                  UR                  :H  nU$ [        U[        R                  [        R                  45      (       a9  UR                  UR                  :H  =(       a    UR                  UR                  :H  nU$ )a  
Returns True if both the first and second intervals are the same sized
generic interval.

If requiredInterval is set, returns True only if both intervals are that
generic or specific interval.

allowOctaveDisplacement treats motion as parallel even if any of the intervals
are displaced by octaves, except in the case of unisons and octaves, which
are always treated as distinct.

We will make the examples shorter with this abbreviation:
>>> N = note.Note

>>> vl = voiceLeading.VoiceLeadingQuartet(N('G4'), N('G4'), N('G3'), N('G3'))
>>> vl.parallelMotion()  # not even similar motion
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('G4'), N('B4'), N('G3'), N('A3'))
>>> vl.parallelMotion()  # similar motion, but no kind of parallel
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('G4'), N('G5'), N('G4'), N('G5'))
>>> vl.parallelMotion()  # parallel unisons
True

>>> vl.parallelMotion('P1')
True

octaves never equivalent to unisons

>>> vl.parallelMotion('P8', allowOctaveDisplacement=True)
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('B4'), N('D3'), N('E3'))
>>> vl.parallelMotion()  # parallel fifths
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('B5'), N('D3'), N('E3'))
>>> vl.parallelMotion()  # 5th to a 12th
False
>>> vl.parallelMotion(allowOctaveDisplacement=True)
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('Bb4'), N('F4'), N('G4'))
>>> vl.parallelMotion(3)  # parallel thirds ...
True
>>> vl.parallelMotion('M3')  # ... but not parallel MAJOR thirds
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('D4'), N('E4'), N('F3'), N('G3'))
>>> gi = interval.GenericInterval(6)
>>> vl.parallelMotion(gi)  # these are parallel sixths ...
True

These are also parallel major sixths

>>> i = interval.Interval('M6')
>>> di = interval.DiatonicInterval('major', 6)
>>> vl.parallelMotion(i) and vl.parallelMotion(di)
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('D5'), N('E6'), N('F3'), N('G3'))
>>> vl.parallelMotion(gi)  # octave displacement
False
>>> vl.parallelMotion(gi, allowOctaveDisplacement=True)
True
r   r4   FT)r,   generictTYPE_CHECKINGr   directedsemiSimpleUndirectedrY   r
   GenericIntervalintrZ   r9   semiSimpleNameDiatonicInterval)rG   requiredIntervalallowOctaveDisplacementvInt0vInt0_genericvInt1vInt1_genericintervalsAreValids           r(   r   "VoiceLeadingQuartet.parallelMotion  s   R ""?? ,,, ,,,!!##$$(>(>>-00 556% !&*H,D,DEE%2%G%G(8(M(M&N! *C00#+#;#;<L#M %2%G%G(8(M(M&N! *C00#+#4#45E#F %*%9%9+;+J+J&K &K).)=)=+;+J+J*K " %$ ,x/@/@(B[B[.\]]%*%9%9+;+J+J&K &K).)=)=+;+J+J*K "
 %$r'   c                    U R                  5       (       a  gU R                  5       (       a  gU R                  S   R                  U R                  S   R                  :X  a  gg)a:  
Returns True if both voices move in opposite directions

>>> n1 = note.Note('G4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('G4')
>>> m2 = note.Note('G4')

No motion, so False:

>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.contraryMotion()
False

Oblique motion, so False:

>>> n2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.contraryMotion()
False

Parallel motion, so False

>>> m2.octave = 5
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.contraryMotion()
False

Similar motion, so False

>>> m2 = note.Note('A5')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.contraryMotion()
False

Finally, contrary motion, so True!

>>> m2 = note.Note('C4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.contraryMotion()
True
Fr   r4   T)r"   r   r-   r   rV   s    r(   r   "VoiceLeadingQuartet.contraryMotionY  sQ    X ==??!!q!++tq/A/K/KKr'   c                    U R                  5       =(       a4    U R                  S   R                  [        R                  R
                  :H  $ )a$  
Returns True if both voices move outward by contrary motion

>>> n1 = note.Note('D5')
>>> n2 = note.Note('E5')
>>> m1 = note.Note('G4')
>>> m2 = note.Note('F4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.outwardContraryMotion()
True
>>> vl.inwardContraryMotion()
False
r   )r   r-   r   r
   	Direction	ASCENDINGrV   s    r(   outwardContraryMotion)VoiceLeadingQuartet.outwardContraryMotion  s?     ##% QOOA&00H4F4F4P4PP	Rr'   c                    U R                  5       =(       a4    U R                  S   R                  [        R                  R
                  :H  $ )a#  
Returns True if both voices move inward by contrary motion

>>> n1 = note.Note('C5')
>>> n2 = note.Note('B4')
>>> m1 = note.Note('G4')
>>> m2 = note.Note('A4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.inwardContraryMotion()
True
>>> vl.outwardContraryMotion()
False
r   )r   r-   r   r
   r   
DESCENDINGrV   s    r(   inwardContraryMotion(VoiceLeadingQuartet.inwardContraryMotion  s?     ##% ROOA&00H4F4F4Q4QQ	Sr'   c                Z   U R                  5       (       d  gU R                  S   R                  U R                  S   R                  :X  aa  Uc  g[        U[        5      (       a  U R                  S   R                  U:X  a  ggU R                  S   R                  UR                  :X  a  ggg)a  
Returns True if the simple interval before is the same as the simple
interval after and the motion is contrary. if simpleName is
specified as an Interval object or a string then it only returns
true if the simpleName of both intervals is the same as simpleName
(i.e., use to find antiParallel fifths)

>>> n11 = note.Note('C4')
>>> n12 = note.Note('D3')  # descending 7th
>>> n21 = note.Note('G4')
>>> n22 = note.Note('A4')  # ascending 2nd
>>> vlq1 = voiceLeading.VoiceLeadingQuartet(n11, n12, n21, n22)
>>> vlq1.antiParallelMotion()
True

>>> vlq1.antiParallelMotion('M2')
False

>>> vlq1.antiParallelMotion('P5')
True

We can also use interval objects

>>> p5Obj = interval.Interval('P5')
>>> p8Obj = interval.Interval('P8')
>>> vlq1.antiParallelMotion(p5Obj)
True

>>> p8Obj = interval.Interval('P8')
>>> vlq1.antiParallelMotion(p8Obj)
False

>>> n1 = note.Note('G4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('G4')
>>> m2 = note.Note('G3')
>>> vl2 = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl2.antiParallelMotion()
False
Fr   r4   T)r   r,   
simpleNamerY   rZ   )rG   r   s     r(   r   &VoiceLeadingQuartet.antiParallelMotion  s    R ""$$q!,,0B0M0MM%!*c22??1-88JF#'#(??1-88J<Q<QQ#'#(r'   c                R    U R                  USS9=(       d    U R                  U5      $ )ab  
Returns True if there is a parallel motion or antiParallel motion of
this type (thisInterval should be an Interval object)

>>> n11 = note.Note('G4')
>>> n12a = note.Note('A4')  # ascending 2nd

>>> n21 = note.Note('C4')
>>> n22a = note.Note('D4')  # ascending 2nd

>>> vlq1 = voiceLeading.VoiceLeadingQuartet(n11, n12a, n21, n22a)
>>> vlq1.parallelInterval(interval.Interval('P5'))
True

>>> vlq1.parallelInterval(interval.Interval('P8'))
False

Antiparallel fifths also are True

>>> n22b = note.Note('D3')  # descending 7th
>>> vlq2 = voiceLeading.VoiceLeadingQuartet(n11, n12a, n21, n22b)
>>> vlq2.parallelInterval(interval.Interval('P5'))
True

But Antiparallel other interval are not:

>>> N = note.Note
>>> vlq2a = voiceLeading.VoiceLeadingQuartet(N('C5'), N('C6'), N('C4'), N('C3'))
>>> vlq2a.parallelInterval(interval.Interval('P5'))
False
>>> vlq2a.parallelInterval(interval.Interval('P8'))
True


Non-parallel intervals are, of course, False

>>> n12b = note.Note('B4')  # ascending 3rd
>>> vlq3 = voiceLeading.VoiceLeadingQuartet(n11, n12b, n21, n22b)
>>> vlq3.parallelInterval(interval.Interval('P5'))
False
T)r   r   )r   r   rG   thisIntervals     r(   parallelInterval$VoiceLeadingQuartet.parallelInterval  s8    X !-(,    5 &&|4	
r'   c                8    U R                  U R                  5      $ )a  
Returns True if the motion is a parallel or antiparallel Perfect Fifth,
allowing displacement by an octave (e.g., 5th to a 12th).

We will make the examples shorter with this abbreviation:

>>> N = note.Note

Parallel fifths

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('G4'), N('A4'), N('C4'), N('D4'))
>>> vlq.parallelFifth()
True

5th -> 12th in similar motion

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('G4'), N('A5'), N('C4'), N('D4'))
>>> vlq.parallelFifth()
True

5th -> 12th in antiparallel motion

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('G4'), N('A4'), N('C4'), N('D3'))
>>> vlq.parallelFifth()
True

Note that diminished fifth moving to perfect fifth is not a parallelFifth

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('G4'), N('A4'), N('C#4'), N('D4'))
>>> vlq.parallelFifth()
False

Nor is P5 moving to d5.

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('G4'), N('Ab4'), N('C4'), N('D4'))
>>> vlq.parallelFifth()
False
)r   r;   rV   s    r(   parallelFifth!VoiceLeadingQuartet.parallelFifth"  s    N $$TZZ00r'   c                8    U R                  U R                  5      $ )aI  
Returns True if the motion is a parallel Perfect Octave.

(This is a concept so abhorrent we shudder to illustrate it
with an example, but alas, we must:)

We will make the examples shorter with this abbreviation:

>>> N = note.Note

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('C5'), N('D5'), N('C4'), N('D4'))
>>> vlq.parallelOctave()
True

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('C6'), N('D6'), N('C4'), N('D4'))
>>> vlq.parallelOctave()
True

Or False if the motion is according to the rules of God's own creation :-)

>>> vlq = voiceLeading.VoiceLeadingQuartet(N('C4'), N('D4'), N('C4'), N('D4'))
>>> vlq.parallelOctave()
False

(P.S., we were joking about parallel octaves being abhorant or out of God's creation!
music21 works just as well with popular music and other styles that do not
have problems with parallel octaves.)
)r   r<   rV   s    r(   parallelOctave"VoiceLeadingQuartet.parallelOctaveK  s    : $$T[[11r'   c                8    U R                  U R                  5      $ )a  
Returns True if the motion is a parallel Perfect Unison (and not
Perfect Octave, etc.)

We will make the examples shorter with this abbreviation:

>>> N = note.Note
>>> vlq = voiceLeading.VoiceLeadingQuartet(N('C4'), N('D4'), N('C4'), N('D4'))
>>> vlq.parallelUnison()
True

>>> vlq  = voiceLeading.VoiceLeadingQuartet(N('C5'), N('D5'), N('C4'), N('D4'))
>>> vlq.parallelUnison()
False
)r   r:   rV   s    r(   parallelUnison"VoiceLeadingQuartet.parallelUnisonj  s      $$T[[11r'   c                P    U R                  5       =(       d    U R                  5       $ )a  
Returns True if the VoiceLeadingQuartet has motion by parallel
octave or parallel unison

>>> voiceLeading.VoiceLeadingQuartet(
...     note.Note('C4'),
...     note.Note('D4'),
...     note.Note('C3'),
...     note.Note('D3')
...     ).parallelUnisonOrOctave()
True

>>> voiceLeading.VoiceLeadingQuartet(
...     note.Note('C4'),
...     note.Note('D4'),
...     note.Note('C4'),
...     note.Note('D4')
...     ).parallelUnisonOrOctave()
True
)r   r   rV   s    r(   parallelUnisonOrOctave*VoiceLeadingQuartet.parallelUnisonOrOctave|  s!    , ""$=(;(;(==r'   c                    U R                  SS9(       a  gU R                  5       (       d  g[        U[        5      (       a  [        R
                  " U5      nU R                  S   R                  UR                  :X  a  gg)as  
Returns True if there is a hidden interval that matches
thisInterval.

N.B. -- this method finds ALL hidden intervals,
not just those that are forbidden under traditional
common practice counterpoint rules. Takes thisInterval,
an Interval object.

>>> n1 = note.Note('C4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('B4')
>>> m2 = note.Note('D5')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.hiddenInterval(interval.Interval('P5'))
True

>>> n1 = note.Note('E4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('B4')
>>> m2 = note.Note('D5')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.hiddenInterval(interval.Interval('P5'))
False

>>> n1 = note.Note('E4')
>>> n2 = note.Note('G4')
>>> m1 = note.Note('B4')
>>> m2 = note.Note('D6')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.hiddenInterval(interval.Interval('P5'))
False
T)r   Fr4   )r   r   rY   rZ   r
   r9   r,   r   r   s     r(   hiddenInterval"VoiceLeadingQuartet.hiddenInterval  sk    D t<##%%,,,'00>q!,,0G0GGr'   c                8    U R                  U R                  5      $ )z[
Calls :meth:`~music21.voiceLeading.VoiceLeadingQuartet.hiddenInterval`
by passing a fifth
)r   r;   rV   s    r(   hiddenFifthVoiceLeadingQuartet.hiddenFifth  s    
 ""4::..r'   c                8    U R                  U R                  5      $ )z+
Calls hiddenInterval by passing an octave
)r   r<   rV   s    r(   hiddenOctave VoiceLeadingQuartet.hiddenOctave  s     ""4;;//r'   c                    U R                   R                  U R                  R                  :  d.  U R                  R                  U R                  R                  :  a  gg)a  
Returns True if the second note in V1 is lower than the first in V2, or
if the second note in V2 is higher than the first note in V1.

We will make the examples shorter with this abbreviation:
>>> N = note.Note

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('B4'), N('F4'), N('G4'))
>>> vl.voiceOverlap()  # no overlap
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('B4'), N('F4'), N('A4'))
>>> vl.voiceOverlap()  # Motion to the SAME note is not considered overlap
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('C4'), N('F4'), N('Bb4'))
>>> vl.voiceOverlap()  # V2 overlaps V1
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('E4'), N('F4'), N('D4'))
>>> vl.voiceOverlap()  # V1 overlaps V2
True
TF)rB   r   rC   rD   rA   rV   s    r(   voiceOverlap VoiceLeadingQuartet.voiceOverlap  9    0 99??TYY__,		$))//0Qr'   c                    U R                   R                  U R                  R                  :  d.  U R                  R                  U R                  R                  :  a  gg)a  
Returns True if either note in V1 is lower than the simultaneous note in V2.

We will make the examples shorter with this abbreviation:

>>> N = note.Note

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('A4'), N('G4'), N('G4'))
>>> vl.voiceCrossing()  # nothing crossed
False

>>> vl = voiceLeading.VoiceLeadingQuartet(N('A4'), N('F4'), N('G4'), N('G4'))
>>> vl.voiceCrossing()  # second interval is crossed
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('F4'), N('A4'), N('G4'), N('G4'))
>>> vl.voiceCrossing()  # first interval crossed
True

>>> vl = voiceLeading.VoiceLeadingQuartet(N('F4'), N('F4'), N('G4'), N('G4'))
>>> vl.voiceCrossing()  # both crossed
True
TF)rA   r   rC   rB   rD   rV   s    r(   voiceCrossing!VoiceLeadingQuartet.voiceCrossing  r   r'   c                V   U R                  5       (       a  gU R                  (       a  U R                  R                  U R                  R                  5      nUR	                  U R
                  5      nUR	                  U R                  5      nU R                  R                  S:X  a_  Uc\  [        R                  " U R                  R                  5      nUR	                  U R
                  [        R                  R                  S9nOSnSnSnU R                  S   R                  nU R                  S   R                  n[        R                   (       a  Uc   eUR"                  nUS:X  a  U R$                  U R&                  :  a  ggUS	:X  a8  U(       a  US
:w  a  gU(       a  US:w  a  gU R)                  5       =(       a    US:H  $ US:X  a8  U(       a  US:w  a  gU(       a  US:w  a  gU R+                  5       =(       a    US:H  $ US:X  a!  U(       a  US:w  a  gU(       a  US:w  a  gUS:H  $ g)a  
Checks whether the voice-leading quartet resolves correctly according to standard
counterpoint rules. If the first harmony is dissonant (P4, d5, A4, or m7) it checks
that these are correctly resolved. If the first harmony is consonant, True is returned.

The key parameter should be specified to check for motion in the bass from specific
note degrees. If it is not set, then no checking for scale degrees takes place.

Currently implements the following resolutions:

    P4:     Top voice must resolve downward.

    A4:     out by contrary motion to a sixth, with chordal seventh resolving
            down to a third in the bass.

    d5:     in by contrary motion to a third, with 7 resolving up to 1 in the bass

    m7:     Resolves to a third with a leap from 5 to 1 in the bass


We will make the examples shorter with this abbreviation:
>>> N = note.Note

>>> n1 = note.Note('B-4')
>>> n2 = note.Note('A4')
>>> m1 = note.Note('E4')
>>> m2 = note.Note('F4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # d5 resolves inward
True
>>> m2.pitch.name = 'D'
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # d5 resolves outward
False
>>> vl.key = 'B-'
>>> vl.isProperResolution()  # not on scale degrees that need resolution
True

>>> n1 = note.Note('D4')
>>> n2 = note.Note('C4')
>>> m1 = note.Note('G#3')
>>> m2 = note.Note('A3')
>>> k = key.Key('a')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2, k)
>>> vl.isProperResolution()  # d5 with #7 in minor handled correctly
True

>>> n1 = note.Note('E5')
>>> n2 = note.Note('F5')
>>> m1 = note.Note('B-4')
>>> m2 = note.Note('A4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # A4 resolves outward
True
>>> m2.pitch.nameWithOctave = 'D5'
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # A4 resolves inward
False
>>> vl.key = 'B-'
>>> vl.isProperResolution()  # A4 not on scale degrees that need resolution
True
>>> vl.key = 'F'
>>> vl.isProperResolution()  # A4 on scale degrees that need resolution
False

>>> n1 = note.Note('B-4')
>>> n2 = note.Note('A4')
>>> m1 = note.Note('C4')
>>> m2 = note.Note('F4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # m7
True
>>> m2.pitch.nameWithOctave = 'F3'
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # m7 with similar motion
True
>>> vl.key = 'B-'
>>> vl.isProperResolution()  # m7 not on scale degrees that need resolution
True
>>> vl.key = 'F'
>>> vl.isProperResolution()  # m7 on scale degrees that need resolution
True

P4 on the initial harmony must move down.

>>> n1 = note.Note('F5')
>>> n2 = note.Note('G5')
>>> m1 = note.Note('C4')
>>> m2 = note.Note('C4')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # P4 must move down or remain static
False
>>> n2.step = 'E'
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.isProperResolution()  # P4 can move down by step or leap
True

>>> vl = voiceLeading.VoiceLeadingQuartet('B-4', 'A4', 'C2', 'F2')
>>> vl.key = key.Key('F')
>>> vl.isProperResolution()  # not dissonant, True returned
True
TminorN)r   r   r4   P4FA4         d5   m7   )r"   r   getScalemodegetScaleDegreeFromPitchrC   rD   r   MelodicMinorScaletonicr   r   r,   r   r   r   r   simpleUndirectedrA   rB   r   r   )rG   keyScalen1degreen2degree
minorScalefirstHarmonysecondGenericsecondHarmonys           r(   isProperResolution&VoiceLeadingQuartet.isProperResolution
  s   N ==??88xx((7H77		BH77		BH xx}}'H,<"44TXX^^D
%==II#oo77 > 9
 HHHq)44*22?? ,,,%664yyDII%T!HMHM..0 /)Q.0 T!HMHM--/ /)Q.0 T!HMHM A%% r'   c                   U R                  5       (       a  gU R                  S   R                  nU R                  S   R                  n[        R                  (       a
  Uc   eUc   eUR
                  S:X  a&  UR
                  S:X  a  U R                  5       (       a  gUR                  (       a$  UR                  =(       d    UR                  (       + $ UR                  (       a$  UR                  =(       d    UR                  (       + $ g)a  
Returns True if there is a leap or skip in once voice then the other voice must
be a step or unison.
if neither part skips then False is returned. Returns False if the two voices
skip thirds in contrary motion.

>>> n1 = note.Note('G4')
>>> n2 = note.Note('C5')
>>> m1 = note.Note('B3')
>>> m2 = note.Note('A3')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.leapNotSetWithStep()
False

>>> n1 = note.Note('G4')
>>> n2 = note.Note('C5')
>>> m1 = note.Note('B3')
>>> m2 = note.Note('F3')
>>> vl = voiceLeading.VoiceLeadingQuartet(n1, n2, m1, m2)
>>> vl.leapNotSetWithStep()
True

>>> vl = voiceLeading.VoiceLeadingQuartet('E', 'G', 'G', 'E')
>>> vl.leapNotSetWithStep()
False
Fr   r4   r   )
r"   r-   r   r   r   
undirectedr   isSkipisDiatonicStepisUnison)rG   hInt0_generichInt1_generics      r(   leapNotSetWithStep&VoiceLeadingQuartet.leapNotSetWithStep  s    6 ==??*22*22?? ,,, ,,,$$)!,,1''))%44 2(113 3!!%44 2(113 3 r'   c                   SSK Jn  U R                  S   nU R                  S   nUR                  nUR                  nUR                  nUR                  n[
        R                  (       a  Ub  Uc   eUb  Uc   e[        R                  " XE/5      n[        R                  " Xg/5      n	UR                  XR                  5      n
UR                  XR                  5      n/ SQnUR                  U;   =(       d    UR                  U;   =(       aC    U
SLa  U
S   R                  5       U;   (       + $ USLa   US   R                  5       U;   (       + $ S(       + $ )a  
TODO(msc): will be renamed to be less dogmatic

Returns True if the VLQ would be an incorrect opening in
the style of 16th century Counterpoint (not Bach Chorale style)

Returns True if the opening or second harmonic interval is PU, P8, or P5,
to accommodate an anacrusis.
also checks to see if opening establishes tonic or dominant harmony (uses
:meth:`~music21.roman.identifyAsTonicOrDominant`

>>> vl = voiceLeading.VoiceLeadingQuartet('D', 'D', 'D', 'F#')
>>> vl.key = 'D'
>>> vl.opensIncorrectly()
False
>>> vl = voiceLeading.VoiceLeadingQuartet('B', 'A', 'G#', 'A')
>>> vl.key = 'A'
>>> vl.opensIncorrectly()
False
>>> vl = voiceLeading.VoiceLeadingQuartet('A', 'A', 'F#', 'D')
>>> vl.key = 'A'
>>> vl.opensIncorrectly()
False

>>> vl = voiceLeading.VoiceLeadingQuartet('C#', 'C#', 'D', 'E')
>>> vl.key = 'A'
>>> vl.opensIncorrectly()
True

>>> vl = voiceLeading.VoiceLeadingQuartet('B', 'B', 'A', 'A')
>>> vl.key = 'C'
>>> vl.opensIncorrectly()
True
r   )romanr4   )r1   r2   IVF)music21r  r,   	noteStartnoteEndr   r   r   ChordidentifyAsTonicOrDominantr   r   upper)rG   r  v0v1v0nsv0nev1nsv1nec1c2r1r2openingss                r(   opensIncorrectly$VoiceLeadingQuartet.opensIncorrectly  sE   F 	"__Q__Q||zz||zz??#(888#(888[[$&[[$&,,R:,,R:)]]h. 5==H4W8:%2a5;;=H4X 	X <>U?N8 ekkmx7X 	X QVX 	Xr'   c                   SnU R                   R                  S:X  a  U R                   R                  S5      R                  S5      R                  U R
                  R                  :X  a)  U R                   R                  U R                  5      S:H  nOwU R                   R                  S5      R                  S5      R                  U R                  R                  :X  a(  U R                   R                  U R                  5      S:H  nOSnSnU R                  R                  R                  U R                  R                  /nU R                  S   R                  nU R                  S   R                  n[        R                  (       a
  Uc   eUc   eUR                  U;   =(       a^    UR                  S:H  =(       aH    U=(       a?    U R                   R                  S5      R                  U;   =(       a    U R!                  5       (       + $ )	ae  
TODO(msc): will be renamed to be less dogmatic

Returns True if the VLQ would be an incorrect closing in
the style of 16th century Counterpoint (not Bach Chorale style)

Returns True if closing harmonic interval is a P8 or PU and the interval
approaching the close is
6 - 8, 10 - 8, or 3 - U. Must be in contrary motion, and if in minor key,
has a leading tone resolves to the tonic.

>>> vl = voiceLeading.VoiceLeadingQuartet('C#', 'D', 'E', 'D')
>>> vl.key = key.Key('d')
>>> vl.closesIncorrectly()
False
>>> vl = voiceLeading.VoiceLeadingQuartet('B3', 'C4', 'G3', 'C2')
>>> vl.key = key.Key('C')
>>> vl.closesIncorrectly()
False
>>> vl = voiceLeading.VoiceLeadingQuartet('F', 'G', 'D', 'G')
>>> vl.key = key.Key('g')
>>> vl.closesIncorrectly()
True
>>> vl = voiceLeading.VoiceLeadingQuartet('C#4', 'D4', 'A2', 'D3', analyticKey='D')
>>> vl.closesIncorrectly()
True
Fr   r   A1r4   T)r   r   r   )r   r   pitchFromDegree	transposer   rA   r   rB   rC   r   rD   r,   r   r   r   r   r   )rG   raisedMinorCorrectlypreClosingsclosingPitchesr   r   s         r(   closesIncorrectly%VoiceLeadingQuartet.closesIncorrectly  s   8  %88==G#xx''*44T:??499>>Q'+xx'G'G		'RVW'W$))!,66t<AATYY^^S'+xx'G'G		'RVW'W$#' ))//..		?*22*22?? ,,, ,,,!22kA /&771</-/ 11!499^K/ ,,.	0 	0r'   )rE   r=   r>   r?   r@   r;   r-   r   r<   r:   rA   rB   rC   rD   r,   )NNNNN)
rA   $None | str | note.Note | pitch.PitchrB   r-  rC   r-  rD   r-  rH   zkey.Key | None)rj   r-  rk   z-t.Literal['_v1n1', '_v1n2', '_v2n1', '_v2n2'])returnzNone | note.Note)rj   r-  r.  bool)NFrp   )3r   r   r   r   __doc__r/   __annotations__r7   rS   propertyr   setterrm   rq   rw   rA   r}   r   rB   r   r   rC   r   r   rD   rF   r   r"   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r"  r+  r&   __classcell__rJ   s   @r(   r*   r*   M   s   	!I~ 	 04/3/3/3$(&",&" -&" -	&"
 -&" "&" &"PU6  , 	ZZ (- =.+ Hh - D+ Hh - D+ Hh - D+ Hh - D+ /4 Vp*< H  %z% 
	z%|4lR"S";z1
h'1R2>2$>0-^/0::_B0d7Xr10 10r'   r*   c                      \ rS rSrSrg)r^   iJ  r   Nr   r   r   r   r&   r   r'   r(   r^   r^   J      r'   r^   c                $   U R                  UR                  5       5      n0 n[        UR                  5       HL  u  pVUR                  5       R	                  USUS9nU H"  nXT;   a  XE   R                  U5        M  U/XE'   M$     MN     [        U5      $ )a  
returns the :class:`~music21.voiceLeading.Verticality` object given a score,
and a music21 object within this score
(under development)

>>> c = corpus.parse('bach/bwv66.6')
>>> n1 = c.flatten().getElementsByClass(note.Note).first()
>>> voiceLeading.getVerticalityFromObject(n1, c)
<music21.voiceLeading.Verticality
    contentDict={0: [<music21.instrument.Instrument 'P1: Soprano: Instrument 1'>,
                     <music21.clef.TrebleClef>,
                     <music21.tempo.MetronomeMark Quarter=96 (playback only)>,
                     <music21.key.Key of f# minor>,
                     <music21.meter.TimeSignature 4/4>,
                     <music21.note.Note C#>],
          1: [<music21.instrument.Instrument 'P2: Alto: Instrument 2'>,
              <music21.clef.TrebleClef>,
              <music21.tempo.MetronomeMark Quarter=96 (playback only)>,
              <music21.key.Key of f# minor>,
              <music21.meter.TimeSignature 4/4>,
              <music21.note.Note E>],
          2: [<music21.instrument.Instrument 'P3: Tenor: Instrument 3'>,
              <music21.clef.BassClef>,
              <music21.tempo.MetronomeMark Quarter=96 (playback only)>,
              <music21.key.Key of f# minor>,
              <music21.meter.TimeSignature 4/4>,
              <music21.note.Note A>],
          3: [<music21.instrument.Instrument 'P4: Bass: Instrument 4'>,
              <music21.clef.BassClef>,
              <music21.tempo.MetronomeMark Quarter=96 (playback only)>,
              <music21.key.Key of f# minor>,
              <music21.meter.TimeSignature 4/4>,
              <music21.note.Note A>]}>

for getting things at the beginning of scores, probably better to use a classFilterList:

>>> voiceLeading.getVerticalityFromObject(n1, c,
...                      classFilterList=[note.Note, chord.Chord, note.Rest])
<music21.voiceLeading.Verticality contentDict={0: [<music21.note.Note C#>],
          1: [<music21.note.Note E>],
          2: [<music21.note.Note A>],
          3: [<music21.note.Note A>]}>
F)mustBeginInSpan	classList)getOffsetBySiteflatten	enumeratepartsgetElementsByOffsetr8   Verticality)	
music21ObjscoreObjectIsFromclassFilterListoffsetOfObjectcontentDictpartNumpartObjelementSelectionels	            r(   getVerticalityFromObjectrL  N  s    X  //0A0I0I0KLNK%&7&=&=>"??,@@INCR A T #B%$++B/(*t$	 #	 ? {##r'   c                     ^  \ rS rSr% SrSS0rS\S'   SS U 4S jjjrS rS	 r	S
 r
S rS rS rS rSS jrSS jr\S 5       rS rSS.S jrS rS r\" \\SS9rS rS rS r\" \\SS9rSrU =r$ )!rB  i  a  
DEPRECATED in v7 in favor of tree.verticality.Verticality

A Verticality (previously called "vertical slice")
object provides more accessible information about
vertical moments in a score. A Verticality is
instantiated by passing in a dictionary of
the form {partNumber: [ music21Objects ] }

Verticalities are useful to provide direct and easy access to objects in a part.
A list of Verticalities, although similar to the list of chords from a chordified score,
provides easier access to part number
information and identity of objects in the score. Plus, the objects in a
Verticality point directly
to the objects in the score, so modifying a Verticality taken from a
score is the same as modifying the elements
of the Verticality in the score directly.

>>> vs1 = voiceLeading.Verticality({0: [note.Note('A4'), harmony.ChordSymbol('Cm')],
...                                 1: [note.Note('F2')]})
>>> vs1.getObjectsByClass(note.Note)
[<music21.note.Note A>, <music21.note.Note F>]
>>> vs1.getObjectsByPart(0, note.Note)
<music21.note.Note A>
rG  zDictionary representing contents of Verticalities.
            the keys of the dictionary
            are the part numbers and the element at each key is a list of
            music21 objects (allows for multiple voices
            in a single part)r.   r/   c                   > [         TU ]  " S0 UD6  Uc  0 nUR                  5        H!  u  p4[        U[        5      (       a  M  U/X'   M#     Xl        g Nr   )r6   r7   itemsrY   listrG  )rG   rG  rI   rH  elementrJ   s        r(   r7   Verticality.__init__  sS    $8$K + 1 1 3Ggt,,(/y$ !4 'r'   c                >    U R                  5       R                  5       $ )a  
evaluates whether this Verticality moment is consonant or dissonant
according to the common-practice
consonance rules. Method generates chord of all simultaneously sounding pitches, then calls
:meth:`~music21.chord.isConsonant`

>>> V = voiceLeading.Verticality
>>> N = note.Note
>>> V({0: N('A4'), 1: N('B4'), 2: N('A4')}).isConsonant()
False
>>> V({0: N('A4'), 1: N('B4'), 2: N('C#4')}).isConsonant()
False
>>> V({0: N('C3'), 1: N('G5'), 2: chord.Chord(['C3', 'E4', 'G5'])}).isConsonant()
True
>>> V({0: N('A3'), 1: N('B3'), 2: N('C4')}).isConsonant()
False
>>> V({0: N('C1'), 1: N('C2'), 2: N('C3'),
...    3: N('G1'), 4: N('G2'), 5: N('G3')}).isConsonant()
True
>>> V({0: N('A3'), 1: harmony.ChordSymbol('Am')}).isConsonant()
True
)getChordisConsonantrV   s    r(   rV  Verticality.isConsonant  s    . }}**,,r'   c                   / nU R                    H  n[        U[        R                  5      (       a0  UR                   H  nUR                  UR                  5        M      MR  [        U[        R                  5      (       d  Ms  UR                  U5        M     [        R                  " U5      nU R                  Ul	        U$ )a+  
extracts all simultaneously sounding pitches (from chords, notes, harmony objects, etc.)
and returns
as a chord. Pretty much returns the Verticality to a chordified output.

>>> N = note.Note
>>> vs1 = voiceLeading.Verticality({0:N('A4'), 1:chord.Chord(['B', 'C', 'A']), 2:N('A')})
>>> vs1.getChord()
<music21.chord.Chord A4 B C A A>
>>> voiceLeading.Verticality({0:N('A3'),
...                           1:chord.Chord(['F3', 'D4', 'A4']),
...                           2:harmony.ChordSymbol('Am')}).getChord()
<music21.chord.Chord A3 F3 D4 A4 A2 C3 E3>
)
objectsrY   r   r  pitchesr8   rM   r   rf   style)rG   rZ  rK  xchs        r(   rU  Verticality.getChord  s     ,,B"ekk**ANN1#3#34 $B		**r"  [[!::	r'   c                B    U R                  U R                  5       5        g)a  
locates the smallest duration of all elements in the Verticality
and assigns this duration
to each element

>>> n1 =  note.Note('C4')
>>> n1.quarterLength = 1
>>> n2 =  note.Note('G4')
>>> n2.quarterLength = 2
>>> cs = harmony.ChordSymbol('C')
>>> cs.quarterLength = 4
>>> vs1 = voiceLeading.Verticality({0:n1, 1:n2, 2:cs})
>>> vs1.makeAllSmallestDuration()
>>> [x.quarterLength for x in vs1.objects]
[1.0, 1.0, 1.0]
N)changeDurationOfAllObjectsgetShortestDurationrV   s    r(   makeAllSmallestDuration#Verticality.makeAllSmallestDuration  s    " 	''(@(@(BCr'   c                B    U R                  U R                  5       5        g)a  
locates the largest duration of all elements in the Verticality
and assigns this duration
to each element

>>> n1 =  note.Note('C4')
>>> n1.quarterLength = 1
>>> n2 =  note.Note('G4')
>>> n2.quarterLength = 2
>>> cs = harmony.ChordSymbol('C')
>>> cs.quarterLength = 4
>>> vs1 = voiceLeading.Verticality({0:n1, 1:n2, 2:cs})
>>> vs1.makeAllLargestDuration()
>>> [x.quarterLength for x in vs1.objects]
[4.0, 4.0, 4.0]
N)r`  getLongestDurationrV   s    r(   makeAllLargestDuration"Verticality.makeAllLargestDuration  s    " 	''(?(?(ABr'   c                j    [        U R                   Vs/ s H  oR                  PM     sn5      $ s  snf )a>  
returns the smallest quarterLength that exists among all elements

>>> n1 =  note.Note('C4')
>>> n1.quarterLength = 1
>>> n2 =  note.Note('G4')
>>> n2.quarterLength = 2
>>> cs = harmony.ChordSymbol('C')
>>> cs.quarterLength = 4
>>> vs1 = voiceLeading.Verticality({0:n1, 1:n2, 2:cs})
>>> vs1.getShortestDuration()
1.0
)minrY  ri   rG   objs     r(   ra  Verticality.getShortestDuration  )     >#%%>??>   0c                j    [        U R                   Vs/ s H  oR                  PM     sn5      $ s  snf )a7  
returns the longest duration that exists among all elements

>>> n1 =  note.Note('C4')
>>> n1.quarterLength = 1
>>> n2 =  note.Note('G4')
>>> n2.quarterLength = 2
>>> cs = harmony.ChordSymbol('C')
>>> cs.quarterLength = 4
>>> vs1 = voiceLeading.Verticality({0:n1, 1:n2, 2:cs})
>>> vs1.getLongestDuration()
4.0
)maxrY  ri   rj  s     r(   re  Verticality.getLongestDuration!  rm  rn  c                6    U R                    H	  nXl        M     g)a  
changes the duration of all objects in Verticality

>>> n1 =  note.Note('C4')
>>> n1.quarterLength = 1
>>> n2 =  note.Note('G4')
>>> n2.quarterLength = 2
>>> cs = harmony.ChordSymbol('C')
>>> cs.quarterLength = 4
>>> vs1 = voiceLeading.Verticality({0:n1, 1:n2, 2:cs})
>>> vs1.changeDurationOfAllObjects(1.5)
>>> [x.quarterLength for x in vs1.objects]
[1.5, 1.5, 1.5]

Note: capitalization of function changed in v5.7
N)rY  ri   )rG   newQuarterLengthrk  s      r(   r`  &Verticality.changeDurationOfAllObjects1  s    " <<C 0  r'   c                   [         R                  " U5      (       d  U/n/ nU R                  U    Vs/ s H	  oDc  M  UPM     sn HP  nUS/:X  a  UR                  U5        M  UR                  R                  U5      (       a  M?  UR                  U5        MR     [        U5      S:  a  U$ [        U5      S:X  a  US   $ gs  snf )a;  
returns the list of music21 objects associated with a given part number
(if more than one). returns
the single object if only one. Optionally specify which
type of objects to return with classFilterList

>>> vs1 = voiceLeading.Verticality({0: [note.Note('A4'), harmony.ChordSymbol('C')],
...                                 1: [note.Note('C')]})
>>> vs1.getObjectsByPart(0, classFilterList=['Harmony'])
<music21.harmony.ChordSymbol C>
>>> vs1.getObjectsByPart(0)
[<music21.note.Note A>, <music21.harmony.ChordSymbol C>]
>>> vs1.getObjectsByPart(1)
<music21.note.Note C>
Nr4   r   )r   
isIterablerG  r8   classSet
isdisjointlen)rG   rH  rE  retListrK  s        r(   getObjectsByPartVerticality.getObjectsByPartE  s        11./O $ 0 0 9L 9"2 9LB4&(r"{{--o>>NN2& M w<!N\Q1: Ms
   B?B?c                &   [         R                  " U5      (       d  U/n/ nU R                  R                  5        HR  u  pEU HG  nUb   UR                  R                  U5      (       a  M(  U(       a  XB;  a  M6  UR                  U5        MI     MT     U$ )a`  
returns a list of all objects in the Verticality of a type contained
in the classFilterList. Optionally
specify part numbers to only search for matching objects

>>> N = note.Note
>>> vs1 = voiceLeading.Verticality({0: [N('A4'), harmony.ChordSymbol('C')],
...                                 1: [N('C')],
...                                 2: [N('B'), N('F#')]})
>>> vs1.getObjectsByClass('Note')
[<music21.note.Note A>, <music21.note.Note C>,
 <music21.note.Note B>, <music21.note.Note F#>]
>>> vs1.getObjectsByClass('Note', [1, 2])
[<music21.note.Note C>, <music21.note.Note B>, <music21.note.Note F#>]

)r   rv  rG  rP  rw  rx  r8   )rG   rE  partNumsrz  partobjList	m21objects          r(   getObjectsByClassVerticality.getObjectsByClassf  s    "   11./O!--335MD$	$	(:(:(E(Eo(V(VD$8 NN9- % 6 r'   c                    / nU R                   R                  5        H  u  p#U H  nUR                  U5        M     M!     U$ )a-  
return a list of all the music21 objects in the Verticality

>>> vs1 = voiceLeading.Verticality({0: [harmony.ChordSymbol('C'), note.Note('A4'),],
...                                 1: [note.Note('C')]})
>>> vs1.objects
[<music21.harmony.ChordSymbol C>, <music21.note.Note A>, <music21.note.Note C>]
)rG  rP  r8   )rG   rz  unused_partr  r  s        r(   rY  Verticality.objects  sB     $($4$4$:$:$< K$	y) % %= r'   c                L   SSK Jn  UR                  " 5       nU R                  R	                  5        H  u  p4UR
                  " SU 3S9nUS   nUR                  [        R                  5      nUR                  [        R                  5      nUR                  [        R                  5      n	U(       a  UR                  U5        U(       a  UR                  U5        U	(       a  UR                  U	5        U H  n
UR                  SU
5        M     UR                  U5        M     U$ )a  
returns a stream representation of this Verticality. Correct key, meter, and time
signatures will be included if they are found in the context of the first part

>>> vs1 = voiceLeading.Verticality({0: [harmony.ChordSymbol('C'), note.Note('A4'),],
...                                 1: [note.Note('C')]})
>>> vsStream = vs1.getStream()
>>> vsStream.show('text')
{0.0} <music21.stream.Part part-0>
    {0.0} <music21.harmony.ChordSymbol C>
    {0.0} <music21.note.Note A>
{0.0} <music21.stream.Part part-1>
    {0.0} <music21.note.Note C>

How many notes are there anywhere in the hierarchy?

>>> len(vsStream[note.Note])
2
>>> len(vsStream[harmony.Harmony])
1
r   r   zpart-)id)r  r   ScorerG  rP  PartgetContextByClassr   Clefr   KeySignaturer   TimeSignaturer8   insert)rG   r   	retStreamrH  elementListpfoundObjclkstsrK  s              r(   	getStreamVerticality.getStream  s    , 	#LLN	$($4$4$:$:$< Gwi01A"1~H++DII6B++C,<,<=B++E,?,?@B!B "Q! %=" r'   T)	leftAlignc                   U R                   (       d  gU(       a"  [        U R                   S S9S   R                  $ [        U R                   S S9S   R                  $ )aP  
returns the overall offset of the Verticality. Typically, this would just be the
offset of each object in the Verticality,
and each object would have the same offset.
However, if the duration of one object in the slice is different from
the duration of another,
and that other starts after the first, but the first is still sounding, then the
offsets would be
different. In this case, specify leftAlign=True to return the lowest valued-offset
of all the objects
in the Verticality. If you prefer the offset of the right-most starting object,
then specify leftAlign=False

>>> s = stream.Score()
>>> n1 = note.Note('A4', quarterLength=1.0)
>>> s.append(n1)
>>> n1.offset
0.0
>>> n2 = note.Note('F2', quarterLength =0.5)
>>> s.append(n2)
>>> n2.offset
1.0
>>> vs = voiceLeading.Verticality({0:n1, 1: n2})
>>> vs.getObjectsByClass(note.Note)
[<music21.note.Note A>, <music21.note.Note F>]

>>> vs.getVerticalityOffset(leftAlign=True)
0.0
>>> vs.getVerticalityOffset(leftAlign=False)
1.0

* Changed in v8: renamed getVerticalityOffset to not conflict with
    .offset property.  Made leftAlign keyword only
rc   c                    U R                   $ rp   offsetm21Objs    r(   <lambda>2Verticality.getVerticalityOffset.<locals>.<lambda>      6==r'   r   r   c                    U R                   $ rp   r  r  s    r(   r  r    r  r'   )rY  sortedr  )rG   r  s     r(   getVerticalityOffset Verticality.getVerticalityOffset  sL    F ||$,,,HI!LSSS$,,,HI"MTTTr'   c                B    [        U R                  S SS9nXS   l        g )Nc                    U R                   $ rp   r  r\  s    r(   r  'Verticality._setLyric.<locals>.<lambda>      QXXr'   Tr   reverser   r  rY  lyric)rG   rj   newLists      r(   	_setLyricVerticality._setLyric  s    +=tL 
r'   c                L    [        U R                  S SS9nUS   R                  $ )Nc                    U R                   $ rp   r  r  s    r(   r  'Verticality._getLyric.<locals>.<lambda>  r  r'   Tr  r   r  )rG   r  s     r(   	_getLyricVerticality._getLyric  s%    +=tLqzr'   a;  
        sets each object on the Verticality to have the passed in lyric

        >>> h = voiceLeading.Verticality({1: note.Note('C'), 2: harmony.ChordSymbol('C')})
        >>> h.lyric = 'Verticality 1'
        >>> h.getStream().flatten().getElementsByClass(note.Note).first().lyric
        'Verticality 1'
        rz   c                     SU R                    3$ )NzcontentDict=rG  rV   s    r(   rS   Verticality._reprInternal  s    d../00r'   c                j    XR                   l        U R                   H  nXR                   l        M     g rp   )r[  colorrY  )rG   r  rk  s      r(   	_setColorVerticality._setColor  s#     

<<C#IIO  r'   c                .    U R                   R                  $ rp   )r[  r  rV   s    r(   	_getColorVerticality._getColor  s    zzr'   aE  
        sets the color of each element in the Verticality

        >>> vs1 = voiceLeading.Verticality({1:note.Note('C'), 2:harmony.ChordSymbol('D')})
        >>> vs1.color = 'blue'
        >>> [(x, x.style.color) for x in vs1.objects]
        [(<music21.note.Note C>, 'blue'), (<music21.harmony.ChordSymbol D>, 'blue')]
    r  rp   )rG  zdict | None)r   r   r   r   r1  r/   r2  r7   rV  rU  rb  rf  ra  re  r`  r{  r  r3  rY  r  r  r  r  r  rS   r  r  r  r&   r5  r6  s   @r(   rB  rB    s    : 	 !!I~ ' '-24D&C&@ @ 1(B>  )V 15 (UT!  Y	 0 E1$
  Y	 0 	Er'   rB  c                  <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )VerticalityNTupleti  z
a collection of n number of Verticalities. These objects are useful when
analyzing counterpoint
motion and music theory elements such as passing tones
c                   > [         TU ]  " S0 UD6  Xl        [        U5      U l        / U l        U(       a  U R                  5         g g rO  )r6   r7   verticalitiesry  
nTupletNum	chordList_calcChordsrG   listOfVerticalitiesrI   rJ   s      r(   r7   VerticalityNTuplet.__init__  sA    $8$012 r'   c                    U R                    HO  nU R                  R                  [        R                  " UR                  [        R                  5      5      5        MQ     g rp   )r  r  r8   r   r  r  r   rf   )rG   vss     r(   r  VerticalityNTuplet._calcChords!  s<    $$BNN!!%++b.B.B499.M"NO %r'   c                     SU R                    3$ )NzlistOfVerticalities=)r  rV   s    r(   rS    VerticalityNTuplet._reprInternal%  s    %d&8&8%9::r'   )r  r  r  r   )
r   r   r   r   r1  r7   r  rS   r&   r5  r6  s   @r(   r  r    s    P; ;r'   r  c                  J   ^  \ rS rSrSrSU 4S jjrS rS	S jrS	S jrSr	U =r
$ )
VerticalityTripleti*  z%
a collection of three Verticalities
c                f   > [         TU ]  " U40 UD6  0 U l        U(       a  U R                  5         g g rp   )r6   r7   tnlsDict	_calcTNLSr  s      r(   r7   VerticalityTriplet.__init__.  s/    ,99NN r'   c                   [        [        [        U R                  S   R	                  [
        R                  5      5      [        U R                  S   R	                  [
        R                  5      5      [        U R                  S   R	                  [
        R                  5      5      5      5       H  n[        U R                  S   R                  U[
        R                  5      U R                  S   R                  U[
        R                  5      U R                  S   R                  U[
        R                  5      /5      U R                  U'   M     g)zP
calculates the three note linear segments if only three Verticalities provided
r   r4   r5   N)
rangeri  ry  r  r  r   rf   ThreeNoteLinearSegmentr{  r  )rG   rH  s     r(   r  VerticalityTriplet._calcTNLS5  s     ST%7%7%:%L%LTYY%W!X$'(:(:1(=(O(OPTPYPY(Z$[$'(:(:1(=(O(OPTPYPY(Z$[] G &<&&q)::7DIIN&&q)::7DIIN&&q)::7DIIN&DMM'"	r'   c                   XR                   ;   a  U R                   U   R                  5       nOgU(       a0   U=(       a&    U R                   U   R                  R                  S:  nU(       ag  U R                  S   R                  5       (       aE  U R                  S   R                  5       (       d#  U R                  S   R                  5       (       a  gg! [        [
        [        R                  4 a     Nf = f)a*  
return true if this Verticality triplet contains a passing tone
music21 currently identifies passing tones by analyzing both horizontal motion
and vertical motion.
It first checks to see if the note could be a passing tone based on the notes
linearly adjacent to it.
It then checks to see if the note's vertical context is dissonant, while the
Verticalities
to the left and right are consonant

partNum is the part (starting with 0) to identify the passing tone

>>> vs1 = voiceLeading.Verticality({0:note.Note('A4'), 1:note.Note('F2')})
>>> vs2 = voiceLeading.Verticality({0:note.Note('B-4'), 1:note.Note('F2')})
>>> vs3 = voiceLeading.Verticality({0:note.Note('C5'), 1:note.Note('E2')})
>>> vt = voiceLeading.VerticalityTriplet([vs1, vs2, vs3])
>>> vt.hasPassingTone(0)
True
>>> vt.hasPassingTone(1)
False

F      ?r   r4   r5   T)
r  couldBePassingTonen2beatStrengthrN   	NameErrorr   Music21ObjectExceptionr  rV  rG   partNumToIdentifyunaccentedOnlyrets       r(   hasPassingTone!VerticalityTriplet.hasPassingToneF  s    . --- 12EEGCVt}}->?BBOORUU NN1%1133q)5577NN1%1133 #It/J/JK s   /C C76C7c                l   XR                   ;   a  U R                   U   R                  5       nOgU(       a0   U=(       a&    U R                   U   R                  R                  S:  nU=(       a"    U R                  S   R                  5       (       + $ ! [        [
        [        R                  4 a     NLf = f)a8  
return true if this Verticality triplet contains a neighbor tone
music21 currently identifies neighbor tones by analyzing both horizontal motion
and vertical motion.
It first checks to see if the note could be a neighbor tone based on the notes
linearly adjacent to it.
It then checks to see if the note's vertical context is dissonant,
while the Verticalities
to the left and right are consonant

partNum is the part (starting with 0) to identify the passing tone
for use on 3 Verticalities (3-tuplet)

>>> vs1 = voiceLeading.Verticality({0:note.Note('E-4'), 1: note.Note('C3')})
>>> vs2 = voiceLeading.Verticality({0:note.Note('E-4'), 1: note.Note('B2')})
>>> vs3 = voiceLeading.Verticality({0:note.Note('C5'), 1: note.Note('C3')})
>>> vt = voiceLeading.VerticalityTriplet([vs1, vs2, vs3])
>>> vt.hasNeighborTone(1)
True
Fr  r4   )
r  couldBeNeighborToner  r  rN   r  r   r  r  rV  r  s       r(   hasNeighborTone"VerticalityTriplet.hasNeighborToneo  s    , --- 12FFHCVt}}->?BBOORUU :4>>!,88::: #It/J/JK s   /B B32B3)r  r  )F)r   r   r   r   r1  r7   r  r  r  r&   r5  r6  s   @r(   r  r  *  s"    "&R; ;r'   r  c                  T   ^  \ rS rSrSrS	U 4S jjr\S 5       rS r\" \SS9r	Sr
U =r$ )
NNoteLinearSegmenti  a<  
a list of n notes strung together in a sequence
noteList = [note1, note2, note3, ..., note-n ] Once this
object is created with a noteList, the noteList may not
be changed

>>> n = voiceLeading.NNoteLinearSegment(['A', 'C', 'D'])
>>> n.noteList
[<music21.note.Note A>, <music21.note.Note C>, <music21.note.Note D>]
c                .  > [         TU ]  " S0 UD6  / U l        U H  nUc  U R                  R                  S 5        M#  [	        U[
        5      (       a1  U R                  R                  [        R                  " U5      5        Mi   UR                  R                  [        R                  [        R                  /5      (       d  U R                  R                  U5        M  M     g ! [        [        4 a    U R                  R                  S 5         M  f = frO  )r6   r7   	_noteListr8   rY   rZ   r   rf   rw  rx  r   rg   rN   r  )rG   noteListrI   rj   rJ   s       r(   r7   NNoteLinearSegment.__init__  s    $8$E}%%d+E3''%%dii&670 >>44dii5MNN--e4 O  '	2 0NN))$/0s   AC%%+DDc                     U R                   SS $ )a  
Read-only property -- returns a copy of the list of notes in the
linear segment.

>>> n = voiceLeading.NNoteLinearSegment(['A', 'B5', 'C', 'F#'])
>>> n.noteList
[<music21.note.Note A>, <music21.note.Note B>,
 <music21.note.Note C>, <music21.note.Note F#>]
Nr  rV   s    r(   r  NNoteLinearSegment.noteList  s     ~~a  r'   c                    U R                   S S nU R                   SS  n/ n[        X5       HK  u  pEU(       a.  U(       a'  UR                  [        R                  " XE5      5        M:  UR                  S 5        MM     U$ )Nr  r4   )r  zipr8   r
   r9   )rG   tempListOnetempListTwomelodicIntervalListn1r  s         r(   _getMelodicIntervals'NNoteLinearSegment._getMelodicIntervals  sm    mmCR(mmAB' +3FBb#**8+<+<R+DE#**40	 4
 #"r'   a  
        calculates the melodic intervals and returns them as a list,
        with the interval at 0 being the interval between the first and second note.

        >>> linSeg = voiceLeading.NNoteLinearSegment([note.Note('A'), note.Note('B'),
        ...            note.Note('C'), note.Note('D')])
        >>> linSeg.melodicIntervals
        [<music21.interval.Interval M2>,
         <music21.interval.Interval M-7>,
         <music21.interval.Interval M2>]
        rz   r  r  )r   r   r   r   r1  r7   r3  r  r  melodicIntervalsr&   r5  r6  s   @r(   r  r    s;    	0 
! 
!	#   4 
; 
r'   r  c                      \ rS rSrSrg)ThreeNoteLinearSegmentExceptioni  r   Nr8  r   r'   r(   r  r    r9  r'   r  c                    ^  \ rS rSrSr/ SQrSU 4S jjrS rS rS r	S r
S	 rS
 rS r\" \\SS9r\" \	\
SS9r\" \\SS9rS rS rS r\" \SS9r\" \SS9r\" \SS9rS rS S jrS S jrS rS rS rS S jrS S jrSr U =r!$ )!r  i  a  
An object consisting of three sequential notes

The middle tone in a ThreeNoteLinearSegment can
be classified using methods enclosed in this class
to identify it as types of embellishing tones. Further
methods can be used on the entire stream to identify these
as non-harmonic.

Accepts a sequence of strings, pitches, or notes.

>>> ex = voiceLeading.ThreeNoteLinearSegment('C#4', 'D4', 'E-4')
>>> ex.n1
<music21.note.Note C#>
>>> ex.n2
<music21.note.Note D>
>>> ex.n3
<music21.note.Note E->

>>> ex = voiceLeading.ThreeNoteLinearSegment(note.Note('A4'),note.Note('D4'),'F5')
>>> ex.n1
<music21.note.Note A>
>>> ex.n2
<music21.note.Note D>
>>> ex.n3
<music21.note.Note F>
>>> ex.iLeftToRight
<music21.interval.Interval m6>

>>> ex.iLeft
<music21.interval.Interval P-5>
>>> ex.iRight
<music21.interval.Interval m10>

if no octave specified, default octave of 4 is assumed

>>> ex2 = voiceLeading.ThreeNoteLinearSegment('a', 'b', 'c')
>>> ex2.n1
<music21.note.Note A>
>>> defaults.pitchOctave
4

)r  couldBeDiatonicPassingTonecouldBeChromaticPassingToner  couldBeDiatonicNeighborTonecouldBeChromaticNeighborTonec                   > [         R                  " U5      (       a  [        TU ]  " U40 UD6  g [        TU ]  " XU/40 UD6  g rp   )r   rv  r6   r7   )rG   noteListOrN1r  n3rI   rJ   s        r(   r7   ThreeNoteLinearSegment.__init__
  s=    \**G\6X6Gl3@x@r'   c                     U R                   S   $ Nr   r  rV   s    r(   _getN1ThreeNoteLinearSegment._getN1      }}Qr'   c                @    U R                  U5      U R                  S'   g r  _correctNoteInputr  rv   s     r(   _setN1ThreeNoteLinearSegment._setN1      11%8ar'   c                     U R                   S   $ Nr4   r  rV   s    r(   _getN2ThreeNoteLinearSegment._getN2  r  r'   c                @    U R                  U5      U R                  S'   g r  r  rv   s     r(   _setN2ThreeNoteLinearSegment._setN2  r  r'   c                     U R                   S   $ Nr5   r  rV   s    r(   _getN3ThreeNoteLinearSegment._getN3  r  r'   c                @    U R                  U5      U R                  S'   g r  r  rv   s     r(   _setN3ThreeNoteLinearSegment._setN3  r  r'   c                (   Uc  g [        U[        5      (       a  [        R                  " U5      $  UR                  R                  [        R                  [        R                  /5      (       d  U$ g ! [         a  n[        SU< 35      UeS nAff = f)Nrd   )
rY   rZ   r   rf   rw  rx  r   rg   rN   r  )rG   rj   r`   s      r(   r  (ThreeNoteLinearSegment._correctNoteInput"  s    =s##99U##~~00$))U[[1IJJ L! 56ui@s   ?A2 2
B<BBzF
        get or set the first note (left-most) in the segment
        rz   z;
        get or set the middle note in the segment
        zF
        get or set the last note (right-most) in the segment
        c                    U R                   (       a<  U R                  (       a+  [        R                  " U R                   U R                  5      $ g rp   )r  r	  r
   r9   rV   s    r(   _getILeftToRight'ThreeNoteLinearSegment._getILeftToRight=  s-    77tww$$TWWdgg66r'   c                     U R                   S   $ r  r  rV   s    r(   	_getILeft ThreeNoteLinearSegment._getILeftC      $$Q''r'   c                     U R                   S   $ r  r+  rV   s    r(   
_getIRight!ThreeNoteLinearSegment._getIRightF  r.  r'   z
        get the interval between the left-most note and the right-most note
        (read-only property)

        >>> tnls = voiceLeading.ThreeNoteLinearSegment('C', 'E', 'G')
        >>> tnls.iLeftToRight
        <music21.interval.Interval P5>
        z
        get the interval between the left-most note and the middle note
        (read-only property)

        >>> tnls = voiceLeading.ThreeNoteLinearSegment('A', 'B', 'G')
        >>> tnls.iLeft
        <music21.interval.Interval M2>
        z
        get the interval between the middle note and the right-most note
        (read-only property)

        >>> tnls = voiceLeading.ThreeNoteLinearSegment('A', 'B', 'G')
        >>> tnls.iRight
        <music21.interval.Interval M-3>
        c                T    SU R                    SU R                   SU R                   3$ )Nzn1=z n2=z n3=r  r  r	  rV   s    r(   rS   $ThreeNoteLinearSegment._reprInternalc  s'    TWWIT$''$twwi88r'   c                r    U R                   S L=(       a#    U R                  S L=(       a    U R                  S L$ rp   r3  rV   s    r(   _isComplete"ThreeNoteLinearSegment._isCompletef  s.    t#X$''*=XDGGSWDWXr'   c                |    U R                  5       (       d  gU R                  5       =(       d    U R                  5       $ )a  
checks if the two intervals are steps and if these steps
are moving in the same direction. Returns True if the tone is
identified as either a chromatic passing tone or a diatonic passing
tone. Only major and minor diatonic passing tones are recognized (not
pentatonic or scales beyond twelve-notes). Does NOT check if tone is non-harmonic.

Accepts pitch or note objects; method is dependent on octave information

>>> voiceLeading.ThreeNoteLinearSegment('C#4', 'D4', 'E-4').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D3', 'E3').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('E-3', 'F3', 'G-3').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'C3', 'C3').couldBePassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('A3', 'C3', 'D3').couldBePassingTone()
False

Directionality must be maintained

>>> voiceLeading.ThreeNoteLinearSegment('B##3', 'C4', 'D--4').couldBePassingTone()
False

If no octave is given then ._defaultOctave is used.  This is generally octave 4

>>> voiceLeading.ThreeNoteLinearSegment('C', 'D', 'E').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C4', 'D', 'E').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C5', 'D', 'E').couldBePassingTone()
False

Method returns True if either a chromatic passing tone or a diatonic passing
tone is identified. Spelling of the pitch does matter!

>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'B##3').couldBePassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('A##3', 'C4', 'E---4').couldBePassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'D-4').couldBePassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'C#4').couldBePassingTone()
True
F)r6  r  r  rV   s    r(   r  )ThreeNoteLinearSegment.couldBePassingTonej  s4    ^ !!224Z8X8X8ZZr'   c                   U R                  5       =(       a    U R                  R                  R                  =(       a    U R                  R                  R
                  S:H  =(       a    U R                  R                  R
                  S:H  =(       a{    U R                  R                  R
                  U R                  R                  R
                  -  S:H  =(       a0    U R                  R                  U R                  R                  -  S:H  $ )a  
A note could be a diatonic passing tone (and therefore a passing tone in general)
if the generic interval between the previous and the current is 2 or -2;
same for the next; and both move in the same direction
(that is, the two intervals multiplied by each other are 4, not -4).

>>> tls = voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'C#4')
>>> tls.couldBeDiatonicPassingTone()
False

>>> tls = voiceLeading.ThreeNoteLinearSegment('C3', 'D3', 'E3')
>>> tls.couldBeDiatonicPassingTone()
True
r5   r   r4   )r6  iLeftToRightr   r  iLeftr  iRightr   rV   s    r(   r  1ThreeNoteLinearSegment.couldBeDiatonicPassingTone  s       " F%%--44FJJ&&11Q6F KK''22a7F JJ&&11DKK4G4G4R4RRVWW	F
 JJ((4;;+@+@@AE	Gr'   c                D   U R                  5       =(       Ga	    U R                  R                  R                  S;   =(       a    U R                  R                  R                  S;   =(       a    U R                  R                  R                  U R                  R                  R                  -  S:H  =(       aj    U R                  R
                  =(       aM    U R                  R
                  =(       a0    U R                  R                  U R                  R                  -  S:H  $ )a  
A note could a chromatic passing tone (and therefore a passing tone in general)
if the generic interval between the previous and the current is -2, 1, or 2;
the generic interval between the current and next is -2, 1, 2; the two generic
intervals multiply to -2 or 2 (if 4 then it's a diatonic interval; if 1 then
not a passing tone; i.e, C -> C# -> C## is not a chromatic passing tone);
AND between each of the notes there is a chromatic interval of 1 or -1 and
multiplied together it is 1. (i.e.: C -> D-- -> D- is not a chromatic passing tone).

>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'C#4').couldBeChromaticPassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C4', 'C#4').couldBeChromaticPassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'B#3', 'C#4').couldBeChromaticPassingTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'D-4', 'C#4').couldBeChromaticPassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('B3', 'C##4', 'C#4').couldBeChromaticPassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('C#4', 'C4', 'C##4').couldBeChromaticPassingTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('D--4', 'C4', 'D-4').couldBeChromaticPassingTone()
False
)r4   r5   r5   r4   )r6  r<  r   r  r=  isChromaticStepr   rV   s    r(   r  2ThreeNoteLinearSegment.couldBeChromaticPassingTone  s    4   " L LZZ''22f< K,,776AK++669L9L9W9WW[\\K 33K 44	K
 --0E0EEJ	Mr'   c                |    U R                  5       (       d  gU R                  5       =(       d    U R                  5       $ )a  
checks if noteToAnalyze could be a neighbor tone, either a diatonic neighbor tone
or a chromatic neighbor tone. Does NOT check if tone is non-harmonic.

>>> voiceLeading.ThreeNoteLinearSegment('E3', 'F3', 'E3').couldBeNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B-4', 'C5', 'B-4').couldBeNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('B4', 'C5', 'B4').couldBeNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('G4', 'F#4', 'G4').couldBeNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('E-3', 'F3', 'E-4').couldBeNeighborTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D3', 'E3').couldBeNeighborTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('A3', 'C3', 'D3').couldBeNeighborTone()
False
F)r6  r  r  rV   s    r(   r  *ThreeNoteLinearSegment.couldBeNeighborTone  s3    ( !!335\9Z9Z9\\r'   c                   U R                  5       =(       a    U R                  R                  U R                  R                  :H  =(       a    U R                  R
                  R                  S:H  =(       aZ    U R                  R
                  R                  S:H  =(       a0    U R                  R                  U R                  R                  -  S:H  $ )a  
Returns True if and only if noteToAnalyze could be a diatonic neighbor tone, that is,
the left and right notes are identical while the middle is a diatonic step up or down

>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D3', 'C3').couldBeDiatonicNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'C#3', 'C3').couldBeDiatonicNeighborTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D-3', 'C3').couldBeDiatonicNeighborTone()
False
r5   r  )	r6  r  rM   r	  r<  	chromaticr  r=  r   rV   s    r(   r  2ThreeNoteLinearSegment.couldBeDiatonicNeighborTone  s       " C&&$''*@*@@C

$$//14C %%00A5C 

$$t{{'<'<<B		Dr'   c                l   U R                  5       =(       a    U R                  R                  U R                  R                  :H  =(       aj    U R                  R
                  =(       aM    U R                  R
                  =(       a0    U R                  R                  U R                  R                  -  S:H  $ )a/  
returns True if and only if noteToAnalyze could be a chromatic neighbor tone, that is,
the left and right notes are identical while the middle is a chromatic step up or down

>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D3', 'C3').couldBeChromaticNeighborTone()
False
>>> voiceLeading.ThreeNoteLinearSegment('C3', 'D-3', 'C3').couldBeChromaticNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C#3', 'D3', 'C#3').couldBeChromaticNeighborTone()
True
>>> voiceLeading.ThreeNoteLinearSegment('C#3', 'D3', 'D-3').couldBeChromaticNeighborTone()
False
r  )r6  r  rM   r	  r<  r@  r=  r   rV   s    r(   r  3ThreeNoteLinearSegment.couldBeChromaticNeighborTone	  s       " K''477+A+AA JZZ//J[[00J jj**T[[-B-BBbH		Lr'   r   )NNNr/  )"r   r   r   r   r1  
_DOC_ORDERr7   r  r  r  r  r   r#  r  r3  r  r  r	  r(  r,  r0  r;  r<  r=  rS   r6  r  r  r  r  r  r  r&   r5  r6  s   @r(   r  r    s    *V2JA 9 9 9" 
&& ' 
B 
&& ' 
B 
&& ' 
B(( , 3 L Y % E j ' F9Y2[hG. MD]4D(L Lr'   r  c                      \ rS rSrSrg)NChordLinearSegmentExceptioni	  r   Nr8  r   r'   r(   rK  rK  	  r9  r'   rK  c                  2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )NObjectLinearSegmenti!	  c                2   > [         TU ]  " S0 UD6  Xl        g rO  )r6   r7   
objectList)rG   rO  rI   rJ   s      r(   r7   NObjectLinearSegment.__init__"	  s    $8$$r'   c                     SU R                    3$ )NzobjectList=rO  rV   s    r(   rS   "NObjectLinearSegment._reprInternal&	  s    T__-..r'   rR  r  )r   r   r   r   r7   rS   r&   r5  r6  s   @r(   rM  rM  !	  s    %/ /r'   rM  c                  B   ^  \ rS rSrSU 4S jjr\S 5       rS rSrU =r	$ )NChordLinearSegmenti*	  c                L  > [         TU ]  " U40 UD6  / U l        U Hc  nUc  U R                  R                  S 5        M#   UR                  R                  SS/5      (       d  U R                  R                  U5        Mc  Me     g ! [         a  n[        SU< 35      UeS nAff = f)Nr  Harmonyz!not a valid chord specification: )r6   r7   
_chordListr8   rw  rx  rN   rK  )rG   r  rI   rj   r`   rJ   s        r(   r7   NChordLinearSegment.__init__+	  s    /h/E}&&t,	 >>44gy5IJJ..u5 K  & 6;E9Es    =B
B#BB#c                     U R                   SS $ )a  
Returns a list of all chord symbols in this linear segment.
Modifying the list does not change the linear segment.

>>> n = voiceLeading.NChordLinearSegment([harmony.ChordSymbol('Am'),
...                                       harmony.ChordSymbol('F7'),
...                                       harmony.ChordSymbol('G9')])
>>> n.chordList
[<music21.harmony.ChordSymbol Am>,
 <music21.harmony.ChordSymbol F7>,
 <music21.harmony.ChordSymbol G9>]
NrX  rV   s    r(   r  NChordLinearSegment.chordList=	  s     q!!r'   c                     SU R                    3$ )Nz
chordList=)r  rV   s    r(   rS   !NChordLinearSegment._reprInternalN	  s    DNN+,,r'   r[  r  )
r   r   r   r   r7   r3  r  rS   r&   r5  r6  s   @r(   rU  rU  *	  s&    $ " " - -r'   rU  c                  8   ^  \ rS rSrSU 4S jjrS rS rSrU =r$ )TwoChordLinearSegmentiQ	  r   c                   > [        U[        [        45      (       a7  U(       a  [        U5      S:w  a  [	        SU< 35      e[
        TU ]  " U40 UD6  g [
        TU ]  " X/40 UD6  g )Nr5   z/First argument must be a list of length 2, not )rY   rQ  tuplery  
ValueErrorr6   r7   )rG   r  chord2rI   rJ   s       r(   r7   TwoChordLinearSegment.__init__R	  sb    i$//S^q0 Ei]S  GY3(3Gi0=H=r'   c                    [         R                  " U R                  S   R                  5       U R                  S   R                  5       5      $ )a  
returns the chromatic interval between the roots of the two chord symbols

>>> h = voiceLeading.TwoChordLinearSegment([harmony.ChordSymbol('C'),
...                                         harmony.ChordSymbol('G')])
>>> h.rootInterval()
<music21.interval.ChromaticInterval 7>
r   r4   )r
   notesToChromaticr  rootrV   s    r(   rootInterval"TwoChordLinearSegment.rootInterval\	  <     (():)?)?)A4>>RSCTCYCYC[\\r'   c                    [         R                  " U R                  S   R                  5       U R                  S   R                  5       5      $ )a  
returns the chromatic interval between the basses of the two chord symbols

>>> h = voiceLeading.TwoChordLinearSegment(harmony.ChordSymbol('C/E'),
...                                        harmony.ChordSymbol('G'))
>>> h.bassInterval()
<music21.interval.ChromaticInterval 3>
r   r4   )r
   rg  r  bassrV   s    r(   bassInterval"TwoChordLinearSegment.bassIntervalg	  rk  r'   )r   N)	r   r   r   r   r7   ri  rn  r&   r5  r6  s   @r(   r`  r`  Q	  s    >	]	] 	]r'   r`  TF)includeRestsincludeObliqueincludeNoMotionr  c             #     #    U R                  5       R                  US9 H  nUR                  UUUS9 Sh  vN   M     g N	7f)a  
Iterate through all VoiceLeading quartets in a Stream (generally a Score),
yielding a generator of VoiceLeadingQuartets.  N.B. does not yet support Streams with
Chords in them.

>>> b = corpus.parse('bwv66.6')
>>> for vlq in voiceLeading.iterateAllVoiceLeadingQuartets(b):
...     print(vlq.v1n1.measureNumber,
...           vlq.v1n1.getContextByClass(stream.Part).id,
...           vlq.v2n1.getContextByClass(stream.Part).id,
...           vlq)
0 Soprano Tenor <music21.voiceLeading.VoiceLeadingQuartet v1n1=B4, v1n2=A4, v2n1=B3, v2n2=C#4>
0 Soprano Bass <music21.voiceLeading.VoiceLeadingQuartet v1n1=B4, v1n2=A4, v2n1=G#3, v2n2=F#3>
0 Tenor Bass <music21.voiceLeading.VoiceLeadingQuartet v1n1=B3, v1n2=C#4, v2n1=G#3, v2n2=F#3>
1 Soprano Alto <music21.voiceLeading.VoiceLeadingQuartet v1n1=A4, v1n2=B4, v2n1=F#4, v2n2=E4>
1 Soprano Tenor <music21.voiceLeading.VoiceLeadingQuartet v1n1=A4, v1n2=B4, v2n1=C#4, v2n2=B3>
1 Soprano Bass <music21.voiceLeading.VoiceLeadingQuartet v1n1=A4, v1n2=B4, v2n1=F#3, v2n2=G#3>
1 Alto Tenor <music21.voiceLeading.VoiceLeadingQuartet v1n1=F#4, v1n2=E4, v2n1=C#4, v2n2=B3>
1 Alto Bass <music21.voiceLeading.VoiceLeadingQuartet v1n1=F#4, v1n2=E4, v2n1=F#3, v2n2=G#3>
...
)r  )rp  rq  rr  N)asTimespansiterateVerticalitiesgetAllVoiceLeadingQuartets)srp  rq  rr  r  vs         r(   iterateAllVoiceLeadingQuartetsry  s	  sQ     : ]]_11'1B//%)+ 0 
 	
 	
 C	
s   5AA
Ac                  &    \ rS rSrS rS rS rSrg)Testi	  c                    [        5         g)z1
test instantiating an empty VoiceLeadingQuartet
N)r*   rV   s    r(   testInstantiateEmptyObjectTest.testInstantiateEmptyObject	  s
     	r'   c                2    SSK Jn  U" U [        5       5        g )Nr   )testCopyAll)music21.test.commonTestr  globals)rG   r  s     r(   testCopyAndDeepcopyTest.testCopyAndDeepcopy	  s    7D')$r'   c                   [         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[        XXE5      nUR                  5       SL d   eUR	                  5       SL d   eUR                  5       SL d   eUR                  5       SL d   eUR                  [        R                  " S	5      5      SL d   eUR                  [        R                  " S
5      5      SL d   e[        XXD5      nUR                  5       SL d   eUR	                  5       SL d   eUR                  5       SL d   eUR                  5       SL d   e[        XXd5      n	U	R                  5       SL d   eU	R                  [        R                  " S	5      5      SL d   e[        XX55      n
U
R                  [        R                  " S	5      5      SL d   eU
R                  [        R                  " S5      5      SL d   eU
R                  [        R                  " S5      5      SL d   eg )NC4D4E4G4r   C5TFr2   M3AA4)r   rf   r*   r   r   r   r   r   r
   r9   r"   r   )rG   c4d4e4g4a4c5abcds              r(   test_unifiedTestTest.test_unifiedTest	  s    YYt_YYt_YYt_YYt_YYt_YYt_  / D(((!T)))##%... E)))!!("3"3D"9:dBBB!!("3"3D"9:eCCC/zz|t###!U***##%... E)))/##%--- 1 1$ 78EAAA/ 1 1$ 78D@@@ 1 1$ 78EAAA 1 1% 89UBBBr'   r   N)r   r   r   r   r}  r  r  r&   r   r'   r(   r{  r{  	  s    % Cr'   r{  c                      \ rS rSrSrg)TestExternali	  r   Nr8  r   r'   r(   r  r  	  r9  r'   r  __main__rp   )rw  zstream.Streamrp  r0  rq  r0  rr  r0  r  r0  r.  z*Generator[VoiceLeadingQuartet, None, None])2r1  
__future__r   collections.abcr   enumtypingr   unittestr  r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r2  rZ   Enumr   Music21Objectr*   Music21Exceptionr^   rL  rB  r  r  r  r  r  rK  rM  rU  r`  ry  TestCaser{  r  rI  r   mainTestr   r'   r(   <module>r     s  , # %               ?? *,& +dii z0$,, z0z'	<#@#@ 	8$vD	$$$ D	N;++ ;4d;+ d;R=++ =@	l&C&C 	@L/ @LL
	<#@#@ 	/4-- /%-. %-N]/ ]J !"
"
 "
 	"

 "
 "
 0"
L,C8 ,C^	8$$ 	 "#9;HZ[
zT r'   