
    3js                     D   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dl	mZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ  G d dej&                        Z G d dej&                        Zedk(  rd dlZ ej.                  e       yy)    N)chord)Chord)	converter)key)m21ToXml)testPrimitive)note)pitch)scale)stream)tempo)tie)volumec                       e Zd ZdZd Zd Zy)TestExternalTc                 n    g dg dfD ]*  }t        |      }| j                  s|j                          , y )N)g2c4zc#6)cd-zf#g)r   show)self	pitchListas      D/DATA/.local/lib/python3.12/site-packages/music21/test/test_chord.py	testBasiczTestExternal.testBasic   s.    -02Ii Ayy	2    c           	      2   t        j                         }t        d      D ]  }g }t        t        j                  g d            D ]?  }t        j                  t        t        d                  }||vs/|j                  |       A t        |      }d|_        |j                  |j                         |j                  t        |j                        j                  dd             |j                  |        | j                  r|j                          y y )N   )                     r"     )r   Streamrangerandomchoicelistappendr   quarterLengthaddLyric
forteClassstr	primeFormreplacer   )r   sichordRawjpcr   s          r   testPostTonalChordsz TestExternal.testPostTonalChords   s    MMOrAH6==);<=]]4b	?3X%OOB' > hAAOJJq||$JJs1;;'//R89HHQK  99FFH r   N)__name__
__module____qualname__r   r   r;    r   r   r   r      s    Dr   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)Testc                 f    d}|D ]  }|t        |      dz   z  } |dt        |      dz
   }|dz  }|S )zK
        make tests for old-style pitch representation still work.
        [z, r      ])r3   len)r   listInoutps       r   pitchOutzTest.pitchOut1   sG     A3q6D= C !CHqL!s

r   c                    t        j                  g d      }t        j                  |      }t	        j
                  d      |j                  d   _        |j                  d   j                  j                  d       | j                  t        |      d       | j                  t        |      d       t        j                  ddg      }t        j                  |      }| j                  ||       | j                  |j                  d   |j                  d          | j                  |j                  d   j                  |j                  d   j                         t        j                         }|j                  |       t        j                  |      }| j                  ||       | j                  |j                  d   j                  d   |j                  d   j                  d          | j!                  |j                  d   j                  d   j                  |j                  d   j                  d   j                  u       y )	N)C4E-4G4sharpr      z <music21.chord.Chord C#4 E#4 G4>z<music21.chord.Chord C4 E-4 G4>zC#3E4)r   r   copydeepcopyr
   
Accidentalpitches
accidentalsetassertEqualreprassertIsNotr   r*   r/   notes
assertTrue)r   c1c2stream1stream2s        r   testMoreCopieszTest.testMoreCopies<   s   [[,-]]2#(#3#3G#<

1 


1  $$Q'b#EFb#DE[[%']]2R A

16A112::a=3K3KL--/r--('*q)11!4gmmA6F6N6Nq6QRa(003>>a(003>>? 	@r   c           	      %   t        j                         }d|_        d|_        t        j                         }t        j                         }| j	                  |t         j                         | j	                  |t         j                         t        j                         }d|_        d|_        t        j                         }d|_        d|_        t        j                  |||g      }| j                  |j                  d|      d       |j                  |       t        j                         }d	|_        d|_        t        j                  ||||g      }| j                  |j                  d        | j                  |j                  d        | j                  |j                         d
       | j                  |j!                         d
       | j                  |j                         d
       | j                  |j!                         d       t        j                         }	d|	_        d|	_        t        j                  ||||	g      }
| j                  |
j!                         d       | j                  |
j#                         d       t        j                         }d|_        d|_        t        j                  ||||g      }| j                  |j#                         d
       | j                  |j%                         d
       t        j                  ||||	|g      }| j                  |j%                         d       t        j                  ||	|g      }| j                  |j'                         d
       | j                  |
j'                         d       t        j                  |||g      }| j                  |j)                         d
       | j                  |j)                         d       | j                  |j)                         d       t        j                         }d|_        d|_        t        j                  |||g      }| j                  |j+                         d
       | j                  |j+                         d       t        j                         }d|_        d|_        t        j                  ||	||g      }| j                  |j-                         d
       | j                  |j-                         d       t        j                         }d|_        d|_        t        j                  ||||g      }| j                  |j/                         d
       | j                  |j/                         d       t        j                  |g      }| j                  |j!                         d       | j                  |j%                         d       t        j                         }d|_        d|_        t        j                  ||||	g      }|j                  |       | j                  |j!                         d       | j                  |j+                         d       t        j                  ||	||g      }| j                  |j                  d      d        | j                  |j1                  d      d
       | j                  |j3                         d
       | j5                  |j                  d      d        | j                  |j                         d
       | j                  |j!                         d       t        j                         }d|_        d|_        t        j                  ||	|g      }| j                  |j7                         d
       | j                  |j7                         d       t        j                  ||||g      }| j                  |j9                         d
       | j                  |j9                         d       | j                  |j;                         j                  d       | j                  |j=                         d       | j                  |j?                         d       t        j                         }d|_        d|_        t        j                  |||g      }| j                  |j=                         d       t        j                  |||g      }|j                  |       | j                  |j=                         d       t        j                         } d| _        d| _        t        j                  || |g      }!| j                  |!j=                         d       | j                  |!j?                         d       t        j                         }"d|"_        d|"_        t        j                  |||"g      }#| j                  |#j                         j                  |j                         | j                  |#j=                         d       | j                  |#j?                         d       t        j                  ||"g      }$|$j                  |"       t        j                  |||g      }%| j                  |%j                         j                  d       t        j                         }&d|&_        d|&_        t        j                         }'d|'_        d|'_        t        j                  ||&|'g      }(| j                  |(j                         j                  d       | j                  |(j?                         d       t        j                  ||&|'|g      })| j                  |)j                         j                  d       t        j                         }*d|*_        d|*_        t        j                         }+d|+_        d|+_        t        j                  |g      },| j                  |,j                         j                  d       t        j                  ||+g      }-| j                  |-j                         j                  d       t        j                         }.d|._        d|._        t        j                  ||	|.g      }/| j                  |/j                         j                  d       t        j                  ||	|.|g      }0| j                  |0j                         j                  d       t        j                  | |"|.|*g      }1| j                  |1j                         j                  d       t        j                         }2d|2_        d|2_        t        j                         }3d|3_        d|3_        t        j                         }d	|_        d|_        t        j                  ||	|.||2g      }4| j                  |4j                         j                  d       t        j                  ||	|.||2|3g      }5| j                  |5j                         j                  d       t        j                  ||	|.||2|3|g      }6| j                  |6j                         j                  |j                         t        j                  ||	|.|g      }7| j                  |7j;                         j                  d       | j                  |7j                         j                  d       | j                  |7j?                         d       t        j                         }8d|8_        t        j                         }9d|9_        t        j                         }:d|:_        t        j                         };d|;_        t        j                  ||	|.|8|:||;g      }<|<j                  |       | j                  |<j9                         d       | j                  |<j/                         d       | j                  |<jA                         d       t        j                  ||8|;|9g      }=| j                  |=jA                         d
       t        j                  ||3||:|g      }>|>jC                         }?| j                  |?jD                  d   j                  d       | j                  |?jD                  d   j                  d       | j                  |?jD                  d   j                  d       | j                  |?jD                  d   j                  d       | j                  |?jD                  d   j                  d	       |>jG                         }@| j                  |@jD                  d   j                  d       | j                  |@jD                  d   j                  d       | j                  |@jD                  d   j                  d       | j                  |@jD                  d   j                  d       | j                  |@jD                  d   j                  d	       |>jI                         }A| j                  |AjD                  d   j                  d       | j                  |AjD                  d   j                  d       | j                  |AjD                  d   j                  d       | j                  |AjD                  d   j                  d       | j                  |AjD                  d   j                  d	       y )NE-r#   Cr"   Gr!   )testRootFzA-TEBzG-zB-zB--zC#rD   zG#+   r   rP   r$   *   FADr%   zF--zA#F#)%r	   NotenameoctaveassertIsInstancer
   Pitchr   r   rZ   getChordSteprootthirdfifthrX   containsTriadisTriadcontainsSeventh	isSeventhisMajorTriadisMinorTriadisDiminishedTriadisDominantSeventhisDiminishedSeventhhasRepeatedChordStephasAnyRepeatedDiatonicNoteassertIsisAugmentedTriadisHalfDiminishedSeventhbass	inversioninversionNameisFalseDiminishedSeventhsortAscendingrU   sortChromaticAscendingsortFrequencyAscending)Br   	highEFlatr   bmiddleClowGchord1	highAFlatchord2middleEchord3middleBchord4chord5chord6chord7lowGFlatchord8middleBFlatchord9middleBDoubleFlatchord10chord11middleCSharpchord12chord13	lowGSharpchord14chord15lowCchord16chord17lowEchord18lowBFlatchord19chord20chord21middleFlowAchord22chord23highChighEchord24chord25middleGchord26chord27chord28highDhighFchord29chord30chord31chord32middleFDblFlatmiddleAmiddleASharpmiddleFSharpchord33chord34scrambledChord1unscrambledChord1unscrambledChord2unscrambledChord3sB                                                                     r   testConstructionzTest.testConstructionR   s   IIK			IIKIIKa+a+))+{{}	i$78,,Q,A5IGIIK			gy$	BCt,t,--/6)40--/6)51))+gy$@A)51//159))+gy$@A//148))+T2gy$IJ))+U3gw56,,.5,,.6gy$78,,.5,,.6,,.699;gy(;<113T:113U;iikgwkBC113T:113U; IIK!&#$ ++w	8=NOP 	446=335u=++wi(*E2**,e4yy{ ++wdGDEW*E2224e<++wx@A--a0$755a8$?;;=tDg**1-t4..0$7*E2IIK			++w;<113T:002E:++w	8[IJ88:DA88:EB,,d3**,a0..0"5yy{	++tWi89**,a0++tWi89W**,a0yy{	++wh78**,a0..0!499;++w	8<=,,gll;**,a0..0"5 ++tX./X++w	8<=,,c2))+yy{	++w67,,c2..0!4++wyAB,,c2		
		
++wi(,,c2++w./,,c2))+++w9:,,c2++w+FG,,c2++tXw>?,,c2		
		
IIK			++w+uMN,,c2++w+ueTU,,c2++w+ueU^_` 	,,gll;++w'BC,,c2,,c2..0!4#))+yy{ yy{ ++w.+->N OW88:EB446>99;UC++wgNO99;TB++y%,Pa&bc+99;*2215::C@*2215::DA*2215::EB*2215::C@*2215::DA+BBD*2215::C@*2215::EB*2215::DA*2215::C@*2215::DA+BBD*2215::C@*2215::EB*2215::DA*2215::C@*2215::DAr   c                    t        j                  d      }| j                  |j                  j                  d       t        j                  g d      }| j                  |j                  D cg c]  }|j                   c}g d       | j                  |j                  D cg c]  }|j                   c}g d       y c c}w c c}w )N?   rc   );   r   B   )rh   zD#rn   )TTT)	r	   ro   rX   r
   rp   r   r   rU   spellingIsInferred)r   eFlatbMajorrI   s       r   testEnharmonicSimplificationz!Test.testEnharmonicSimplificationm  s    		"))40\*&..9.Q!&&.9;LMG1!..GI[\ :Gs   ,C "Cc                    t        j                  d      }d|j                  _        t	        j
                  |g      }| j                  |j                  j                  d       t        j                  d      }d|j                  _        t	        j
                  ||g      }| j                  |j                  j                  d       t	        j
                  ||g      }| j                  |j                  j                  d       t	        j
                  ||gd      }| j                  |j                  j                  d       y )NrL   quarterD4halfwhole)type)r	   ro   durationr   r   r   rX   )r   Cqchord35Dhchord36chord37chord38s          r   testDurationszTest.testDurationst  s    YYt_$++rd#))..	:YYt_!++r2h'))..	:++r2h'))..7++r2hW5))..8r   c                     t        g d      }| j                  |j                                | j                  |j	                                t        dg      }| j                  |j	                                y )N)C#4rQ   rN   rL   )r   r\   r~   assertFalser|   r   r   r   s      r   testShortCutszTest.testShortCuts  s[    *+0023,,./v,,./r   c                     t        j                  g d      }|j                         }| j                  t	        |      d       y )N)r   G5E6z<music21.chord.Chord C#4 E4 G4>)r   r   closedPositionrX   rY   r   s      r   testClosedPositionzTest.testClosedPosition  s4    01&&(f'HIr   c                 $   t        g d      }| j                  |j                  g d       | j                  |j                  d       | j                  |j                  g d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                  g d       | j                  |j                  d       | j                  |j                  g d       | j                  |j                  g d       | j                  |j                         | j                  |j                         | j                  |j                  t        g d	                   | j                  |j                   d
       y )N)r   rP   r!   r$   r&   	   r'   )r   rP   r!   r$   r&   r   r   r%   )r   rP   r!   r$   r&   r   r$   z6-29   )rD   rD   r"   rD   r!   rD   )r   rP   r"   r$   r%   r   zcombinatorial RI (RI9))r   rX   pitchClassesmultisetCardinalityorderedPitchClassespitchClassCardinalityr2   normalOrderforteClassNumberr4   intervalVectorr   isPrimeFormInversionr\   hasZRelationareZRelations
commonNamer   r]   s     r   testPostTonalChordsAzTest.testPostTonalChordsA  s&   )**?@//3//1CD1115/);<,,b1'9:**,>?001(((/A)BCD(@Ar   c                     t        g d      }| j                  |j                  d       | j                  |j                  d       y )N)rP   r"   r%   
   zdiminished seventh chordzA#-diminished seventh chord)r   rX   r   pitchedCommonNamer   s     r   testPostTonalChordsBzTest.testPostTonalChordsB  s8    =!(BC--/LMr   c                    t        j                  g d      }t        j                         }|j	                  t        j                  d             |j	                  |       | j                  t        |j                        d       t        j                         }|j	                  t        j                  d             |j	                  |       |j                  }| j                  t        |      d       t        j                         }|j	                  t        j                  d             t        j                  g d      }|j	                  |       |j                  }| j                  t        |      d       y )	NC#5zE#5zG#5c#=[(1, None), (3, <music21.pitch.Accidental sharp>), (5, None)]r   |[(1, <music21.pitch.Accidental sharp>), (3, <music21.pitch.Accidental double-sharp>), (5, <music21.pitch.Accidental sharp>)]rd   )rL   r   r   rM   rQ   F4zy[(1, None), (1, <music21.pitch.Accidental sharp>), (2, None), (3, <music21.pitch.Accidental flat>), (3, None), (4, None)])
r   r   r   r*   r/   r   KeyrX   rY   scaleDegrees)r   r   st1st2sd2st3r   sd3s           r   testScaleDegreesAzTest.testScaleDegreesA  s   23mmo

3774=!

6f112X	Z mmo

3773< 

6!!cD	E
 mmo

3773< CD

6!!cY	Zr   c                 ~   t        g d      }t        j                         }|j                  t	        j
                  d             |j                  |       | j                  |j                  |       | j                  t        |j                        d       t        j                         }|j                  t	        j
                  d             |j                  |       | j                  |j                  |       | j                  |j                  |       | j                  t        |j                        d       y )Nr  r  r  r   r  )r   r   r*   r/   r   r	  rX   
activeSiter3   r
  assertNotEqual)r   r   r  r  s       r   testScaleDegreesBzTest.testScaleDegreesB  s    ,-mmo

3774=!

6**C0V001X	Z mmo

3773< 

6F--s3 	**C0 	##$e	
r   c                 
   t        j                  g d      }| j                  |j                  d        t        j                         }t        j                         }||j
                  d   _        | j                  |j                  |       ||_        | j                  t        |j                        t        |             | j                  t        |j
                  d   j                        t        |             | j                  t        |j
                  d   j                        t        |             | j                  t        |j
                  d   j                        t        |             t        j                         }t        j                         }t        j                         }|j                  ||j                  d          |j                  ||j                  d          |j                  ||j                  d          | j                  t        |j                  |j                  d               t        |             | j                  t        |j                  |j                  d               t        |             | j                  t        |j                  |j                  d               t        |             t        j                  t        j                        }|j                         j                  t         j                        }| j                  |d   j                  t!        j"                  d            j$                  d       | j                  |d   j                  t!        j"                  d            d        | j                  |d   j                  t!        j"                  d            d        | j                  |d   j                  t!        j"                  d            j$                  d	       | j                  |d   j                  t!        j"                  d
            d        | j                  |d   j                  t!        j"                  d            j$                  d	       | j                  |d   j                  t!        j"                  d            j$                  d       | j                  |d   j                  t!        j"                  d            d        t'        j(                         }	|	j                  |      j+                  d      }
|
j-                  dd      }
|
j-                  dd      }
| j/                  |
j1                  d      dk7  |
       y )N)r   dr   r   rP   rD   a4startc5f4continueg5zutf-8r(   r)   
z<pitch><step>A</step><octave>4</octave></pitch><duration>15120</duration><tietype="start"/><type>quarter</type><dot/><stem>up</stem><notations><tiedtype="start"/></notations>)r   r   rX   r   Tie_notesidsetTierU   getTier   parser   chordIndependentTiesflattengetElementsByClassr
   rs   r   r   GeneralObjectExporterdecoder5   r\   find)r   r]   t1t2t3t4t5r6   chordsGEXrH   s              r   	testTiesAzTest.testTiesA  s   [[) 	&WWYWWY		!$BFFRV,BIIaL,,-r"v6BIIaL,,-r"v6BIIaL,,-r"v6 WWYWWYWWY
		"bjjm$
		"bjjm$
		"bjjm$BIIbjjm45r"v>BIIbjjm45r"v>BIIbjjm45r"v>OOM>>?//<))%++d*;<AA7K))%++d*;<dC))%++d*;<dC))%++d*;<AA:N))%++d*;<dC))%++d*;<AA:N))%++d*;<AA7K))%++d*;<dC ,,.iil!!'*kk#r"kk$# "P Q UWW 		r   c                 ^   t        j                         }t        j                         }t	        d      D ]w  }t        t	        |dz               }|j                  ddd      }|D ]4  }|j                  t        j                  d      |j                  |          6 |j                  |       y y )Nr%   rP   r   r  )r0   r  )r   WholeToneScaler   r*   r+   r.   getChordr"  r   r  rU   r/   )r   scr6   r7   tiePosr   poss          r   	testTiesBzTest.testTiesB  s    !!#MMOqA%A,'FD$a8A)199S>: HHQK r   c                    t        ddg      }|j                  d   }|j                  d|       | j                  |j                  d   j
                         | j                  |j                  d   j
                  j                  d       y )Nr   rP   r  r   )r   rU   r"  assertIsNoner   r   rX   r   )r   r^   secondD4s      r   	testTiesCzTest.testTiesC&  sk    D$< ::a=
		'8$"))A,**+1))..8r   c                 V    t        ddg      }| j                  |j                  d       y )Nr   ze-minor)r   rX   qualityr   s     r   testChordQualityzTest.testChordQuality-  s$    C;W-r   c                 F   t        ddg      }|j                  t        j                  d      t        j                  d      g       | j	                  |j                                | j                  |j                                | j                  |j                         y )Nzg#r   `   velocity)
r   
setVolumesr   Volumer\   hasComponentVolumesr   hasVolumeInformationr;  _volume)r   r   s     r   testVolumeInformationzTest.testVolumeInformation1  sq    4,	fmmR0&--2LMN--/0//12!))$r   c                 @   t        g d      }t        j                  d      }t        j                  d      }t        j                  d      }|j                  |d       |j                  |d       |j                  |d       | j	                  |j                  d      j                  d       | j	                  |j                  d      j                  d       | j	                  |j                  d      j                  d       | j	                  |j                  d      j                  |       | j	                  |j                  d      j                  |       | j	                  |j                  d      j                  |       t        j                  |      }| j	                  |j                  d      j                  d       | j	                  |j                  d      j                  d       | j	                  |j                  d      j                  d       | j	                  |j                  d      j                  |       | j	                  |j                  d      j                  |       | j	                  |j                  d      j                  |       y )	Nr   d-4g4o   rD  b   I   r   rN  rO  )
r   r   rG  	setVolumerX   	getVolumerE  clientrR   rS   )r   r   v1v2v3cCopys         r   testVolumePerPitchAzTest.testVolumePerPitchA9  s   %&]]C(]]B']]B'	B	B	BT*33S9U+44b9T*33R8T*1115U+22A6T*1115a .77=/88"=.77< 	.55u=/66>.55u=r   c                 p   t        j                         }g d}t        d      D ]G  }t        g d      }t	        |      D ]  \  }}||   |j
                  _         |j                  |       I g }|D ].  }|D ]'  }|j                  |j
                  j                         ) 0 | j                  |g d       y )N)皙?      ?rP   r'   )c3rN  r  )$   @      r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  r_  r`  ra  )
r   r*   r+   r   	enumerater   velocityScalarr/   rE  rX   )r   r6   ampsr9   r   r7   submatchs           r   testVolumePerPitchBzTest.testVolumePerPitchBV  s    MMOrA)*A#A,3,0G

) 'HHQK	 
 ASZZ001   	 !M 	Nr   c           	      T   t        g d      }d|j                  _        t        j                         }|j                  t        j                  dd             g d}dD ]  }t        j                  |      }|1||j                  _        | j                  |j                                ngt        j                  |       |j!                  |D cg c]  }t        j"                  |       c}       | j%                  |j                                |j'                  |        y c c}w )	N)zf-2za-2zc-3f-3g3b-3rN  ze-4r]  rD   2   )referentnumber)r\  g?g333333?g?r]  g333333?gffffff?g?)Xr]  r]  r]  r]  r]  r]  r]  r]  r]  rP   r]  rP   r]  r]  r]  r]  r]  rP   r]  r]  rP   r]  r]  r]  rP   r]  r]  r]  r]  rP   r]  r]  NNNNNNNNNNNNNNNNr]  r]  r]  r]  r]  rP   r]  rP   r]  r]  r]  r]  r]  rP   r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  r]  )rc  )r   r   r0   r   r*   insertr   MetronomeMarkrR   rS   r   rc  r   rH  r,   shufflerF  rG  r\   r/   )r   r   r6   rd  accentcNewxs          r   testVolumePerPitchCzTest.testVolumePerPitchCf  s    IJ#&

 MMO	$$a;<7F ==#D!-3*  !9!9!;<t$$ O$Qa!@$ OP 8 8 :;HHTN)$ !Ps   D%
c                 ,   t        g d      }d|j                  _        | j                  |j                  j                  d       | j	                  |j                                |j                  dD cg c]  }t        j                  |       c}       | j                  |D cg c]  }|j                  j                   c}g d       | j                  |j                                | j                  |j                  j                  d       | j                  |j                                | j                  |D cg c]  }|j                  j                   c}g d       d|j                  _        | j                  |j                  j                  d       | j                  |j                                | j                  |D cg c]  }|j                  j                   c}g d       t        j                  d      |_        | j                  |j                  j                  d       | j	                  |j                                |j                  dD cg c]  }t        j                  |       c}       | j                  |D cg c]  }|j                  j                   c}g d       | j                  |j                                | j                  |j                  d        y c c}w c c}w c c}w c c}w c c}w c c}w )	N)ri  rj  rk  y   )r    <   Z   rD  rx  ra     )r   rz  r    )
r   r   rE  rX   r   rH  rF  rG  r\   rJ  )r   r   rt  s      r   testVolumePerPitchDzTest.testVolumePerPitchD  s=   &'**C0..01	FAfmmQ/FGQ7Q!((++Q7F--/0**B/--/0Q7Q!((++Q7F  **C0--/0Q7Q!((++Q7F=="-**B/..01	FAfmmQ/FGQ7Q!((++Q7F--/0D)1 G7 8 8 G7s$   3K8&K= LL"LLc                    t        g d      }| j                  t        |d   j                        d       | j                  t        |d   j                        d       | j                  t        |d   j                        d       | j                  t        |d         d       | j                  t        |d	         d       | j                  t        |d
         d       | j                  t        |d         d       | j                  t        |d         d       | j                  t        |d         d       d|d   _        d|d   _        d|d   _        | j                  |d   j                  d       | j                  |d   j                  d       | j                  |d   j                  d       | j                  |D cg c]  }|j
                  j                   c}g d       t        j                  |      }| j                  |D cg c]  }|j
                  j                   c}g d       g d}t        |      D ]  \  }}||   |j
                  _         | j                  |D cg c]  }|j
                  j                   c}g d       | j                  |D cg c]  }|j
                  j                   c}g d       | j                  |D cg c]  }|j
                  j                   c}|||g       | j                  |D cg c]  }|j
                  j                   c}|||g       y c c}w c c}w c c}w c c}w c c}w c c}w )NrM  r   rL   rP   zD-4rD   rN   z0.pitchz1.pitchz2.pitchz0.volumez%<music21.volume.Volume realized=0.71>z1.volumerz  P   x   z2.volume)rz  r}  r~  )      !   )
r   rX   r3   r
   rE  r   rR   rS   rb  rU  )r   r   rt  rY  
velocitiesr7   s         r   testGetItemAzTest.testGetItemA  s   %&QqTZZ$/QqTZZ%0QqTZZ$/Qy\*D1Qy\*E2Qy\*D1 	Qz]+-TUQz]+-TUQz]+-TU!#*!#*!$*://4://4://5Q7Q!((++Q7Ga U;U!((++U;]K!
e$DAq *1AHH %U;U!((++U;\JQ7Q!((++Q7G595a!((//59E5%;PQ151a!((//151ayA 8; <795s$   L<M0M&MMMc                 B   t        g d      }t        j                         }|D ]  }|j                  |        | j	                  t        |j                        d       | j	                  |j                  d       | j	                  t        |j                        d       y )N)d2ze-1zb-6r!   g       @zP[<music21.pitch.Pitch D2>, <music21.pitch.Pitch E-1>, <music21.pitch.Pitch B-6>])
r   r   r*   r/   rX   rF   r[   highestOffsetr3   rU   )r   r   r6   ns       r   testChordComponentsAzTest.testChordComponentsA  sv    &'MMOAHHQK QWWq)#.		N^	`r   c                     t        j                  g d      }| j                  |j                         d       |j                  d       | j                  t	        |      d       y )N)rO  b4d5f5r   rP   z!<music21.chord.Chord B4 D5 F5 G5>)r   r   rX   r   rY   )r   r   s     r   testInvertingSimplezTest.testInvertingSimple  sG    KK01*	Aa"EFr   c                 h    t        d      }t        j                  |      }| j                  ||       y )NC4 E4 G4)r   rR   rS   rX   )r   chch2s      r   testDeepcopyChordzTest.testDeepcopyChord  s*    :mmBS!r   c                     t        d      }|j                         }|j                          |j                  |       | j	                  |j                         j
                  d       y)zJ
        Test that bass and root caches invalidate after removal.
        r  rg   N)r   ru   r   removerX   rp   )r   r  rs      r   testNewBassAfterRemovezTest.testNewBassAfterRemove  sG     :GGI
	
		!-r   c                     d}| j                  t        |      5  t        t        j                         g       d d d        y # 1 sw Y   y xY w)NzQUse a PercussionChord to contain Unpitched objects; got \[<music21.note.Unpitched)assertRaisesRegex	TypeErrorr   r	   	Unpitched)r   msgs     r   testChordCannotContainUnpitchedz$Test.testChordCannotContainUnpitched  s5    b##Is34>>#$% 433s   AA
c                     t        j                  d      }| j                  |j                                |j	                  dd       | j                  |j                                y )Nr  r  F)runSort)r   r   r\   isConsonantaddr   )r   r  s     r   testCacheClearedOnAddzTest.testCacheClearedOnAdd  sH    [[$()
ue$)*r   N)r<   r=   r>   rJ   ra   r   r   r   r   r   r   r  r  r  r2  r9  r=  rA  rK  rZ  rg  ru  r{  r  r  r  r  r  r  r  r?   r   r   rA   rA   /   s    	@,YBv]9&0J
B N
Z4
:9v9.%>:N 8*BB<	`G"
.&+r   rA   __main__)rR   r,   unittestmusic21r   music21.chordr   r   r   music21.musicxmlr   r   r	   r
   r   r   r   r   r   TestCaser   rA   r<   mainTestr?   r   r   <module>r     s~           % *       8$$ 6@+8 @+F zGT r   