
    3jf                      U d Z ddlmZ ddlmZ ddlZddlZddlZddl	m
Z
 ddl	mZ ddl	mZ ddl	mZ dd	l	mZ dd
l	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ej*                  rddl	mZ g Zded<    G d deej4                        Z G d de
j8                        Z G d dej<                        Zd7dZ  G d de
j8                        Z! G d de
j8                        Z" G d de"      Z# G d  d!e
j8                        Z$ G d" d#ej<                        Z% G d$ d%e$      Z& G d& d'ej<                        Z' G d( d)e
j8                        Z( G d* d+e(      Z) G d, d-e)      Z*d.d.d/d/d0	 	 	 	 	 	 	 	 	 	 	 d8d1Z+ G d2 d3ejX                        Z- G d4 d5ejX                        Z.ee&e!e"gZ/e0d6k(  rddl	Z	 e	jb                  e-       yy)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                  $    e Zd ZdZdZdZdZdZdZy)
MotionTypezAnti-ParallelContraryz	No MotionObliqueParallelSimilarN)	__name__
__module____qualname__antiParallelcontrarynoMotionobliqueparallelsimilar     A/DATA/.local/lib/python3.12/site-packages/music21/voiceLeading.pyr   r   B   s     "LHHGHGr$   r   c                      e Zd ZU dZdddZded<   	 	 	 	 	 d3	 	 	 	 	 	 	 	 	 d4 fdZd Zed	        Z	e	j                  d
        Z		 	 	 	 d5dZd6dZd7dZ eeed      Zd6dZd7dZ eeed      Zd6dZd7dZ eeed      Zd6dZd7dZ eeed      Zd ZdddZd8dZd8dZd8dZ	 	 d9	 d8d Zd8d!Zd8d"Zd8d#Z d:d8d$Z!d8d%Z"d8d&Z#d8d'Z$d8d(Z%d8d)Z&d8d*Z'd8d+Z(d8d,Z)d8d-Z*d8d.Z+d8d/Z,d8d0Z-d8d1Z.d8d2Z/ xZ0S );VoiceLeadingQuarteta  
    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                X   t        |   di | t        sxt        j                  t	        j
                  d             t        j                  t	        j
                  d             t        j                  t	        j
                  d             t        d   | _        t        d   | _        t        d   | _        d | _	        d | _
        d | _        d | _        || _        || _        || _        || _        g | _        g | _        d | _        ||| _        ||||| j+                          y y y y y )NP1P5P8r         r#   )super__init__r   appendr
   Intervalunisonfifthoctave_v1n1_v1n2_v2n1_v2n2v1n1v1n2v2n1v2n2r(   r)   _keyr   _findIntervals)selfr=   r>   r?   r@   analyticKeykeywords	__class__s          r%   r3   zVoiceLeadingQuartet.__init__e   s    	$8$   !2!24!89  !2!24!89  !2!24!89#A&"1%
#A&



				3535	""DH 0T5E$JZ! K[5E 0r$   c                ^   d }d }d }d }	 | j                   j                  }	 | j                  j                  }	 | j                  j                  }	 | j
                  j                  }d| d| d| d| S # t        $ r Y ^w xY w# t        $ r Y Vw xY w# t        $ r Y Nw xY w# t        $ r Y Fw xY w)Nzv1n1=z, v1n2=z, v2n1=z, v2n2=)r=   nameWithOctaveAttributeErrorr>   r?   r@   )rC   nameV1n1nameV1n2nameV2n1nameV2n2s        r%   _reprInternalz!VoiceLeadingQuartet._reprInternal   s    	yy//H	yy//H	yy//H	yy//H xjz
'(TT%  		
  		
  		
  		sE   A3 B B B  3	A?>A?	BB	BB 	B,+B,c                    | j                   S )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
        )rA   rC   s    r%   r   zVoiceLeadingQuartet.key   s    * yyr$   c                `   t        |t              r1	 t        j                  t        j                  |            }|| _        y 	 t        |t        j                        }|du rt        	 || _        y # t
        $ r}t        d|       |d }~ww xY w# t        $ r}t        d|       |d }~ww xY w)Nz2got a key signature string that is not supported: Fz@got a key signature that is not a string or music21 Key object: )	
isinstancestrr   Key"convertKeyStringToMusic21KeyString	ExceptionVoiceLeadingQuartetExceptionrI   rA   )rC   keyValueeisKeyaes        r%   r   zVoiceLeadingQuartet.key   s    h$773#I#I(#ST 	#Hcgg6E>(( " 	  2H
S " 2'j* s/   (A0 $B 0	B9BB	B-B((B-c                   |t        | |d        y t        |t              r!t        | |t        j                  |             y 	 t        |t        j                        rt        | ||       y t        |t
        j                        r:t        j                         }d|j                  _        ||_        t        | ||       y y # t        $ r}t        d|      |d }~ww xY w)N         not a valid note specification: )setattrrR   rS   r   Noter   PitchdurationquarterLengthrV   rW   )rC   valuewhichnrY   s        r%   _setVoiceNotez!VoiceLeadingQuartet._setVoiceNote   s    
 =D%&s#D%5!12eTYY/D%/u{{3		A/2AJJ,#AGD%+	 4
  26ui@s   'C  +AC   	C	CCc                    | j                   S N)r9   rP   s    r%   _getV1n1zVoiceLeadingQuartet._getV1n1       zzr$   c                (    | j                  |d       y )Nr9   rg   rC   rd   s     r%   _setV1n1zVoiceLeadingQuartet._setV1n1       5'*r$   z
        set note1 for voice 1

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v1n1
        <music21.note.Note C>
        docc                    | j                   S ri   )r:   rP   s    r%   _getV1n2zVoiceLeadingQuartet._getV1n2   rk   r$   c                (    | j                  |d       y )Nr:   rm   rn   s     r%   _setV1n2zVoiceLeadingQuartet._setV1n2   rp   r$   z
        set note 2 for voice 1

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v1n2
        <music21.note.Note D>
        c                    | j                   S ri   )r;   rP   s    r%   _getV2n1zVoiceLeadingQuartet._getV2n1  rk   r$   c                (    | j                  |d       y )Nr;   rm   rn   s     r%   _setV2n1zVoiceLeadingQuartet._setV2n1
  rp   r$   z
        set note 1 for voice 2

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v2n1
        <music21.note.Note E>
        c                    | j                   S ri   )r<   rP   s    r%   _getV2n2zVoiceLeadingQuartet._getV2n2  rk   r$   c                (    | j                  |d       y )Nr<   rm   rn   s     r%   _setV2n2zVoiceLeadingQuartet._setV2n2  rp   r$   z
        set note 2 for voice 2

        >>> vl = voiceLeading.VoiceLeadingQuartet('C', 'D', 'E', 'F')
        >>> vl.v2n2
        <music21.note.Note F>
        c                |   | j                   j                  t        j                  | j                  | j
                               | j                   j                  t        j                  | j                  | j                               | j                  j                  t        j                  | j                  | j                               | j                  j                  t        j                  | j
                  | j                               | j                   D ]	  }d|_	         | j                  D ]	  }d|_	         y )Nharmonicmelodic)
r(   r4   r
   r5   r=   r?   r>   r@   r)   intervalType)rC   vIntvhIntvs      r%   rB   z"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                  d}| j                         rt        j                  }|S | j                         rt        j                  }|S | j                         rt        j                  }|S |r"| j                         rt        j                  }|S | j                         rt        j                  }|S | j                         rt        j                  }|S )a-
  
        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   )rC   r   
motionTypes      r%   r   zVoiceLeadingQuartet.motionType-  s    N 
#++J    "#,,J  !#++J  4#:#:#<#00J    "#,,J  ]]_#,,Jr$   c                H    | j                   D ]  }|j                  dk7  s y y)a  
        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
        r-   FT)r)   name)rC   iVs     r%   r   zVoiceLeadingQuartet.noMotion  s%      //Bww$ " r$   c                    | j                         ry| j                  d   j                  | j                  d   j                  g}d|vryy)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   r0   r-   T)r   r)   r   )rC   iNamess     r%   r   z!VoiceLeadingQuartet.obliqueMotion  sF    * ==?ooa(--tq/A/F/FGF6!r$   c                    | j                         ry| j                  d   j                  | j                  d   j                  k(  ryy)am  
        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   r0   T)r   r)   	directionrP   s    r%   r   z!VoiceLeadingQuartet.similarMotion  s<    4 ==?q!++tq/A/K/KKr$   c                   | j                   d   }|j                  }| j                   d   }|j                  }t        j                  r|J |J | j	                         sy|j
                  |j
                  k7  r|sy|j                  |j                  k7  ry|yd}t        |t        j                        r|j                  |j                  k(  }t        |t              r.t        j                  |      }|j                  |j                  k(  }t        |t              rKt        j                  |      }|j                  |j                  k(  xr |j                  |j                  k(  }|S t        |t        j                  t        j                  f      r4|j                  |j                  k(  xr |j                  |j                  k(  }|S )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   r0   FT)r(   generictTYPE_CHECKINGr   directedsemiSimpleUndirectedrR   r
   GenericIntervalintrS   r5   semiSimpleNameDiatonicInterval)rC   requiredIntervalallowOctaveDisplacementvInt0vInt0_genericvInt1vInt1_genericintervalsAreValids           r%   r   z"VoiceLeadingQuartet.parallelMotion  s   R ""?? ,,, ,,,!!#$$(>(>>-00 556% !&*H,D,DE%2%G%G(8(M(M&N! *C0#+#;#;<L#M %2%G%G(8(M(M&N! *C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                    | j                         ry| j                         ry| j                  d   j                  | j                  d   j                  k(  ryy)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   r0   T)r   r   r)   r   rP   s    r%   r   z"VoiceLeadingQuartet.contraryMotionU  sL    X ==?!q!++tq/A/K/KKr$   c                    | j                         xr4 | j                  d   j                  t        j                  j
                  k(  S )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	ASCENDINGrP   s    r%   outwardContraryMotionz)VoiceLeadingQuartet.outwardContraryMotion  s?     ##% QOOA&00H4F4F4P4PP	Rr$   c                    | j                         xr4 | j                  d   j                  t        j                  j
                  k(  S )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   
DESCENDINGrP   s    r%   inwardContraryMotionz(VoiceLeadingQuartet.inwardContraryMotion  s?     ##% ROOA&00H4F4F4Q4QQ	Sr$   c                >   | j                         sy| j                  d   j                  | j                  d   j                  k(  rY|yt        |t              r| j                  d   j                  |k(  ryy| j                  d   j                  |j                  k(  ryyy)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   r0   T)r   r(   
simpleNamerR   rS   )rC   r   s     r%   r   z&VoiceLeadingQuartet.antiParallelMotion  s    R ""$q!,,0B0M0MM%!*c2??1-88JF#'#(??1-88J<Q<QQ#'#(r$   c                N    | j                  |d      xs | j                  |      S )aI  
        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   rC   thisIntervals     r%   parallelIntervalz$VoiceLeadingQuartet.parallelInterval  s8    V !-(,    5 &&|4	
r$   c                8    | j                  | j                        S )av  
        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   r7   rP   s    r%   parallelFifthz!VoiceLeadingQuartet.parallelFifth  s    N $$TZZ00r$   c                8    | j                  | j                        S )a  
        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   r8   rP   s    r%   parallelOctavez"VoiceLeadingQuartet.parallelOctaveF  s    : $$T[[11r$   c                8    | j                  | j                        S )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   r6   rP   s    r%   parallelUnisonz"VoiceLeadingQuartet.parallelUnisone  s      $$T[[11r$   c                F    | j                         xs | j                         S )aF  
        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   rP   s    r%   parallelUnisonOrOctavez*VoiceLeadingQuartet.parallelUnisonOrOctavew  s!    , ""$=(;(;(==r$   c                    | j                  d      ry| j                         syt        |t              rt	        j
                  |      }| j                  d   j                  |j                  k(  ryy)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   Fr0   )r   r   rR   rS   r
   r5   r(   r   r   s     r%   hiddenIntervalz"VoiceLeadingQuartet.hiddenInterval  se    D t<##%,,'00>q!,,0G0GGr$   c                8    | j                  | j                        S )zs
        Calls :meth:`~music21.voiceLeading.VoiceLeadingQuartet.hiddenInterval`
        by passing a fifth
        )r   r7   rP   s    r%   hiddenFifthzVoiceLeadingQuartet.hiddenFifth  s    
 ""4::..r$   c                8    | j                  | j                        S )z;
        Calls hiddenInterval by passing an octave
        )r   r8   rP   s    r%   hiddenOctavez VoiceLeadingQuartet.hiddenOctave  s     ""4;;//r$   c                    | j                   j                  | j                  j                  k  s-| j                  j                  | j                  j                  kD  ryy)an  
        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)r>   r   r?   r@   r=   rP   s    r%   voiceOverlapz VoiceLeadingQuartet.voiceOverlap  9    0 99??TYY__,		$))//0Qr$   c                    | j                   j                  | j                  j                  k  s-| j                  j                  | j                  j                  k  ryy)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)r=   r   r?   r>   r@   rP   s    r%   voiceCrossingz!VoiceLeadingQuartet.voiceCrossing  r   r$   c                   | j                         ry| j                  r| j                  j                  | j                  j                        }|j	                  | j
                        }|j	                  | j                        }| j                  j                  dk(  rg|et        j                  | j                  j                        }|j	                  | j
                  t        j                  j                        }nd}d}d}| j                  d   j                  }| j                  d   j                  }t        j                   r|J |j"                  }|dk(  r| j$                  | j&                  k\  ryy|d	k(  r'|r|d
k7  ry|r|dk7  ry| j)                         xr |dk(  S |dk(  r'|r|dk7  ry|r|dk7  ry| j+                         xr |dk(  S |dk(  r|r|dk7  ry|r|dk7  ry|dk(  S y)af  
        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   r0   P4FA4         d5   m7   )r   r   getScalemodegetScaleDegreeFromPitchr?   r@   r   MelodicMinorScaletonicr   r   r(   r   r   r   r   simpleUndirectedr=   r>   r   r   )rC   keyScalen1degreen2degree
minorScalefirstHarmonysecondGenericsecondHarmonys           r%   isProperResolutionz&VoiceLeadingQuartet.isProperResolution  s   L ==?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                   | j                         ry| j                  d   j                  }| j                  d   j                  }t        j                  r|J |J |j
                  dk(  r |j
                  dk(  r| j                         ry|j                  r|j                  xs |j                   S |j                  r|j                  xs |j                   S y)af  
        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   r0   r   )
r   r)   r   r   r   
undirectedr   isSkipisDiatonicStepisUnison)rC   hInt0_generichInt1_generics      r%   leapNotSetWithStepz&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                f   ddl m} | j                  d   }| j                  d   }|j                  }|j                  }|j                  }|j                  }t
        j                  r||J ||J t        j                  ||g      }t        j                  ||g      }	|j                  || j                        }
|j                  |	| j                        }g d}|j                  |v xs |j                  |v xr7 |
dur|
d   j                         |v  S |dur	 |d   j                         |v  S d 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   )romanr0   )r-   r.   IVF)music21r   r(   	noteStartnoteEndr   r   r   ChordidentifyAsTonicOrDominantr   r   upper)rC   r   v0v1v0nsv0nev1nsv1nec1c2r1r2openingss                r%   opensIncorrectlyz$VoiceLeadingQuartet.opensIncorrectly  sM   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                   d}| j                   j                  dk(  r| j                   j                  d      j                  d      j                  | j
                  j                  k(  r)| j                   j                  | j                        dk(  }nv| j                   j                  d      j                  d      j                  | j                  j                  k(  r+| j                   j                  | j                        dk(  }nd}d}| j                  j                  j                  | j                  j                  g}| j                  d   j                  }| j                  d   j                  }t        j                  r|J |J |j                  |v xrN |j                  dk(  xr= |xr9 | j                   j                  d      j                  |v xr | j!                          S )	a  
        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   A1r0   T)r   r   r   )r   r   pitchFromDegree	transposer   r=   r   r>   r?   r   r@   r(   r   r   r   r   r   )rC   raisedMinorCorrectlypreClosingsclosingPitchesr   r   s         r%   closesIncorrectlyz%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$   )NNNNN)
r=   $None | str | note.Note | pitch.Pitchr>   r  r?   r  r@   r  rD   zkey.Key | None)rd   r  re   z-t.Literal['_v1n1', '_v1n2', '_v2n1', '_v2n2'])returnzNone | note.Note)rd   r  r  bool)NFri   )1r   r   r   __doc__r+   __annotations__r3   rN   propertyr   setterrg   rj   ro   r=   rt   rv   r>   rx   rz   r?   r|   r~   r@   rB   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  __classcell__rF   s   @r%   r'   r'   L   s   	!I~ 	 04/3/3/3$(&",&" -&" -	&"
 -&" "&"PU6  , 	ZZ (- =.+ Hh - D+ Hh - D+ Hh - D+ Hh - D+ /4 Un*< H  %z% 
	z%x4lR"S";z0
f'1R2>2$>0-^/0::^@0d7Xr10r$   r'   c                      e Zd Zy)rW   Nr   r   r   r#   r$   r%   rW   rW   D      r$   rW   c                $   | j                  |j                               }i }t        |j                        D ]M  \  }}|j                         j	                  |d|      }|D ]!  }||v r||   j                  |       |g||<   # O t        |      S )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getElementsByOffsetr4   Verticality)	
music21ObjscoreObjectIsFromclassFilterListoffsetOfObjectcontentDictpartNumpartObjelementSelectionels	            r%   getVerticalityFromObjectr%  H  s    X  //0A0I0I0KLNK%&7&=&=>"??,@@INCR A T #B+%G$++B/(*tG$	 #	 ? {##r$   c                       e Zd ZU dZddiZded<   dd fdZd Zd Zd	 Z	d
 Z
d Zd Zd ZddZddZed        Zd ZdddZd Zd Z eeed      Zd Zd Zd Z eeed      Z xZS )r  ak  
    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>
    r   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        |   di | |i }|j                         D ]  \  }}t        |t              r|g||<    || _        y Nr#   )r2   r3   itemsrR   listr   )rC   r   rE   r!  elementrF   s        r%   r3   zVerticality.__init__  sV    $8$K + 1 1 3GWgt,(/yG$ !4 'r$   c                >    | j                         j                         S )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isConsonantrP   s    r%   r.  zVerticality.isConsonant  s    . }}**,,r$   c                ^   g }| j                   D ]u  }t        |t        j                        r-|j                  D ]  }|j                  |j                          Jt        |t        j                        se|j                  |       w t        j                  |      }| j                  |_	        |S )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>
        )
objectsrR   r   r   pitchesr4   rH   r   r`   style)rC   r1  r$  xchs        r%   r-  zVerticality.getChord  s     ,,B"ekk*ANN1#3#34 $B		*r"  [[!::	r$   c                B    | j                  | j                                y)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getShortestDurationrP   s    r%   makeAllSmallestDurationz#Verticality.makeAllSmallestDuration  s    " 	''(@(@(BCr$   c                B    | j                  | j                                y)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)r6  getLongestDurationrP   s    r%   makeAllLargestDurationz"Verticality.makeAllLargestDuration  s    " 	''(?(?(ABr$   c                f    t        | j                  D cg c]  }|j                   c}      S c c}w )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
        )minr0  rc   rC   objs     r%   r7  zVerticality.getShortestDuration  +     >#C%%>??>   .c                f    t        | j                  D cg c]  }|j                   c}      S c c}w )a  
        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
        )maxr0  rc   r>  s     r%   r:  zVerticality.getLongestDuration  r@  rA  c                4    | j                   D ]	  }||_         y)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)r0  rc   )rC   newQuarterLengthr?  s      r%   r6  z&Verticality.changeDurationOfAllObjects+  s    " <<C 0C  r$   c                \   t        j                  |      s|g}g }| j                  |   D cg c]  }||	 c}D ]G  }|dgk(  r|j                  |       |j                  j                  |      r7|j                  |       I t        |      dkD  r|S t        |      dk(  r|d   S yc c}w )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>
        Nr0   r   )r   
isIterabler   r4   classSet
isdisjointlen)rC   r!  r  retListr$  s        r%   getObjectsByPartzVerticality.getObjectsByPart?  s        1./O $ 0 0 9L 9"R^2 9LB4&(r"{{--o>NN2& M w<!N\Q1: Ms
   B)B)c                    t        j                  |      s|g}g }| j                  j                         D ]B  \  }}|D ]8  }||j                  j                  |      r!|r||vr(|j                  |       : D |S )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   rG  r   r)  rH  rI  r4   )rC   r  partNumsrK  partobjList	m21objects          r%   getObjectsByClasszVerticality.getObjectsByClass`  s    "   1./O!--335MD'$	$	(:(:(E(Eo(VD$8 NN9- % 6 r$   c                ~    g }| j                   j                         D ]  \  }}|D ]  }|j                  |         |S )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>]
        )r   r)  r4   )rC   rK  unused_partrP  rQ  s        r%   r0  zVerticality.objects  sD     $($4$4$:$:$< K$	y) % %= r$   c                .   ddl m}  |j                         }| j                  j	                         D ]  \  }} |j
                  d|       }|d   }|j                  t        j                        }|j                  t        j                        }|j                  t        j                        }	|r|j                  |       |r|j                  |       |	r|j                  |	       |D ]  }
|j                  d|
        |j                  |        |S )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   Scorer   r)  PartgetContextByClassr   Clefr   KeySignaturer   TimeSignaturer4   insert)rC   r   	retStreamr!  elementListpfoundObjclkstsr$  s              r%   	getStreamzVerticality.getStream  s    , 	# FLLN	$($4$4$:$:$< G[wi01A"1~H++DII6B++C,<,<=B++E,?,?@B!B "Q! %=" r$   T)	leftAlignc                   | j                   sy|r%t        | j                   d       d   j                  S t        | j                   d       d   j                  S )aA  
        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.
        r]   c                    | j                   S ri   offsetm21Objs    r%   <lambda>z2Verticality.getVerticalityOffset.<locals>.<lambda>      6==r$   r   r   c                    | j                   S ri   ri  rk  s    r%   rm  z2Verticality.getVerticalityOffset.<locals>.<lambda>  rn  r$   )r0  sortedrj  )rC   rf  s     r%   getVerticalityOffsetz Verticality.getVerticalityOffset  sL    F ||$,,,HI!LSSS$,,,HI"MTTTr$   c                J    t        | j                  d d      }||d   _        y )Nc                    | j                   S ri   ri  r3  s    r%   rm  z'Verticality._setLyric.<locals>.<lambda>      QXXr$   Tr   reverser   rq  r0  lyric)rC   rd   newLists      r%   	_setLyriczVerticality._setLyric  s!    +=tL 
r$   c                R    t        | j                  d d      }|d   j                  S )Nc                    | j                   S ri   ri  ru  s    r%   rm  z'Verticality._getLyric.<locals>.<lambda>  rv  r$   Trw  r   ry  )rC   r{  s     r%   	_getLyricz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'
        rq   c                     d| j                    S )NzcontentDict=)r   rP   s    r%   rN   zVerticality._reprInternal  s    d../00r$   c                j    || j                   _        | j                  D ]  }||j                   _         y ri   )r2  colorr0  )rC   r  r?  s      r%   	_setColorzVerticality._setColor  s'     

<<C#CIIO  r$   c                .    | j                   j                  S ri   )r2  r  rP   s    r%   	_getColorz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')]
    ri   )r   zdict | None)r   r   r   r
  r+   r  r3   r.  r-  r8  r;  r7  r:  r6  rL  rR  r  r0  re  rr  r|  r  rz  rN   r  r  r  r  r  s   @r%   r  r    s    : 	 !!I~ '-24D&C&@ @ 1(B>  )V 15 (UT!  Y	 0 E1$
  Y	 0 	Er$   r  c                  0     e Zd ZdZd fd	Zd Zd Z xZS )VerticalityNTupletz
    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        |   di | || _        t        |      | _        g | _        |r| j                          y y r(  )r2   r3   verticalitiesrJ  
nTupletNum	chordList_calcChordsrC   listOfVerticalitiesrE   rF   s      r%   r3   zVerticalityNTuplet.__init__  sC    $8$012 r$   c                    | j                   D ]M  }| j                  j                  t        j                  |j                  t        j                                     O y ri   )r  r  r4   r   r   rR  r   r`   )rC   vss     r%   r  zVerticalityNTuplet._calcChords  s<    $$BNN!!%++b.B.B499.M"NO %r$   c                     d| j                    S )NzlistOfVerticalities=)r  rP   s    r%   rN   z VerticalityNTuplet._reprInternal  s    %d&8&8%9::r$   r#   )r   r   r   r
  r3   r  rN   r  r  s   @r%   r  r  
  s    P;r$   r  c                  :     e Zd ZdZd fd	Zd ZddZddZ xZS )VerticalityTripletz-
    a collection of three Verticalities
    c                Z    t        |   |fi | i | _        |r| j                          y y ri   )r2   r3   tnlsDict	_calcTNLSr  s      r%   r3   zVerticalityTriplet.__init__(  s/    ,99NN r$   c                   t        t        t        | j                  d   j	                  t
        j                              t        | j                  d   j	                  t
        j                              t        | j                  d   j	                  t
        j                                          D ]  }t        | j                  d   j                  |t
        j                        | j                  d   j                  |t
        j                        | j                  d   j                  |t
        j                        g      | j                  |<    y)z`
        calculates the three note linear segments if only three Verticalities provided
        r   r0   r1   N)
ranger=  rJ  r  rR  r   r`   ThreeNoteLinearSegmentrL  r  )rC   r!  s     r%   r  zVerticalityTriplet._calcTNLS/  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                   || j                   v r| j                   |   j                         }ny|r+	 |xr& | j                   |   j                  j                  dk  }|rX| j                  d   j                         r;| j                  d   j                         s| j                  d   j                         ryy# t        t
        t        j                  f$ r Y {w xY w)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   r0   r1   T)
r  couldBePassingTonen2beatStrengthrI   	NameErrorr   Music21ObjectExceptionr  r.  rC   partNumToIdentifyunaccentedOnlyrets       r%   hasPassingTonez!VerticalityTriplet.hasPassingTone@  s    . --- 12EEGCVt}}->?BBOORUU NN1%113q)557NN1%113 #It/J/JK s   *B6 6CCc                B   || j                   v r| j                   |   j                         }ny|r+	 |xr& | j                   |   j                  j                  dk  }|xr | j                  d   j                          S # t        t
        t        j                  f$ r Y Bw xY w)a  
        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  r0   )
r  couldBeNeighborToner  r  rI   r  r   r  r  r.  r  s       r%   hasNeighborTonez"VerticalityTriplet.hasNeighborTonei  s    , --- 12FFHCVt}}->?BBOORUU :4>>!,88::: #It/J/JK s   *A= =BBr  )F)	r   r   r   r
  r3   r  r  r  r  r  s   @r%   r  r  $  s    "&R;r$   r  c                  N     e Zd ZdZd fd	Zed        Zd Z eed      Z xZ	S )NNoteLinearSegmenta\  
    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        |   di | g | _        |D ]  }|| j                  j                  d        !t	        |t
              r/| j                  j                  t        j                  |             `	 |j                  j                  t        j                  t        j                  g      s| j                  j                  |        y # t        t        f$ r | j                  j                  d        Y w xY wr(  )r2   r3   	_noteListr4   rR   rS   r   r`   rH  rI  r   ra   rI   r  )rC   noteListrE   rd   rF   s       r%   r3   zNNoteLinearSegment.__init__  s    $8$E}%%d+E3'%%dii&670 >>44dii5MN--e4  '	2 0NN))$/0s   ;AC*C?>C?c                     | j                   dd S )a9  
        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  rP   s    r%   r  zNNoteLinearSegment.noteList  s     ~~a  r$   c                    | j                   d d }| j                   dd  }g }t        ||d      D ]@  \  }}|r(|r&|j                  t        j                  ||             0|j                  d        B |S )Nrp  r0   T)strict)r  zipr4   r
   r5   )rC   tempListOnetempListTwomelodicIntervalListn1r  s         r%   _getMelodicIntervalsz'NNoteLinearSegment._getMelodicIntervals  sv    mmCR(mmAB' +{4@FBb#**8+<+<R+DE#**40	 A
 #"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>]
        rq   r  )
r   r   r   r
  r3   r  r  r  melodicIntervalsr  r  s   @r%   r  r    s;    	0 
! 
!	#   4 
; 
r$   r  c                      e Zd Zy)ThreeNoteLinearSegmentExceptionNr  r#   r$   r%   r  r    r  r$   r  c                      e Zd ZdZg dZd fd	Zd Zd Zd Zd Z	d Z
d	 Zd
 Z eeed      Z eee	d      Z ee
ed      Zd Zd Zd Z eed      Z eed      Z eed      Zd ZddZddZd Zd Zd ZddZddZ xZS )r  al  
    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                x    t        j                  |      rt        |   |fi | y t        |   |||gfi | y ri   )r   rG  r2   r3   )rC   noteListOrN1r  n3rE   rF   s        r%   r3   zThreeNoteLinearSegment.__init__  s<    \*G\6X6GlB3@x@r$   c                     | j                   d   S Nr   r  rP   s    r%   _getN1zThreeNoteLinearSegment._getN1
      }}Qr$   c                @    | j                  |      | j                  d<   y r  _correctNoteInputr  rn   s     r%   _setN1zThreeNoteLinearSegment._setN1      11%8ar$   c                     | j                   d   S Nr0   r  rP   s    r%   _getN2zThreeNoteLinearSegment._getN2  r  r$   c                @    | j                  |      | j                  d<   y r  r  rn   s     r%   _setN2zThreeNoteLinearSegment._setN2  r  r$   c                     | j                   d   S Nr1   r  rP   s    r%   _getN3zThreeNoteLinearSegment._getN3  r  r$   c                @    | j                  |      | j                  d<   y r  r  rn   s     r%   _setN3zThreeNoteLinearSegment._setN3  r  r$   c                   |y t        |t              rt        j                  |      S 	 |j                  j                  t        j                  t        j                  g      s|S y # t        $ r}t        d|      |d }~ww xY w)Nr^   )
rR   rS   r   r`   rH  rI  r   ra   rI   r  )rC   rd   rY   s      r%   r  z(ThreeNoteLinearSegment._correctNoteInput  sy    =s#99U##~~00$))U[[1IJ L! 56ui@s   :A& &	B/A>>BzF
        get or set the first note (left-most) in the segment
        rq   z;
        get or set the middle note in the segment
        zF
        get or set the last note (right-most) in the segment
        c                    | j                   r6| j                  r*t        j                  | j                   | j                        S y ri   )r  r  r
   r5   rP   s    r%   _getILeftToRightz'ThreeNoteLinearSegment._getILeftToRight7  s-    77tww$$TWWdgg66r$   c                     | j                   d   S r  r  rP   s    r%   	_getILeftz ThreeNoteLinearSegment._getILeft=      $$Q''r$   c                     | j                   d   S r  r  rP   s    r%   
_getIRightz!ThreeNoteLinearSegment._getIRight@  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    d| j                    d| j                   d| j                   S )Nzn1=z n2=z n3=r  r  r  rP   s    r%   rN   z$ThreeNoteLinearSegment._reprInternal]  s'    TWWIT$''$twwi88r$   c                ^    | j                   d uxr | j                  d uxr | j                  d uS ri   r  rP   s    r%   _isCompletez"ThreeNoteLinearSegment._isComplete`  s.    t#X$''*=XDGGSWDWXr$   c                h    | j                         sy| j                         xs | j                         S )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)r  r  r  rP   s    r%   r  z)ThreeNoteLinearSegment.couldBePassingToned  s1    ^ !224Z8X8X8ZZr$   c                   | j                         xr | j                  j                  j                  xr | j                  j                  j
                  dk(  xr | j                  j                  j
                  dk(  xrv | j                  j                  j
                  | j                  j                  j
                  z  dk(  xr0 | j                  j                  | j                  j                  z  dk(  S )aH  
        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
        r1   r   r0   )r  iLeftToRightr   r   iLeftr   iRightr   rP   s    r%   r  z1ThreeNoteLinearSegment.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                   | j                         xr | j                  j                  j                  dv xr | j                  j                  j                  dv xr | j                  j                  j                  | j                  j                  j                  z  dk(  xr` | j                  j
                  xrH | j                  j
                  xr0 | j                  j                  | j                  j                  z  dk(  S )as  
        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
        )r0   r1   r1   r0   )r  r  r   r   r  isChromaticStepr   rP   s    r%   r  z2ThreeNoteLinearSegment.couldBeChromaticPassingTone  s    4   " 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                h    | j                         sy| j                         xs | j                         S )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)r  r  r  rP   s    r%   r  z*ThreeNoteLinearSegment.couldBeNeighborTone  s0    ( !335\9Z9Z9\\r$   c                x   | j                         xr | j                  j                  | j                  j                  k(  xrz | j                  j
                  j                  dk(  xrU | j                  j
                  j                  dk(  xr0 | j                  j                  | j                  j                  z  dk(  S )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
        r1   rp  )	r  r  rH   r  r  	chromaticr   r  r   rP   s    r%   r  z2ThreeNoteLinearSegment.couldBeDiatonicNeighborTone  s       " C&&$''*@*@@C

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

$$t{{'<'<<B		Dr$   c                D   | j                         xr | j                  j                  | j                  j                  k(  xr` | j                  j
                  xrH | j                  j
                  xr0 | j                  j                  | j                  j                  z  dk(  S )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
        rp  )r  r  rH   r  r  r  r  r   rP   s    r%   r  z3ThreeNoteLinearSegment.couldBeChromaticNeighborTone  s       " K''477+A+AA JZZ//J[[00J jj**T[[-B-BBbH		Lr$   )NNNr  ) r   r   r   r
  
_DOC_ORDERr3   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rN   r  r  r  r  r  r  r  r  r  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r$   r  c                      e Zd Zy)NChordLinearSegmentExceptionNr  r#   r$   r%   r  r  	  r  r$   r  c                  &     e Zd Zd fd	Zd Z xZS )NObjectLinearSegmentc                2    t        |   di | || _        y r(  )r2   r3   
objectList)rC   r  rE   rF   s      r%   r3   zNObjectLinearSegment.__init__	  s    $8$$r$   c                     d| j                    S )NzobjectList=)r  rP   s    r%   rN   z"NObjectLinearSegment._reprInternal 	  s    T__-..r$   r  )r   r   r   r3   rN   r  r  s   @r%   r  r  	  s    %/r$   r  c                  6     e Zd Zd fd	Zed        Zd Z xZS )NChordLinearSegmentc                0   t        |   |fi | g | _        |D ]Y  }|| j                  j                  d        !	 |j                  j                  ddg      s| j                  j                  |       [ y # t        $ r}t        d|      |d }~ww xY w)Nr   Harmonyz!not a valid chord specification: )r2   r3   
_chordListr4   rH  rI  rI   r  )rC   r  rE   rd   rY   rF   s        r%   r3   zNChordLinearSegment.__init__%	  s    /h/E}&&t,	 >>44gy5IJ..u5  & 6;E9Es   8A88	BBBc                     | j                   dd 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)r  rP   s    r%   r  zNChordLinearSegment.chordList7	  s     q!!r$   c                     d| j                    S )Nz
chordList=)r  rP   s    r%   rN   z!NChordLinearSegment._reprInternalH	  s    DNN+,,r$   r  )r   r   r   r3   r  r  rN   r  r  s   @r%   r  r  $	  s!    $ " " -r$   r  c                  ,     e Zd Zd fd	Zd Zd Z xZS )TwoChordLinearSegmentc                    t        |t        t        f      r/|rt        |      dk7  rt	        d|      t        |   |fi | y t        |   ||gfi | y )Nr1   z/First argument must be a list of length 2, not )rR   r*  tuplerJ  
ValueErrorr2   r3   )rC   r  chord2rE   rF   s       r%   r3   zTwoChordLinearSegment.__init__L	  sa    i$/S^q0 Ei]S  GY3(3Gi0=H=r$   c                    t        j                  | j                  d   j                         | j                  d   j                               S )aE  
        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   r0   )r
   notesToChromaticr  rootrP   s    r%   rootIntervalz"TwoChordLinearSegment.rootIntervalV	  <     (():)?)?)A4>>RSCTCYCYC[\\r$   c                    t        j                  | j                  d   j                         | j                  d   j                               S )aE  
        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   r0   )r
   r  r  bassrP   s    r%   bassIntervalz"TwoChordLinearSegment.bassIntervala	  r  r$   )r#   N)r   r   r   r3   r  r  r  r  s   @r%   r  r  K	  s    >	]	]r$   r  TF)includeRestsincludeObliqueincludeNoMotionrx  c             #     K   | j                         j                  |      D ]  }|j                  |||      E d{      y7 w)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>
    ...
    )rx  )r  r  r  N)asTimespansiterateVerticalitiesgetAllVoiceLeadingQuartets)sr  r  r  rx  vs         r%   iterateAllVoiceLeadingQuartetsr  m	  sR     : ]]_11'1B//%)+ 0 
 	
 	
 C	
s   ;AAAc                      e Zd Zd Zd Zd Zy)Testc                    t                y)zA
        test instantiating an empty VoiceLeadingQuartet
        N)r'   rP   s    r%   testInstantiateEmptyObjectzTest.testInstantiateEmptyObject	  s
     	r$   c                2    ddl m}  || t                      y )Nr   )testCopyAll)music21.test.commonTestr  globals)rC   r  s     r%   testCopyAndDeepcopyzTest.testCopyAndDeepcopy	  s    7D')$r$   c                   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        ||||      }|j                         du sJ |j	                         du sJ |j                         du sJ |j                         du sJ |j                  t        j                  d	            du sJ |j                  t        j                  d
            du sJ t        ||||      }|j                         du sJ |j	                         du sJ |j                         du sJ |j                         du sJ t        ||||      }	|	j                         du sJ |	j                  t        j                  d	            du sJ t        ||||      }
|
j                  t        j                  d	            du sJ |
j                  t        j                  d            du sJ |
j                  t        j                  d            du sJ y )NC4D4E4G4r   C5TFr.   M3AA4)r   r`   r'   r   r   r   r   r   r
   r5   r   r   )rC   c4d4e4g4a4c5abcds              r%   test_unifiedTestzTest.test_unifiedTest	  s0   YYt_YYt_YYt_YYt_YYt_YYt_  BB/ D(((!T)))##%... E)))!!("3"3D"9:dBBB!!("3"3D"9:eCCCBB/zz|t###!U***##%... E)))BB/##%--- 1 1$ 78EAAABB/ 1 1$ 78D@@@ 1 1$ 78EAAA 1 1% 89UBBBr$   N)r   r   r   r  r  r1  r#   r$   r%   r  r  	  s    % Cr$   r  c                      e Zd Zy)TestExternalNr  r#   r$   r%   r3  r3  	  r  r$   r3  __main__ri   )r  zstream.Streamr  r	  r  r	  r  r	  rx  r	  r  z*Generator[VoiceLeadingQuartet, None, None])2r
  
__future__r   collections.abcr   enumtypingr   unittestr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r  rS   Enumr   Music21Objectr'   Music21ExceptionrW   r%  r  r  r  r  r  r  r  r  r  r  r  TestCaser  r3  r  r   mainTestr#   r$   r%   <module>r?     s  , # %               ?? *,& +dii u0$,, u0p'	<#@#@ 	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GT r$   