
    rht                       % S SK Jr  S SKrS SKrS SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S	 rS
 rS rS rSS jrSS jrS r\\\R0                  \R0                  \R0                  \R0                  4   \4   r0 rS\S'   0 rS\S'   0 rS\S'   0 rS\S'   S r S r!S r"S r#S r$\\\\/r% " S S\RL                  5      r'\(S:X  a  S SKr\RR                  " \'5        gg)    )annotationsN)pitch)stream)voiceLeading)opFrac)possibility)Music21Exceptionc                h   [        U 5      nU R                  [        R                  5      R                  5       n[	        [        U5      5       Vs/ s H2  nX#   R                  5       R                  S5      R                  5       PM4     nnUS   R                  [        R                  5      R                  5       R                  n[        UR                  5       5       Hd  u  pgUu  p[	        [        U5      5       HC  n
Xz   n[        R                  " U5      nX-
  Ul        SUl        XJ   R#                  X-   U5        ME     Mf     U HL  nUR%                  SSS9  US:w  d  M  US   R'                  5         U H  nU=R(                  S-  sl        M     MN     [        R*                  " U5      nU$ s  snf )	aP  
Takes in a :class:`~music21.stream.Stream` and returns a :class:`~music21.stream.Score`
of the :class:`~music21.stream.Stream` broken up into its voice leading moments.

>>> #_DOCS_SHOW score = corpus.parse('corelli/opus3no1/1grave').measures(1, 3)
>>> #_DOCS_SHOW score.show()

.. image:: images/figuredBass/corelli_grave.*
        :width: 700


>>> from music21.figuredBass import checker
>>> score = corpus.parse('bwv66.6') #_DOCS_HIDE
>>> vlMoments = checker.getVoiceLeadingMoments(score)
>>> #_DOCS_SHOW vlMoments.show()

.. image:: images/figuredBass/corelli_vlm.*
        :width: 700
GeneralNoter   NTF)inPlacecautionaryNotImmediateRepeatg           )extractHarmoniesgetElementsByClassr   PartrangelenflattengetElementsNotOfClassMeasurefirstpaddingLeftsorteditemscopydeepcopyquarterLengthtieinsertmakeNotationpadAsAnacrusisnumberScore)music21StreamallHarmoniesallPartsinewPartsr   offsetsnotes
initOffsetendTimegenNoteIndexmusic21GeneralNotenewGeneralNote	givenPartmnewScores                   U/home/james-whalen/.local/lib/python3.13/site-packages/music21/figuredBass/checker.pygetVoiceLeadingMomentsr4      sy   ( $M2L//<CCEHs8}-/-A ##%;;MJQQS-  /1+00@FFHTTK"<#5#5#78 '!#e*-L!&!4!]]+=>N+2+?N(!%N"))**BNS . 9 	t%P#aL'')A 	  ||H%HO%/s   9F/c                    U R                  [        R                  5      n[        U5      S:  a  [	        S5      e[        US   5      nUSS  H  n[        X#5      nM     U$ )a  
Takes in a :class:`~music21.stream.Stream` and returns a dictionary whose values
are the voice leading moments of the :class:`~music21.stream.Stream` and whose
keys are (offset, endTime) pairs delimiting their duration. The voice leading
moments are spelled out from the first or highest :class:`~music21.stream.Part`
to the lowest one.

>>> score = corpus.parse('corelli/opus3no1/1grave').measures(1, 3)
>>> #_DOCS_SHOW score.show()

.. image:: images/figuredBass/corelli_grave.*
        :width: 700


>>> from music21.figuredBass import checker
>>> allHarmonies = checker.extractHarmonies(score)
>>> for (offsets, notes) in sorted(allHarmonies.items()):
...    print('{0!s:15}[{1!s:23}{2!s:23}{3!s:22}]'.format(offsets, notes[0], notes[1], notes[2]))
(0.0, 1.5)     [<music21.note.Note C>  <music21.note.Note A>  <music21.note.Note F> ]
(1.5, 2.0)     [<music21.note.Note C>  <music21.note.Note A>  <music21.note.Note F> ]
(2.0, 3.0)     [<music21.note.Note B-> <music21.note.Note G>  <music21.note.Note G> ]
(3.0, 3.5)     [<music21.note.Note A>  <music21.note.Note F>  <music21.note.Note A> ]
(3.5, 4.0)     [<music21.note.Note A>  <music21.note.Note F>  <music21.note.Note B->]
(4.0, 6.0)     [<music21.note.Note G>  <music21.note.Note E>  <music21.note.Note C> ]
(6.0, 6.5)     [<music21.note.Note A>  <music21.note.Note F>  <music21.note.Note A> ]
(6.5, 7.0)     [<music21.note.Note B-> <music21.note.Note F>  <music21.note.Note A> ]
(7.0, 7.5)     [<music21.note.Note C>  <music21.note.Note F>  <music21.note.Note A> ]
(7.5, 8.0)     [<music21.note.Note C>  <music21.note.Note E>  <music21.note.Note A> ]
(8.0, 8.5)     [<music21.note.Note C>  <music21.note.Note D>  <music21.note.Note B->]
(8.5, 9.0)     [<music21.note.Note F>  <music21.note.Note D>  <music21.note.Note B->]
(9.0, 9.5)     [<music21.note.Note B-> <music21.note.Note D>  <music21.note.Note B->]
(9.5, 10.0)    [<music21.note.Note B-> <music21.note.Note G>  <music21.note.Note B->]
(10.0, 10.5)   [<music21.note.Note B-> <music21.note.Note E>  <music21.note.Note C> ]
(10.5, 11.0)   [<music21.note.Note B-> <music21.note.Note C>  <music21.note.Note C> ]
(11.0, 11.5)   [<music21.note.Note A>  <music21.note.Note F>  <music21.note.Note D> ]
(11.5, 12.0)   [<music21.note.Note A>  <music21.note.Note F>  <music21.note.Note A> ]
   z5There must be at least two parts to extract harmoniesr   r   N)r   r   r   r   r	   createOffsetMappingcorrelateHarmonies)r$   r&   r%   music21Parts       r3   r   r   F   s_    N //<H
8}qVWW&x{3L|),D $    c                    [         R                  " [        5      nU R                  5       R                   H2  nUR
                  nX2R                  -   nXU4   R                  U5        M4     U$ )aU  
Creates an initial offset mapping of a :class:`~music21.stream.Part`.

>>> from music21.figuredBass import checker
>>> score = corpus.parse('corelli/opus3no1/1grave').measures(1, 3)
>>> v0 = score[0]
>>> offsetMapping = checker.createOffsetMapping(v0)
>>> for (offsets, notes) in sorted(offsetMapping.items()):
...    print('{0!s:15}[{1!s:22}]'.format(offsets, notes[0]))
(0.0, 1.5)     [<music21.note.Note C> ]
(1.5, 2.0)     [<music21.note.Note C> ]
(2.0, 3.0)     [<music21.note.Note B->]
(3.0, 4.0)     [<music21.note.Note A> ]
(4.0, 6.0)     [<music21.note.Note G> ]
(6.0, 6.5)     [<music21.note.Note A> ]
(6.5, 7.0)     [<music21.note.Note B->]
(7.0, 8.0)     [<music21.note.Note C> ]
(8.0, 8.5)     [<music21.note.Note C> ]
(8.5, 9.0)     [<music21.note.Note F> ]
(9.0, 11.0)    [<music21.note.Note B->]
(11.0, 12.0)   [<music21.note.Note A> ]
)collectionsdefaultdictlistr   notesAndRestsoffsetr   append)r9   currentMappingr.   r+   r,   s        r3   r7   r7   v   sg    . !,,T2N)113AA'..
???G,-445GH B r:   c           
        0 n[        U R                  5       5       H  nUu  pEUR                  5       R                  R	                  XESSSSS9nX   nU H  nUn	Un
UR
                  U:  d  UR
                  n	UR
                  UR                  -   U:  d"  [        UR
                  UR                  -   5      n
[        R                  " U5      nUR                  U5        XX4'   M     M     U$ )a  
Adds a new :class:`~music21.stream.Part` to an existing offset mapping.

>>> from music21.figuredBass import checker
>>> score = corpus.parse('corelli/opus3no1/1grave').measures(1, 3)
>>> v0 = score[0]
>>> offsetMapping = checker.createOffsetMapping(v0)
>>> v1 = score[1]
>>> newMapping = checker.correlateHarmonies(offsetMapping, v1)
>>> for (offsets, notes) in sorted(newMapping.items()):
...    print('{0!s:15}[{1!s:23}{2!s:21}]'.format(offsets, notes[0], notes[1]))
(0.0, 1.5)     [<music21.note.Note C>  <music21.note.Note A>]
(1.5, 2.0)     [<music21.note.Note C>  <music21.note.Note A>]
(2.0, 3.0)     [<music21.note.Note B-> <music21.note.Note G>]
(3.0, 4.0)     [<music21.note.Note A>  <music21.note.Note F>]
(4.0, 6.0)     [<music21.note.Note G>  <music21.note.Note E>]
(6.0, 6.5)     [<music21.note.Note A>  <music21.note.Note F>]
(6.5, 7.0)     [<music21.note.Note B-> <music21.note.Note F>]
(7.0, 7.5)     [<music21.note.Note C>  <music21.note.Note F>]
(7.5, 8.0)     [<music21.note.Note C>  <music21.note.Note E>]
(8.0, 8.5)     [<music21.note.Note C>  <music21.note.Note D>]
(8.5, 9.0)     [<music21.note.Note F>  <music21.note.Note D>]
(9.0, 9.5)     [<music21.note.Note B-> <music21.note.Note D>]
(9.5, 10.0)    [<music21.note.Note B-> <music21.note.Note G>]
(10.0, 10.5)   [<music21.note.Note B-> <music21.note.Note E>]
(10.5, 11.0)   [<music21.note.Note B-> <music21.note.Note C>]
(11.0, 12.0)   [<music21.note.Note A>  <music21.note.Note F>]
F)	offsetEndincludeEndBoundarymustFinishInSpanmustBeginInSpanincludeElementsThatEndAtStart)
r   keysr   r?   getElementsByOffsetr@   r   r   r   rA   )rB   r9   
newMappingr)   r+   r,   notesInRangeallNotesSoFarr.   newInitOffset
newEndTimeallNotesCopys               r3   r8   r8      s    < J.--/0 '"**,::NN$u! O H '/".&M J%,,z9 2 9 9%,,/A/O/OORYY#$6$=$=@R@`@`$`a
99]3L 236B23 #/ 1$ r:   c           	        / nUSL a4  UR                  SUR                  -   5        UR                  S<S S35        [        [        [	        U 5      R                  5       5      5      nU R                  [        R                  5       Vs/ s H  ofR                  5       PM     nnU H  u  pU	 V
s/ s H  n
[        U
5      PM     nn
U" U5      nUS   nU HZ  nU H2  nUc  M  XS-
     R                  UUS	S
9S   nUUR                  l        M4     USL d  MB  UR                  U<S U< 35        M\     M     USL a5  [        U5      S:X  a  UR                  S5        U H  n[        U5        M     ggs  snf s  sn
f )aN  
Takes in a :class:`~music21.stream.Score` and a functionToApply which takes in a possibility
instance, a tuple with pitches or rests comprising a vertical sonority. Changes the color of
notes in the :class:`~music21.stream.Score` which comprise rule violations as determined by
functionToApply.


.. note:: Colored notes are NOT supported in Finale.

>>> music21Stream = corpus.parse('corelli/opus3no1/1grave').measures(1, 6)
>>> #_DOCS_SHOW music21Stream.show()

.. image:: images/figuredBass/corelli_grave2.*
        :width: 700


>>> from music21.figuredBass import checker
>>> functionToApply = checker.voiceCrossing
>>> checker.checkSinglePossibilities(music21Stream, functionToApply, debug=True)
Function To Apply: voiceCrossing
(Offset, End Time):      Part Numbers:
(16.0, 16.5)             (1, 2)
(16.5, 17.0)             (1, 2)

Voice Crossing is present in the fifth measure between the first and second voices,
and the notes in question are highlighted in the music21Stream.


>>> #_DOCS_SHOW music21Stream.show()

.. image:: images/figuredBass/corelli_voiceCrossing.*
        :width: 700
TFunction To Apply: z(Offset, End Time):25zPart Numbers:r   Nr   FrG   r6   No violations to report.)rA   __name__r   r>   r   r   r   r   r   r   generalNoteToPitchrJ   stylecolorr   print)r$   functionToApplyrY   debug	debugInfor%   pr&   r)   r*   nvlmvlm_violationsr+   partNumberTuple
partNumbernoteAlineInfos                     r3   checkSinglePossibilitiesrf      s   F I}.1I1IIJ17B7}EF$/>DDFGHL%2%E%Efkk%RS%R		%RHS(.34e!!$e4(-QZ
-O-
$$!^4HH""(- I / 012E ).EKK% . }  G>b>/1D!EF  .	 ) }y>Q78!H(O " ! T4s   E1.E6c           	        / nUSL a/  UR                  SUR                  -   5        UR                  S5        [        [        U 5      R	                  5       5      nU R                  [        R                  5       Vs/ s H  ofR                  5       PM     nnUS   u  pU	 V
s/ s H  n
[        U
5      PM     nn
US   nUSS  H  u  pU V
s/ s H  n
[        U
5      PM     nn
US   nU" X5      nU H  nU Hs  nUc  M  UUS-
     R                  XSS9R                  5       nUUS-
     R                  UUSS9R                  5       nUUR                  l        UUR                  l        Mu     USL d  M  UR                  U<S	 U<S	 U< 35        M     UnUnUnM     USL a5  [        U5      S
:X  a  UR                  S5        U H  n[        U5        M     ggs  snf s  sn
f s  sn
f )a#  
Takes in a :class:`~music21.stream.Score` and a functionToApply which takes in two consecutive
possibility instances, each a tuple with pitches or rests comprising a vertical sonority.
Changes the color of notes in the :class:`~music21.stream.Score` which comprise rule violations
as determined by functionToApply.


.. note:: Colored notes are NOT supported in Finale.

>>> music21Stream = corpus.parse('theoryExercises/checker_demo.xml')
>>> #_DOCS_SHOW music21Stream.show()

.. image:: images/figuredBass/checker_demo.*
        :width: 700


>>> from music21.figuredBass import checker
>>> functionToApply = checker.parallelOctaves
>>> checker.checkConsecutivePossibilities(music21Stream, functionToApply, debug=True)
Function To Apply: parallelOctaves
(Offset A, End Time A):  (Offset B, End Time B):  Part Numbers:
(1.0, 2.0)               (2.0, 3.0)               (2, 4)
(2.0, 3.0)               (3.0, 5.0)               (2, 4)
(8.0, 9.0)               (9.0, 11.0)              (1, 3)

Parallel octaves can be found in the first measure, between the first two measures,
and between the third and the fourth measure. The notes in question are highlighted
in the music21Stream, as shown below.


>>> #_DOCS_SHOW music21Stream.show()

.. image:: images/figuredBass/checker_parallelOctaves.*
        :width: 700
TrR   z>(Offset A, End Time A):  (Offset B, End Time B): Part Numbers:r   r   NFrT   rS   r6   rU   )rA   rV   r   r   r   r   r   r   r   rW   rJ   r   rX   rY   r   rZ   )r$   r[   rY   r\   r]   r%   r^   r&   previousOffsetspreviousNotesr_   vlmAinitOffsetAr)   r*   vlmBinitOffsetBra   rb   rc   rd   noteBre   s                          r3   checkConsecutivePossibilitiesro     s   J I}.1I1IIJYZ*=9??ABL%2%E%Efkk%RS%R		%RHS'3A$_+89=aq!=D9!!$K(,/45u!"1%u5aj(4-O-
$$Z!^4HH#% I IIN $Z!^4HH#[% I IIN (-EKK%(-EKK% . }  O#9b#9'BGZ![\  . "!% -( }y>Q78!H(O " 3 T9 6s   :G G
G"c                F   / n[        [        U 5      5       Hd  n X   nUR                    [        US-   [        U 5      5       H4  n X   nUR                    X5:  d  M  UR	                  US-   US-   45        M6     Mf     U$ ! [         a     Mw  f = f! [         a     M\  f = f)a  
Returns a list of (partNumberA, partNumberB) pairs, each representing
two voices which form a voice crossing. The parts from the lowest part to
the highest part (right to left) must correspond to increasingly higher
pitches in order for there to be no voice crossing. Comparisons between
pitches are done using pitch comparison methods, which are based on pitch
space values (see :class:`~music21.pitch.Pitch`).

>>> from music21.figuredBass import checker
>>> C4 = pitch.Pitch('C4')
>>> E4 = pitch.Pitch('E4')
>>> C5 = pitch.Pitch('C5')
>>> G5 = pitch.Pitch('G5')
>>> possibA1 = (C5, G5, E4)
>>> checker.voiceCrossing(possibA1)  # G5 > C5
[(1, 2)]
>>> possibA2 = (C5, E4, C4)
>>> checker.voiceCrossing(possibA2)
[]
r   )r   r   psAttributeErrorrA   )possibApartViolations
part1IndexhigherPitch
part2Index
lowerPitchs         r3   voiceCrossingry   ^  s    * NCL)
	!-KNN  
QG=J$0
 '%%zA~zA~&FG > *    		 " s#   BB
BB
B B PITCH_QUARTET_TO_BOOL_TYPEparallelFifthsTableparallelOctavesTablehiddenFifthsTablehiddenOctavesTablec                   [         R                  " X5      n/ n[        [        U5      5       GH  nX$   u  pV[        US-   [        U5      5       H  nX'   u  p [	        UR
                  UR
                  -
  5      S-  S:X  d  M5  [	        UR
                  U	R
                  -
  5      S-  S:X  d  M`   XXV4n
U
[        ;   a)  [        U
   nU(       a  UR                  US-   US-   45        [        R                  " U
6 nUR                  5       (       a"  UR                  US-   US-   45        S[        U
'   S[        U
'   M     GM     U$ ! [         a     GM  f = f)a8  
Returns a list of (partNumberA, partNumberB) pairs, each representing
two voices which form parallel fifths.


If pitchA1 and pitchA2 in possibA are separated by
a simple interval of a perfect fifth, and they move
to a pitchB1 and pitchB2 in possibB also separated
by the simple interval of a perfect fifth, then this
constitutes parallel fifths between these two parts.

>>> from music21.figuredBass import checker
>>> C3 = pitch.Pitch('C3')
>>> D3 = pitch.Pitch('D3')
>>> G3 = pitch.Pitch('G3')
>>> A3 = pitch.Pitch('A3')
>>> A4 = pitch.Pitch('A4')
>>> B4 = pitch.Pitch('B4')


Here, the bass moves from C3 to D3 and the tenor moves
from G3 to A3. The interval between C3 and G3, as well
as between D3 and A3, is a perfect fifth. These two
parts, and therefore the two possibilities, have
parallel fifths.


>>> possibA1 = (B4, G3, C3)
>>> possibB1 = (A4, A3, D3)
>>> checker.parallelFifths(possibA1, possibB1)
[(2, 3)]



Now, the tenor moves instead to F3. The interval between
D3 and F3 is a minor third. The bass and tenor parts
don't form parallel fifths. The soprano part forms parallel
fifths with neither the bass nor tenor parts. The
two possibilities, therefore, have no parallel fifths.


>>> F3 = pitch.Pitch('F3')
>>> possibA2 = (B4, G3, C3)
>>> possibB2 = (A4, F3, D3)
>>> checker.parallelFifths(possibA2, possibB2)
[]
r         TF)r   	partPairsr   r   absrq   rr   r{   rA   r   VoiceLeadingQuartetparallelFifth)rs   possibB	pairsListrt   
pair1IndexhigherPitchAhigherPitchB
pair2IndexlowerPitchAlowerPitchBpitchQuartethasParallelFifthsvlqs                r3   parallelFifthsr     sV   ` %%g7INC	N+
'0'<$
QI?J)2)>&[<??[^^;<rAQF<??[^^;<rAQF G
 (lQL22$7$E!$")):>:>*JK22LAC  ""%%zA~zA~&FG48#L105-' @ ,.  "    )E)E
EEc                   / n[         R                  " X5      nUS   u  pEUS   u  pg [        UR                  UR                  -
  5      S-  S:X  a  XgXE4nU[        ;   a.  [        U   n	U	(       a  UR                  S[        U5      45        U$ [        R                  " U6 n
U
R                  5       (       a%  UR                  S[        U5      45        S[        U'   S[        U'   U$  U$ ! [         a     U$ f = f)ay  
Returns a list with a (highestPart, lowestPart) pair which represents
a hidden fifth between shared outer parts of possibA and possibB. The
outer parts here are the first and last elements of each possibility.


If sopranoPitchA and bassPitchA in possibA move to a sopranoPitchB
and bassPitchB in possibB in similar motion, and the simple interval
between sopranoPitchB and bassPitchB is that of a perfect fifth,
then this constitutes a hidden octave between the two possibilities.

>>> from music21.figuredBass import checker
>>> C3 = pitch.Pitch('C3')
>>> D3 = pitch.Pitch('D3')
>>> E3 = pitch.Pitch('E3')
>>> F3 = pitch.Pitch('F3')
>>> E5 = pitch.Pitch('E5')
>>> A5 = pitch.Pitch('A5')


Here, the bass part moves up from C3 to D3 and the soprano part moves
up from E5 to A5. The simple interval between D3 and A5 is a perfect
fifth. Therefore, there is a hidden fifth between the two possibilities.


>>> possibA1 = (E5, E3, C3)
>>> possibB1 = (A5, F3, D3)
>>> checker.hiddenFifth(possibA1, possibB1)
[(1, 3)]


Here, the soprano and bass parts also move in similar motion, but the
simple interval between D3 and Ab5 is a diminished fifth. Consequently,
there is no hidden fifth.


>>> Ab5 = pitch.Pitch('A-5')
>>> possibA2 = (E5, E3, C3)
>>> possibB2 = (Ab5, F3, D3)
>>> checker.hiddenFifth(possibA2, possibB2)
[]


Now, we have the soprano and bass parts again moving to A5 and D3, whose
simple interval is a perfect fifth. However, the bass moves up while the
soprano moves down. Therefore, there is no hidden fifth.


>>> E6 = pitch.Pitch('E6')
>>> possibA3 = (E6, E3, C3)
>>> possibB3 = (A5, F3, D3)
>>> checker.hiddenFifth(possibA3, possibB3)
[]
r   r   r   r   TF)r   r   r   rq   r}   rA   r   r   r   hiddenFifthrr   )rs   r   rt   r   highestPitchAhighestPitchBlowestPitchAlowestPitchBr   hasHiddenFifthr   s              r3   r   r     s   n N%%g7I%.q\"]#,R= \},//12R71<(UL00!2<!@!"))1c'l*;<%%22LAC  %%q#g,&7826!,/.3l+!! ="      A$C( AC( (
C65C6c                   [         R                  " X5      n/ n[        [        U5      5       GH  nX$   u  pV[        US-   [        U5      5       H  nX'   u  p [	        UR
                  UR
                  -
  5      S-  S:X  d  M5  [	        UR
                  U	R
                  -
  5      S-  S:X  d  M`   XXV4n
U
[        ;   a)  [        U
   nU(       a  UR                  US-   US-   45        [        R                  " U
6 nUR                  5       (       a"  UR                  US-   US-   45        S[        U
'   S[        U
'   M     GM     U$ ! [         a     GM  f = f)a  
Returns a list of (partNumberA, partNumberB) pairs, each representing
two voices which form parallel octaves.


If pitchA1 and pitchA2 in possibA are separated by
a simple interval of a perfect octave, and they move
to a pitchB1 and pitchB2 in possibB also separated
by the simple interval of a perfect octave, then this
constitutes parallel octaves between these two parts.

>>> from music21.figuredBass import checker
>>> C3 = pitch.Pitch('C3')
>>> D3 = pitch.Pitch('D3')
>>> G3 = pitch.Pitch('G3')
>>> A3 = pitch.Pitch('A3')
>>> C4 = pitch.Pitch('C4')
>>> D4 = pitch.Pitch('D4')


Here, the soprano moves from C4 to D4 and the bass moves
from C3 to D3. The interval between C3 and C4, as well as
between D3 and D4, is a parallel octave. The two parts,
and therefore the two possibilities, have parallel octaves.


>>> possibA1 = (C4, G3, C3)
>>> possibB1 = (D4, A3, D3)
>>> checker.parallelOctaves(possibA1, possibB1)
[(1, 3)]


Now, the soprano moves down to B3. The interval between
D3 and B3 is a major sixth. The soprano and bass parts
no longer have parallel octaves. The tenor part forms
a parallel octave with neither the bass nor soprano,
so the two possibilities do not have parallel octaves.
(Notice, however, the parallel fifth between the bass
and tenor!)


>>> B3 = pitch.Pitch('B3')
>>> possibA2 = (C4, G3, C3)
>>> possibB2 = (B3, A3, D3)
>>> checker.parallelOctaves(possibA2, possibB2)
[]
r   r   r   TF)r   r   r   r   r   rq   rr   r|   rA   r   r   parallelOctave)rs   r   r   rt   r   r   r   r   r   r   r   hasParallelOctavesr   s                r3   parallelOctavesr   2  sV   ` %%g7INC	N+
'0'<$
QI?J)2)>&[<??[^^;<rAQF<??[^^;<rAQF G
 (lQL33%9,%G"%")):>:>*JK22LAC!!##%%zA~zA~&FG59$\216 .' @ ,.  " r   c                   / n[         R                  " X5      nUS   u  pEUS   u  pg [        UR                  UR                  -
  5      S-  S:X  a  XgXE4nU[        ;   a.  [        U   n	U	(       a  UR                  S[        U5      45        U$ [        R                  " U6 n
U
R                  5       (       a%  UR                  S[        U5      45        S[        U'   S[        U'   U$  U$ ! [         a     U$ f = f)aL  
Returns a list with a (highestPart, lowestPart) pair which represents
a hidden octave between shared outer parts of possibA and possibB. The
outer parts here are the first and last elements of each possibility.


If sopranoPitchA and bassPitchA in possibA move to a sopranoPitchB
and bassPitchB in possibB in similar motion, and the simple interval
between sopranoPitchB and bassPitchB is that of a perfect octave,
then this constitutes a hidden octave between the two possibilities.

>>> from music21.figuredBass import checker
>>> C3 = pitch.Pitch('C3')
>>> D3 = pitch.Pitch('D3')
>>> E3 = pitch.Pitch('E3')
>>> F3 = pitch.Pitch('F3')
>>> A5 = pitch.Pitch('A5')
>>> D6 = pitch.Pitch('D6')


Here, the bass part moves up from C3 to D3 and the soprano part moves
up from A5 to D6. The simple interval between D3 and D6 is a perfect
octave. Therefore, there is a hidden octave between the two possibilities.


>>> possibA1 = (A5, E3, C3)
>>> possibB1 = (D6, F3, D3)  # Perfect octave between soprano and bass.
>>> checker.hiddenOctave(possibA1, possibB1)
[(1, 3)]


Here, the bass part moves up from C3 to D3 but the soprano part moves
down from A6 to D6. There is no hidden octave since the parts move in
contrary motion.


>>> A6 = pitch.Pitch('A6')
>>> possibA2 = (A6, E3, C3)
>>> possibB2 = (D6, F3, D3)
>>> checker.hiddenOctave(possibA2, possibB2)
[]
r   r   r   r   TF)r   r   r   rq   r~   rA   r   r   r   hiddenOctaverr   )rs   r   rt   r   r   r   r   r   r   hasHiddenOctaver   s              r3   r   r     s   V N%%g7I%.q\"]#,R= \},//12R71<(UL11"4\"B""))1c'l*;<%%22LAC!!%%q#g,&7837"<0/4|,!! ="   r   c                >    U R                   (       a  U R                  $ g)a`  
Takes a :class:`~music21.note.GeneralNote`. If it is a :class:`~music21.note.Note`,
returns its pitch. Otherwise, returns the string "RT", a rest placeholder.

>>> n1 = note.Note('G5')
>>> c1 = chord.Chord(['C3', 'E3', 'G3'])

>>> figuredBass.checker.generalNoteToPitch(n1)
<music21.pitch.Pitch G5>
>>> figuredBass.checker.generalNoteToPitch(c1)
'RT'
RT)isNoter   )r.   s    r3   rW   rW     s       !'''r:   c                      \ rS rSrSrg)Testi   N)rV   
__module____qualname____firstlineno____static_attributes__r   r:   r3   r   r     s    r:   r   __main__)z#FF0000F)*
__future__r   r<   r   unittestmusic21r   r   r   music21.common.numberToolsr   music21.figuredBassr   music21.exceptions21r	   r4   r   r7   r8   rf   ro   ry   dicttuplePitchboolrz   r{   __annotations__r|   r}   r~   r   r   r   r   rW   
_DOC_ORDERTestCaser   rV   mainTestr   r:   r3   <module>r      s    #        - + 1(V-`>2p=@Hb&X "	%++u{{EKK
<=	  35 / 435 0 502 - 213 . 3JZNbJZBP&  6+-EG

	8 	 zT r:   