
    rhl                      S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSK	r
SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \
R,                  (       a  SSKJr  \R0                  " S5      rSS. GSS jjrSS. GSS jjr " S S\R8                  5      r " S S\5      r " S S\5      r " S S\5      r  " S S\5      r! " S S\5      r" " S  S!\5      r# " S" S#\5      r$ " S$ S%\5      r% " S& S'\%5      r& " S( S)\%5      r' " S* S+\%5      r( " S, S-\%5      r) " S. S/\5      r* " S0 S1\5      r+ " S2 S3\+5      r, " S4 S5\+5      r- " S6 S7\+5      r. " S8 S9\+5      r/ " S: S;\+5      r0 " S< S=\+5      r1 " S> S?\15      r2 " S@ SA\15      r3 " SB SC\15      r4 " SD SE\15      r5 " SF SG\15      r6 " SH SI\+5      r7 " SJ SK\+5      r8 " SL SM\+5      r9 " SN SO\+5      r: " SP SQ\+5      r; " SR SS\+5      r< " ST SU\+5      r= " SV SW\5      r> " SX SY\>5      r? " SZ S[\?5      r@ " S\ S]\?5      rA " S^ S_\?5      rB " S` Sa\?5      rC " Sb Sc\?5      rD " Sd Se\?5      rE " Sf Sg\>5      rF " Sh Si\>5      rG " Sj Sk\>5      rH " Sl Sm\H5      rI " Sn So\>5      rJ " Sp Sq\J5      rK " Sr Ss\>5      rL " St Su\L5      rM " Sv Sw\L5      rN " Sx Sy\L5      rO " Sz S{\L5      rP " S| S}\>5      rQ " S~ S\>5      rR " S S\5      rS " S S\S5      rT " S S\S5      rU " S S\S5      rV " S S\V5      rW " S S\S5      rX " S S\5      rY " S S\Y5      rZ " S S\Y5      r[ " S S\Z5      r\ " S S\Z5      r] " S S\Z5      r^ " S S\Z5      r_ " S S\Z5      r` " S S\Z5      ra " S S\Z5      rb " S S\Z5      rc " S S\Z5      rd " S S\Z5      re " S S\Z5      rf " S S\Z5      rg " S S\[5      rh " S S\[5      ri " S S\[5      rj " S S\[5      rk " S S\[5      rl " S S\[5      rm " S S\m5      rn " S S\m5      ro " S S\m5      rp " S S\m5      rq " S S\m5      rr " S S\m5      rs " S S\m5      rt " S S\[5      ru " S S\[5      rv " S S\[5      rw " S S\[5      rx " S S\[5      ry " S S\[5      rz " S S\[5      r{ " S S\[5      r| " S S\[5      r} " S S\[5      r~ " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\[5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r/ SQrS rGSGSS jjr0 S\_S\_GS \$_GS\_GS\$_GS\$_GS\ _GS\!_GS\"_GS\__GS\__GS	\\_GS
\]_GS\^_GS\a_GS\d_GS\'_0 GS\'_GS\'_GS\&_GS\(_GS\)_GS\*_GS\)_GS\2_GS\2_GS\3_GS\3_GS\3_GS\3_GS\3_GS\3_GS\4_GS\5_E0 GS \5_GS!\6_GS"\5_GS#\5_GS$\5_GS%\5_GS&\,_GS'\-_GS(\._GS)\/_GS*\+_GS+\+_GS,\0_GS-\f_GS.\+_GS/\+_GS0\+_E0 GS1\+_GS2\_GS3\_GS4\_GS5\#_GS6\U_GS7\V_GS8\X_GS9\U_GS:\T_GS;\S_GS<\S_GS=\S_GS>\M_GS?\N_GS@\O_GSA\P_E0 GSB\F_GSC\G_GSD\J_GSE\H_GSF\@_GSG\?_GSH\A_GSI\B_GSJ\B_GSK\C_GSL\D_GSM\E_GSN\#_GSO\#_GSP\#_GSQ\#_GSR\#_E0 GSS\#_GST\#_GSU\#_GSV\#_GSW\#_GSX\#_GSY\#_GSZ\#_GS[\#_GS\\#_GS]\#_GS^\#_GS_\#_GS`\#_GSa\#_GSb\#_GSc\#_E0 GSd\#_GSe\#_GSf\;_GSg\9_GSh\<_GSi\=_GSj\g_GSk\Q_GSl\,_GSm\R_GSn\__GSo\w_GSp\e_GSq\h_GSr\_GSs\}_GSt\#_E\#\#\#\#\#\#\#\#\#GSu.	ErGSGSv jrGSGSw jrGSx r " GSy GSz\GR0                  GR2                  5      r\GR6                  4 GSGS{ jjr\GR6                  4 GSGS| jjr\GR6                  4 GSGS} jjr " GS~ GS\GR>                  5      r " GS GS\GR>                  5      r\/r\GS:X  a  SSKr\GRH                  " \5        gg(  a  
This module represents instruments through objects that contain general information
such as Metadata for instrument names, classifications, transpositions and default
MIDI program numbers.  It also contains information specific to each instrument
or instrument family, such as string pitches, etc.  Information about instrumental
ensembles is also included here though it may later be separated out into its own
ensemble.py module.
    )annotations)OrderedDict)IterableN)base)common)environment)InstrumentException)interval)note)pitch)
OffsetTreestream
instrumentFinPlacec                   USL a  U nOU R                  S5      nU HR  n[        U[        R                  5      (       d  M$  UR                  nUc  M5  UR
                  nUR                  XT5        MT     USL a  U$ g)ar  
takes a :class:`~music21.stream.Stream` that has :class:`~music21.note.NotRest` objects
and moves their `.storedInstrument` attributes to a new Stream (unless inPlace=True)

>>> up1 = note.Unpitched()
>>> up1.storedInstrument = instrument.BassDrum()
>>> up2 = note.Unpitched()
>>> up2.storedInstrument = instrument.Cowbell()
>>> s = stream.Stream()
>>> s.append(up1)
>>> s.append(up2)
>>> s2 = instrument.unbundleInstruments(s)
>>> s2.show('text')
{0.0} <music21.instrument.BassDrum 'Bass Drum'>
{0.0} <music21.note.Unpitched 'Bass Drum'>
{1.0} <music21.instrument.Cowbell 'Cowbell'>
{1.0} <music21.note.Unpitched 'Cowbell'>
TunbundleInstrumentsNF)coreCopyAsDerivation
isinstancer   NotReststoredInstrumentoffsetinsert)streamInr   sthisObjioffs         L/home/james-whalen/.local/lib/python3.13/site-packages/music21/instrument.pyr   r   /   su    , $))*?@gt||,,((A}nn   %     c                   USL a  U nOU R                  S5      nSnU HO  nSUR                  ;   a  UnUR                  U5        M(  [        U[        R
                  5      (       d  MI  X4l        MQ     USL a  U$ g)a  
>>> up1 = note.Unpitched()
>>> up1.storedInstrument = instrument.BassDrum()
>>> upUnknownInstrument = note.Unpitched()

>>> up2 = note.Unpitched()
>>> up2.storedInstrument = instrument.Cowbell()
>>> s = stream.Stream()
>>> s.append(up1)
>>> s.append(upUnknownInstrument)
>>> s.append(up2)
>>> s2 = instrument.unbundleInstruments(s)
>>> s3 = instrument.bundleInstruments(s2)
>>> for test in s3:
...     print(test.storedInstrument)
Bass Drum
Bass Drum
Cowbell

TbundleInstrumentsN
InstrumentF)r   classesremover   r   r   r   )r   r   r   lastInstrumentr   s        r    r#   r#   V   sx    0 $))*=>N7??*$NHHW..'5$  % r!   c                  n   ^  \ rS rSrSrSrSSU 4S jjjrS rS rSS jr	S r
S	 rS
 rSSS jjrSrU =r$ )r$      a  
Base class for all musical instruments.  Designed
for subclassing, though usually a more specific
instrument class (such as StringInstrument) would
be better to subclass.

Some defined attributes for instruments include:

* partId
* partName
* partAbbreviation
* instrumentId
* instrumentName
* instrumentAbbreviation
* midiProgram (0-indexed)
* midiChannel (0-indexed)
* lowestNote (a note object or a string for _written_ pitch)
* highestNote (a note object or a string for _written_ pitch)
* transposition (an interval object)
* inGMPercMap (bool -- if it uses the GM percussion map)
* soundfontFn (filepath to a sound font, optional)
ic                   > [         TU ]  " S0 UD6  S U l        SU l        S U l        S U l        S U l        S U l        S U l        SU l	        Xl
        S U l        S U l        S U l        S U l        S U l        S U l        S U l        SU l        S U l        g )NF )super__init__partId_partIdIsRandompartNamepartAbbreviationprintPartNameprintPartAbbreviationinstrumentId_instrumentIdIsRandominstrumentNameinstrumentAbbreviationmidiProgrammidiChannelinstrumentSound
lowestNotehighestNotetranspositioninGMPercMapsoundfontFn)selfr6   keywords	__class__s      r    r-   Instrument.__init__   s    $8$ $$"&*.(,04"&*%*"(604#%)%))-,0-1 6: r!   c                $   / nU R                   b  UR                  U R                    S35        U R                  b  UR                  U R                   S35        U R                  b  UR                  U R                  5        SR	                  U5      $ )Nz:  )r.   appendr0   r6   join)r@   msgs     r    __str__Instrument.__str__   su    ;;"JJ$++b)*==$JJ$--+,*JJt**+wws|r!   c                *    [        [        U 5      5      $ N)reprstrr@   s    r    _reprInternalInstrument._reprInternal   s    CIr!   c                    [         R                  " X5      nU R                  (       a  UR                  5         U R                  (       a  UR                  5         U$ rL   )r   defaultDeepcopyr/   partIdRandomizer5   instrumentIdRandomize)r@   memonews      r    __deepcopy__Instrument.__deepcopy__   sA    $$T0!%%%%'
r!   c                    U R                   b  U R                   $ U R                  b  U R                  $ U R                  b  U R                  $ U R                  b  U R                  $ g)zQ
Find a viable name, looking first at instrument, then part, then
abbreviations.
N)r0   r1   r6   r7   rO   s    r    bestNameInstrument.bestName   sc    
 ==$== "".(((  ,&&&((4...r!   c                N    S[         R                  " 5        3nXl        SU l        g)#
Force a unique id by using an MD5
PTN)r   getMd5r.   r/   r@   idNews     r    rT   Instrument.partIdRandomize   s&     FMMO$% #r!   c                N    S[         R                  " 5        3nXl        SU l        g)r^   ITN)r   r`   r4   r5   ra   s     r    rU    Instrument.instrumentIdRandomize   s'     FMMO$% "%)"r!   c                F   [        U5      nSU R                  ;   a  SU;  a  SU l        U R                  $ U(       d  SU l        U R                  $ [        U5      US-
  :  a  [	        S5      e[        U5       H'  nXC;   a  M
  US-  S:X  a  M  X@l        U R                  s  $    g)aW  
Assign an unused midi channel given a list of
used channels.  Music21 uses 0-indexed MIDI channels.

assigns the number to self.midiChannel and returns
it as an int.

Note that the Percussion MIDI channel (9 in music21, 10 in 1-16 numbering) is special,
and thus is skipped.

>>> used = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11]
>>> i = instrument.Violin()
>>> i.autoAssignMidiChannel(used)
12
>>> i.midiChannel
12

Note that used is unchanged after calling this and would need to be updated manually

>>> used
[0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11]



Unpitched percussion will be set to 9, so long as it's not in the filter list:

>>> used = [0]
>>> i = instrument.Maracas()
>>> i.autoAssignMidiChannel(used)
9
>>> i.midiChannel
9

>>> used = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> i = instrument.Woodblock()
>>> i.autoAssignMidiChannel(used)
11
>>> i.midiChannel
11

If all 16 channels are used, an exception is raised:

>>> used2 = range(16)
>>> i = instrument.Instrument()
>>> i.autoAssignMidiChannel(used2)
Traceback (most recent call last):
music21.exceptions21.InstrumentException: we are out of midi channels! help!

Get around this by assinging higher channels:

>>> i.autoAssignMidiChannel(used2, maxMidi=32)
16
>>> i.midiChannel
16

* Changed in v.9 -- usedChannelList is required, add maxMidi as an optional parameter.
    various small tweaks for corner cases.
UnpitchedPercussion	   r      z"we are out of midi channels! help!   )	frozensetr%   r9   lenr	   range)r@   usedChannelsmaxMidichannelFilterchs        r    autoAssignMidiChannel Instrument.autoAssignMidiChannel   s    x ",/ DLL0Qm5K D### D###7Q;.%&JKKGn&"W\')$+++ % r!   )r5   r/   r<   r>   r7   r4   r6   r:   r;   r9   r8   r1   r.   r0   r3   r2   r?   r=   rL   )r6   z
str | None)rk   )ro   z	list[int])__name__
__module____qualname____firstlineno____doc__classSortOrderr-   rI   rP   rX   r[   rT   rU   rs   __static_attributes____classcell__rB   s   @r    r$   r$      sC    , N   < $*P Pr!   r$   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )KeyboardInstrumentiG  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NKeyboardKbzkeyboard.pianor+   r,   r-   r6   r7   r:   r@   rA   rB   s     r    r-   KeyboardInstrument.__init__I  s+    $8$(&*#/r!   r7   r6   r:   ru   rv   rw   rx   r-   r{   r|   r}   s   @r    r   r   G  s    0 0r!   r   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )PianoiP  zN

>>> p = instrument.Piano()
>>> p.instrumentName
'Piano'
>>> p.midiProgram
0
c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        [
        R                  " S5      U l        g )Nr   Pnor   A0C8r+   	r,   r-   r6   r7   r8   r   Pitchr;   r<   r   s     r    r-   Piano.__init__Z  sL    $8$%&+#++d+ ;;t,r!   r<   r7   r6   r;   r8   ru   rv   rw   rx   ry   r-   r{   r|   r}   s   @r    r   r   P  s    - -r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Harpsichordie  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l	        g )Nr   Hpschd   zkeyboard.harpsichordF1F6r+   
r,   r-   r6   r7   r8   r:   r   r   r;   r<   r   s     r    r-   Harpsichord.__init__f  sT    $8$+&.#5++d+ ;;t,r!   r<   r7   r6   r:   r;   r8   r   r}   s   @r    r   r   e      	- 	-r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
Clavichordir  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr   Clv   zkeyboard.clavichordr+   r,   r-   r6   r7   r8   r:   r   s     r    r-   Clavichord.__init__s  s3    $8$*&+#4r!   r7   r6   r:   r8   r   r}   s   @r    r   r   r  s    5 5r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Celestai  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr   Clst   zkeyboard.celestar+   r   r   s     r    r-   Celesta.__init__  s3    $8$'&,#1r!   r   r   r}   s   @r    r   r     s    2 2r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Sampleri  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr   Samp7   r+   r,   r-   r6   r7   r8   r   s     r    r-   Sampler.__init__  s+    $8$'&,#r!   r7   r6   r8   r   r}   s   @r    r   r     s     r!   r   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )ElectricPianoi  z_

>>> p = instrument.ElectricPiano()
>>> p.instrumentName
'Electric Piano'
>>> p.midiProgram
2
c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NzElectric PianozE.Pno   r+   r   r   s     r    r-   ElectricPiano.__init__  s+    $8$.&-#r!   r   r   r}   s   @r    r   r     s     r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Organi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr      zkeyboard.organr+   )r,   r-   r6   r8   r:   r   s     r    r-   Organ.__init__  s+    $8$%/r!   r6   r:   r8   r   r}   s   @r    r   r     s    0 0r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	PipeOrgani  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l	        g )Nz
Pipe OrganzP Orgr   zkeyboard.organ.pipeC2C6r+   r   r   s     r    r-   PipeOrgan.__init__  sT    $8$*&-#4++d+ ;;t,r!   r   r   r}   s   @r    r   r         - -r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )ElectricOrgani  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        [
        R                  " S5      U l        g )NzElectric OrganzElec Orgrk   r   r   r+   r   r   s     r    r-   ElectricOrgan.__init__  sL    $8$.&0#++d+ ;;t,r!   r   r   r}   s   @r    r   r     r   r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	ReedOrgani  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        [
        R                  " S5      U l        g )Nz
Reed Organ   zkeyboard.organ.reedr   r   r+   )	r,   r-   r6   r8   r:   r   r   r;   r<   r   s     r    r-   ReedOrgan.__init__  sL    $8$*4++d+ ;;t,r!   )r<   r6   r:   r;   r8   r   r}   s   @r    r   r     r   r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Accordioni  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l	        g )Nr   Acc   zkeyboard.accordionF3A6r+   r   r   s     r    r-   Accordion.__init__  sT    $8$)&+#3++d+ ;;t,r!   r   r   r}   s   @r    r   r     r   r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Harmonicai  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l	        g )Nr   Hmca   zwind.reed.harmonicaC3r   r+   r   r   s     r    r-   Harmonica.__init__  sT    $8$)&,#4++d+ ;;t,r!   r   r   r}   s   @r    r   r     r   r!   r   c                  D   ^  \ rS rSrU 4S jrS rS r\" \\SS9rSr	U =r
$ )StringInstrumenti  c                l   > [         TU ]  " S0 UD6  S U l        S U l        SU l        SU l        SU l        g )Nr   Str0   r+   )r,   r-   _stringPitches_cachedPitchesr6   r7   r8   r   s     r    r-   StringInstrument.__init__  s;    $8$""0&+#r!   c                   [        U S5      (       a  U R                  b  U R                  $ [        U S5      (       d  [        S5      eU R                   Vs/ s H  n[        R
                  " U5      PM     snU l        U R                  $ s  snf )Nr   r   z.cannot get stringPitches for these instruments)hasattrr   r	   r   r   r   )r@   xs     r    _getStringPitches"StringInstrument._getStringPitches  sz    4)**t/B/B/N&&&/00%&VWW;?;N;N"O;Na5;;q>;N"OD&&& #Ps    B	c                z    U(       a'  [        US   S5      (       d  US   c  Xl        Xl        g S U l        Xl        g )Nr   step)r   r   r   )r@   
newPitchess     r    _setStringPitches"StringInstrument._setStringPitches  s8    7:a=&99Z]=R",","&D",r!   a  
            stringPitches is a property that stores a list of Pitches (or pitch names,
            such as "C4") that represent the pitch of the open strings from lowest to
            highest.[*]

            >>> vln1 = instrument.Violin()
            >>> [str(p) for p in vln1.stringPitches]
            ['G3', 'D4', 'A4', 'E5']

            instrument.stringPitches are full pitch objects, not just names:

            >>> [x.octave for x in vln1.stringPitches]
            [3, 4, 4, 5]

            Scordatura for Scelsi's violin concerto *Anahit*.
            (N.B. that string to pitch conversion is happening automatically)

            >>> vln1.stringPitches = ['G3', 'G4', 'B4', 'D4']

            (`[*]In some tuning methods such as reentrant tuning on the ukulele,
            lute, or five-string banjo the order might not strictly be from lowest to
            highest.  The same would hold true for certain violin scordatura pieces, such
            as some of Biber's *Mystery Sonatas*`)
            doc)r   r   r7   r6   r8   )ru   rv   rw   rx   r-   r   r   propertystringPitchesr{   r|   r}   s   @r    r   r     s*    '- .0A H Mr!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Violini&  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )Nr   Vln(   zstrings.violinG3r   D4A4E5r+   
r,   r-   r6   r7   r8   r:   r   r   r;   r   r   s     r    r-   Violin.__init__'  sK    $8$&&+#/++d+6r!   r   r7   r6   r:   r;   r8   r   r}   s   @r    r   r   &      	7 	7r!   r   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Violai3  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )Nr  Vla)   zstrings.violar   r   r   r   r   r+   r   r   s     r    r-   Viola.__init__4  sK    $8$%&+#.++d+6r!   r   r   r}   s   @r    r  r  3  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Violoncelloi@  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )Nr
  Vc*   zstrings.cellor   )r   G2D3A3r+   r   r   s     r    r-   Violoncello.__init__A  sK    $8$+&*#.++d+6r!   r   r   r}   s   @r    r
  r
  @  r  r!   r
  c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )
ContrabassiM  z
For the Contrabass (or double bass), the stringPitches attribute refers to the sounding pitches
of each string; whereas the lowestNote attribute refers to the lowest written note.
c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        [        R                  " S5      U l        g )	Nr  Cb+   zstrings.contrabassE2E1A1D2r  P-8r+   )r,   r-   r6   r7   r8   r:   r   r   r;   r   r
   Intervalr=   r   s     r    r-   Contrabass.__init__S  s^    $8$*&*#3++d+6%..u5r!   r   r7   r6   r:   r;   r8   r=   r   r}   s   @r    r  r  M  s    

6 
6r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Harpi`  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l	        g )Nr!  Hp.   z
pluck.harpC1zG#7r+   r   r   s     r    r-   Harp.__init__a  sT    $8$$&*#+++d+ ;;u-r!   r   r   r}   s   @r    r!  r!  `  s    	. 	.r!   r!  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Guitarim  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )Nr(  Gtr   zpluck.guitarr  )r  A2r  r   B3E4r+   r   r   s     r    r-   Guitar.__init__n  sK    $8$&&+#-++d+Br!   r   r   r}   s   @r    r(  r(  m  s    	C 	Cr!   r(  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )AcousticGuitariz  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NAcoustic GuitarzAc Gtrr+  zpluck.guitar.acousticr+   r   r   s     r    r-   AcousticGuitar.__init__{  s3    $8$/&.#6r!   r   r   r}   s   @r    r1  r1  z      7 7r!   r1  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )ElectricGuitari  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NzElectric GuitarzElec Gtr   zpluck.guitar.electricr+   r   r   s     r    r-   ElectricGuitar.__init__  s3    $8$/&0#6r!   r   r   r}   s   @r    r7  r7    r5  r!   r7  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )AcousticBassi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )NzAcoustic BasszAc b    zpluck.bass.acousticr  r  r+   r   r   s     r    r-   AcousticBass.__init__  sK    $8$-&,#4++d+6r!   r   r   r}   s   @r    r<  r<    r  r!   r<  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )ElectricBassi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        g )NzElectric BasszElec b!   zpluck.bass.electricr  r  r+   r   r   s     r    r-   ElectricBass.__init__  sK    $8$-&.#4++d+6r!   r   r   r}   s   @r    rA  rA    r  r!   rA  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )FretlessBassi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        / SQU l        g )NzFretless Bass#   zpluck.bass.fretlessr  r  r+   )	r,   r-   r6   r8   r:   r   r   r;   r   r   s     r    r-   FretlessBass.__init__  sC    $8$-4++d+6r!   )r   r6   r:   r;   r8   r   r}   s   @r    rF  rF    r  r!   rF  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Mandolini  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        / SQU l        g )NrK  Mdlnzpluck.mandolinr   r   r+   	r,   r-   r6   r7   r:   r   r   r;   r   r   s     r    r-   Mandolin.__init__  sC    $8$(&,#/++d+6r!   r   r7   r6   r:   r;   r   r}   s   @r    rK  rK        7 7r!   rK  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Ukulelei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        / SQU l        g )NrS  Ukezpluck.ukuleleC4)G4rV  r.  r   r+   rN  r   s     r    r-   Ukulele.__init__  sC    $8$'&+#.++d+6r!   rP  r   r}   s   @r    rS  rS    rQ  r!   rS  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Banjoi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        / SQU l	        [        R                  " S5      U l        g )	NrZ  Bjozpluck.banjoi   r   r  r  r+   )r,   r-   r6   r7   r:   r8   r   r   r;   r   r
   r  r=   r   s     r    r-   Banjo.__init__  s^    $8$%&+#,++d+6%..u5r!   r  r   r}   s   @r    rZ  rZ    s    
6 
6r!   rZ  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Lutei  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr`  Ltez
pluck.luter+  r+   r,   r-   r6   r7   r:   r8   r   s     r    r-   Lute.__init__  s3    $8$$&+#+r!   r   r   r}   s   @r    r`  r`         r!   r`  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Sitari  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nrg  Sitzpluck.sitarh   r+   rc  r   s     r    r-   Sitar.__init__  s3    $8$%&+#,r!   r   r   r}   s   @r    rg  rg         r!   rg  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Shamiseni  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nrn  zpluck.shamisenj   r+   r,   r-   r6   r:   r8   r   s     r    r-   Shamisen.__init__  s+    $8$(/r!   r   r   r}   s   @r    rn  rn    rl  r!   rn  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Kotoi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nrt  z
pluck.kotok   r+   rq  r   s     r    r-   Koto.__init__  s+    $8$$+r!   r   r   r}   s   @r    rt  rt    rl  r!   rt  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )WoodwindInstrumenti  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NWoodwindWwr+   r,   r-   r6   r7   r   s     r    r-   WoodwindInstrument.__init__  s#    $8$(&*#r!   r7   r6   r   r}   s   @r    ry  ry    s    + +r!   ry  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Flutei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Flzwind.flutes.fluteI   rV  r+   	r,   r-   r6   r7   r:   r8   r   r   r;   r   s     r    r-   Flute.__init__  sC    $8$%&*#2++d+r!   r7   r6   r:   r;   r8   r   r}   s   @r    r  r        , ,r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Piccoloi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l        g )Nr  Picczwind.flutes.piccoloH   r   P8r+   r,   r-   r6   r7   r:   r8   r   r   r;   r
   r  r=   r   s     r    r-   Piccolo.__init__  sV    $8$'&,#4++d+%..t4r!   r7   r6   r:   r;   r8   r=   r   r}   s   @r    r  r    s    	5 	5r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Recorderi&  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Reczwind.flutes.recorderJ   F4r+   r  r   s     r    r-   Recorder.__init__'  sC    $8$(&+#5++d+r!   r  r   r}   s   @r    r  r  &  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )PanFlutei2  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nz	Pan FlutezP Flzwind.flutes.panpipesK   r+   rc  r   s     r    r-   PanFlute.__init__3  s3    $8$)&,#5r!   r   r   r}   s   @r    r  r  2  re  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
Shakuhachii<  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr  zShk Flzwind.flutes.shakuhachiM   r+   rc  r   s     r    r-   Shakuhachi.__init__=  s3    $8$*&.#7r!   r   r   r}   s   @r    r  r  <  re  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )WhistleiF  c                z   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SU l        g )Nr  Whszwind.flutes.whistleTG   N   r+   )r,   r-   r6   r7   r:   r>   percMapPitchr8   r   s     r    r-   Whistle.__init__G  sC    $8$'&+#4r!   )r>   r7   r6   r:   r8   r  r   r}   s   @r    r  r  F  s    	 	r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )OcarinaiS  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr  Oczwind.flutes.ocarinaO   r+   rc  r   s     r    r-   Ocarina.__init__T  s3    $8$'&*#4r!   r   r   r}   s   @r    r  r  S  re  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Oboei]  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Obzwind.reed.oboeD   B-3r+   r  r   s     r    r-   Oboe.__init__^  sC    $8$$&*#/++e,r!   r  r   r}   s   @r    r  r  ]  r   r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )EnglishHornii  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l        g )NzEnglish HornzEng Hnzwind.reed.english-hornE   r-  P-5r+   r  r   s     r    r-   EnglishHorn.__init__j  sV    $8$,&.#7++d+%..u5r!   r  r   r}   s   @r    r  r  i      	6 	6r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Clarinetiv  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l        g )Nr  Clzwind.reed.clarinetr  E3M-2r+   r  r   s     r    r-   Clarinet.__init__w  sV    $8$(&*#3++d+%..u5r!   r  r   r}   s   @r    r  r  v  r  r!   r  c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )BassClarineti  z
>>> bcl = instrument.BassClarinet()
>>> bcl.instrumentName
'Bass clarinet'
>>> bcl.midiProgram
71
>>> 'WoodwindInstrument' in bcl.classes
True
c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        [        R                  " S5      U l
        g )NzBass clarinetzBs Clzwind.reed.clarinet.basszE-3M-9r+   )r,   r-   r6   r7   r:   r   r   r;   r
   r  r=   r   s     r    r-   BassClarinet.__init__  sN    $8$-&-#8++e,%..u5r!   )r7   r6   r:   r;   r=   r   r}   s   @r    r  r    s    6 6r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Bassooni  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Bsnwind.reed.bassoonF   B-1r+   r  r   s     r    r-   Bassoon.__init__  sC    $8$'&+#2++e,r!   r  r   r}   s   @r    r  r    r   r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Contrabassooni  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  zC Bsnr  r  r  r+   r  r   s     r    r-   Contrabassoon.__init__  sC    $8$-&-#2++e,r!   r  r   r}   s   @r    r  r    r   r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Saxophonei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Saxzwind.reed.saxophoneA   r  r+   r  r   s     r    r-   Saxophone.__init__  sC    $8$)&+#4++e,r!   r  r   r}   s   @r    r  r    r   r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SopranoSaxophonei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )NzSoprano SaxophonezS Saxzwind.reed.saxophone.soprano@   r  r+   	r,   r-   r6   r7   r:   r8   r
   r  r=   r   s     r    r-   SopranoSaxophone.__init__  sF    $8$1&-#<%..u5r!   r7   r6   r:   r8   r=   r   r}   s   @r    r  r        6 6r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )AltoSaxophonei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )NzAlto SaxophonezA Saxzwind.reed.saxophone.altor  zM-6r+   r  r   s     r    r-   AltoSaxophone.__init__  sF    $8$.&-#9%..u5r!   r  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TenorSaxophonei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )NzTenor SaxophonezT Saxzwind.reed.saxophone.tenorB   r  r+   r  r   s     r    r-   TenorSaxophone.__init__  sF    $8$/&-#:%..u5r!   r  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )BaritoneSaxophonei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )NzBaritone SaxophonezBar Saxzwind.reed.saxophone.baritoneC   zM-13r+   r  r   s     r    r-   BaritoneSaxophone.__init__  sF    $8$2&/#=%..v6r!   r  r   r}   s   @r    r  r    rQ  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Bagpipesi  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr  Bagzwind.pipes.bagpipesm   r+   rc  r   s     r    r-   Bagpipes.__init__  s3    $8$(&+#4r!   r   r   r}   s   @r    r  r    rl  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Shehnaii  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr  Shnzwind.reed.shenaio   r+   rc  r   s     r    r-   Shehnai.__init__  s3    $8$'&+#1r!   r   r   r}   s   @r    r  r         r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )BrassInstrumenti  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NBrassBrs=   r+   r   r   s     r    r-   BrassInstrument.__init__  s+    $8$%&+#r!   r   r   r}   s   @r    r  r    s     r!   r  c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )Horni  zx
>>> hn = instrument.Horn()
>>> hn.instrumentName
'Horn'
>>> hn.midiProgram
60
>>> 'BrassInstrument' in hn.classes
True
c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l        g )Nr  Hnzbrass.french-horn<   r   r  r+   r  r   s     r    r-   Horn.__init__  sV    $8$$&*#2++d+%..u5r!   r  r   r}   s   @r    r  r    s    	6 	6r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Trumpeti$  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        [        R                  " S5      U l        g )Nr  Tptzbrass.trumpet8   zF#3r  r+   r  r   s     r    r-   Trumpet.__init__%  sV    $8$'&+#.++e,%..u5r!   r  r   r}   s   @r    r  r  $  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Trombonei1  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Trbzbrass.trombone9   r  r+   r  r   s     r    r-   Trombone.__init__2  sC    $8$(&+#/++d+r!   r  r   r}   s   @r    r  r  1  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )BassTrombonei=  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        [
        R                  " S5      U l        g )NzBass TromboneBTrbzbrass.trombone.bassr  r+   )r,   r-   r6   r7   r:   r   r   r;   r   s     r    r-   BassTrombone.__init__>  s;    $8$-&,#4++e,r!   )r7   r6   r:   r;   r   r}   s   @r    r  r  =  s    - -r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TubaiH  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        [        R                  " S5      U l        g )Nr  Tbaz
brass.tuba:   D1r+   r  r   s     r    r-   Tuba.__init__I  sC    $8$$&+#+++d+r!   r  r   r}   s   @r    r  r  H  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
PercussioniV  c                ^   > [         TU ]  " S0 UD6  SU l        S U l        SU l        SU l        g )NFr&  Percr+   )r,   r-   r>   r  r6   r7   r   s     r    r-   Percussion.__init__W  s3    $8$  *&,#r!   )r>   r7   r6   r  r   r}   s   @r    r&  r&  V      - -r!   r&  c                      \ rS rSrSrg)PitchedPercussioni_  r+   Nru   rv   rw   rx   r{   r+   r!   r    r,  r,  _      r!   r,  c                  D   ^  \ rS rSrU 4S jrS rS r\" \\SS9rSr	U =r
$ )rh   ic  c                ^   > [         TU ]  " S0 UD6  S U l        0 U l        0 U l        SU l        g )Nri   r+   )r,   r-   	_modifier_modifierToPercMapPitch_percMapPitchToModifierr9   r   s     r    r-   UnpitchedPercussion.__init__d  s2    $8$')$')$r!   c                    U R                   $ rL   )r1  rO   s    r    _getModifier UnpitchedPercussion._getModifierk  s    ~~r!   c                P   UR                  5       R                  5       nU R                  SL as  UR                  5       U R                  ;   aU  U R                  UR                  5          U l        U R                  U R
                  ;   a  U R
                  U R                     nXl        g )NT)lowerstripr>   r2  r  r3  r1  )r@   modifiers     r    _setModifier UnpitchedPercussion._setModifiern  s    >>#))+ t#(8D<X<X(X $ < <X^^=M ND   D$@$@@778I8IJ!r!   a  
    Returns or sets the modifier for this instrument.  A modifier could
    be something like "low-floor" for a TomTom or "rimshot" for a SnareDrum.

    If the modifier is in the object's ._modifierToPercMapPitch dictionary
    then changing the modifier also changes the .percMapPitch for the object


    >>> bd = instrument.BongoDrums()
    >>> bd.modifier
    'high'

    >>> bd.percMapPitch
    60
    >>> bd.modifier = 'low'
    >>> bd.percMapPitch
    61

    Variations on modifiers can also be used and they get normalized:

    >>> wb1 = instrument.Woodblock()
    >>> wb1.percMapPitch
    76
    >>> wb1.modifier = 'LO'
    >>> wb1.percMapPitch
    77
    >>> wb1.modifier  # n.b. -- not LO
    'low'
    r   )r1  r2  r3  r9   r  )ru   rv   rw   rx   r-   r6  r<  r   r;  r{   r|   r}   s   @r    rh   rh   c  s'    " l 9 	Hr!   rh   c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
Vibraphonei  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr?  Vbpzpitched-percussion.vibraphone   r+   rc  r   s     r    r-   Vibraphone.__init__  s3    $8$*&+#>r!   r   r   r}   s   @r    r?  r?    re  r!   r?  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Marimbai  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NrE  Marzpitched-percussion.marimba   r+   rc  r   s     r    r-   Marimba.__init__  s3    $8$'&+#;r!   r   r   r}   s   @r    rE  rE    re  r!   rE  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Xylophonei  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NrK  zXyl.zpitched-percussion.xylophone   r+   rc  r   s     r    r-   Xylophone.__init__  s3    $8$)&,#=r!   r   r   r}   s   @r    rK  rK    re  r!   rK  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Glockenspieli  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NrP  Gspzpitched-percussion.glockenspielri   r+   rc  r   s     r    r-   Glockenspiel.__init__  s3    $8$,&+#@r!   r   r   r}   s   @r    rP  rP    s     r!   rP  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )ChurchBellsi  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NzChurch BellsBellszmetal.bells.church   r+   rc  r   s     r    r-   ChurchBells.__init__  s3    $8$,&-#3r!   r   r   r}   s   @r    rU  rU    re  r!   rU  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TubularBellsi  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )NzTubular BellsTbellsz pitched-percussion.tubular-bellsrX  r+   rc  r   s     r    r-   TubularBells.__init__  s3    $8$-&.#Ar!   r   r   r}   s   @r    r[  r[    re  r!   r[  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Gongi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr`  Gngz
metal.gongr+   r   r   s     r    r-   Gong.__init__  s+    $8$$&+#+r!   r   r   r}   s   @r    r`  r`        , ,r!   r`  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Handbellsi  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )Nrf  zpitched-percussion.handbellsr+   r,   r-   r6   r:   r   s     r    r-   Handbells.__init__  s#    $8$)=r!   r6   r:   r   r}   s   @r    rf  rf    s    > >r!   rf  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Dulcimeri  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nrl  zpluck.dulcimer   r+   rq  r   s     r    r-   Dulcimer.__init__  s+    $8$(/r!   r   r   r}   s   @r    rl  rl    re  r!   rl  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	SteelDrumi  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nz
Steel DrumzSt Drzmetal.steel-drumsr   r+   rc  r   s     r    r-   SteelDrum.__init__  s3    $8$*&-#2r!   r   r   r}   s   @r    rq  rq    rl  r!   rq  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Timpanii  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nrv  Timpzdrum.timpani/   r+   rc  r   s     r    r-   Timpani.__init__  s3    $8$'&,#-r!   r   r   r}   s   @r    rv  rv    re  r!   rv  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Kalimbai  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr|  Kalzpitched-percussion.kalimbal   r+   rc  r   s     r    r-   Kalimba.__init__  s3    $8$'&+#;r!   r   r   r}   s   @r    r|  r|    rl  r!   r|  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Woodblocki  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SU l        SSSSS	.U l        SS
S.U l	        U R                  U R                     U l
        g )Nr  zWd Blzwood.wood-blockTs   highL   r  )r  lowhilor  )r  r  r+   )r,   r-   r6   r7   r:   r>   r8   r1  r2  r3  r  r   s     r    r-   Woodblock.__init__  sw    $8$)&-#0022Rr'R$,2'>$ 88Hr!   )	r1  r2  r3  r>   r7   r6   r:   r8   r  r   r}   s   @r    r  r        I Ir!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TempleBlocki   c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NzTemple BlockzTemp Blzwood.temple-blockr+   r   r   s     r    r-   TempleBlock.__init__!  s+    $8$,&/#2r!   r   r   r}   s   @r    r  r         3 3r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Castanetsi)  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr  Caszwood.castanetsr+   r   r   s     r    r-   Castanets.__init__*  s+    $8$)&+#/r!   r   r   r}   s   @r    r  r  )      0 0r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Maracasi2  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nr  Tr  zrattle.maracar+   )r,   r-   r6   r>   r  r:   r   s     r    r-   Maracas.__init__3  s3    $8$'.r!   )r>   r6   r:   r  r   r}   s   @r    r  r  2  s    / /r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	Vibraslapi=  c                l   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        g )Nr  Vbslpzrattle.vibraslapTr"  r+   r,   r-   r6   r7   r:   r>   r  r   s     r    r-   Vibraslap.__init__>  s;    $8$)&-#1r!   r>   r7   r6   r:   r  r   r}   s   @r    r  r  =  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )CymbalsiK  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )Nr  Cymr+   r}  r   s     r    r-   Cymbals.__init__L  s#    $8$'&+#r!   r  r   r}   s   @r    r  r  K  s    , ,r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )FingerCymbalsiR  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NzFinger CymbalszFing Cymzmetal.cymbal.fingerr+   r   r   s     r    r-   FingerCymbals.__init__S  s+    $8$.&0#4r!   r   r   r}   s   @r    r  r  R      5 5r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )CrashCymbalsi[  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSS.U l        SS	S
.U l        U R                  U R                     U l	        g )NzCrash Cymbalsr  zmetal.cymbal.crashT11   r  )r  2r  )r  r  r+   
r,   r-   r6   r7   r:   r>   r1  r2  r3  r  r   s     r    r-   CrashCymbals.__init__\  su    $8$-&+#3-/-/(*$ -0,/(*$ !88Hr!   r1  r2  r3  r>   r7   r6   r:   r  r   r}   s   @r    r  r  [      I Ir!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SuspendedCymbalin  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzSuspended Cymbalzmetal.cymbal.suspendedr+   rh  r   s     r    r-   SuspendedCymbal.__init__o  s#    $8$07r!   rj  r   r}   s   @r    r  r  n  s    8 8r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SizzleCymbaliw  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzSizzle Cymbalzmetal.cymbal.sizzler+   rh  r   s     r    r-   SizzleCymbal.__init__x  s#    $8$-4r!   rj  r   r}   s   @r    r  r  w  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SplashCymbalsi  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzSplash Cymbalszmetal.cymbal.splashr+   rh  r   s     r    r-   SplashCymbals.__init__  s#    $8$.4r!   rj  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )RideCymbalsi  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzRide Cymbalszmetal.cymbal.rider+   rh  r   s     r    r-   RideCymbals.__init__  s#    $8$,2r!   rj  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )HiHatCymbali  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SSSS.U l        SS	S
S.U l        U R                  U R
                     U l        g )NzHi-Hat Cymbalzmetal.hi-hatTpedal,   r$  r  )r  openclosedr  r  )r  r$  r  r+   	r,   r-   r6   r:   r>   r1  r2  r3  r  r   s     r    r-   HiHatCymbal.__init__  ss    $8$-- 130224(*$ -4,2,4(*$ !88Hr!   r1  r2  r3  r>   r6   r:   r  r   r}   s   @r    r  r    s    I Ir!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Trianglei  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSS.U l        S	SS
.U l        U R                  U R                     U l	        g )Nr  Trizmetal.triangleTr  Q   P   )r  muter  )r  r  r+   r  r   s     r    r-   Triangle.__init__  su    $8$(&+#/0202(*$ -3,2(*$ !88Hr!   r  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Cowbelli  c                l   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        g )Nr  Cwbzmetal.bells.cowbellTr  r+   r  r   s     r    r-   Cowbell.__init__  s;    $8$'&+#4r!   r  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Agogoi  c                l   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        g )Nr  zmetal.bells.agogoTr  q   r+   )r,   r-   r6   r:   r>   r  r8   r   s     r    r-   Agogo.__init__  s;    $8$%2r!   )r>   r6   r:   r8   r  r   r}   s   @r    r  r    s     r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TamTami  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzTam-Tamzmetal.tamtamr+   rh  r   s     r    r-   TamTam.__init__  s#    $8$'-r!   rj  r   r}   s   @r    r  r        . .r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SleighBellsi  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzSleigh Bellszmetal.bells.sleigh-bellsr+   rh  r   s     r    r-   SleighBells.__init__  s#    $8$,9r!   rj  r   r}   s   @r    r  r    s    : :r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	SnareDrumi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSSS	.U l        SS
SS.U l        U R                  U R                     U l	        g )Nz
Snare DrumzSn Drzdrum.snare-drumTacoustic&   %   r   )r  sideelectricr  r  )r  r  r   r+   r  r   s     r    r-   SnareDrum.__init__  s{    $8$*&-#0#460246(*$ -7,2,6(*$ !88Hr!   r  r   r}   s   @r    r  r    s    I Ir!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	TenorDrumi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nz
Tenor DrumzTen Drzdrum.tenor-drumr+   r   r   s     r    r-   TenorDrum.__init__  s+    $8$*&.#0r!   r   r   r}   s   @r    r  r        1 1r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
BongoDrumsi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSS.U l        SS	S
.U l        U R                  U R                     U l	        g )NzBongo DrumszBgo Drz
drum.bongoTr  r  r  r  r  r  )r  r  r+   r  r   s     r    r-   BongoDrums.__init__  sk    $8$+&.#+022'>$,2'>$ 88Hr!   r  r   r}   s   @r    r  r    s    I Ir!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TomTomi  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SSSSS	S
S.U l        SSSSSSS.U l        U R                  U R
                     U l        g )NzTom-Tomzdrum.tom-tomT	low floorr  r  -   ry  r   2   )r  
high floorr  low-midhigh-midr  r  r  r  r  r  )r  r  r  ry  r   r  r+   r  r   s     r    r-   TomTom.__init__  s|    $8$'-$57rRT352r(S$,7\u,5:6(S$ 88Hr!   r  r   r}   s   @r    r  r    r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Timbalesi!  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSS.U l        SS	S
.U l        U R                  U R                     U l	        g )Nr	  Timzdrum.timbaleTr  r  r  r  r  )r  r  r+   r  r   s     r    r-   Timbales.__init__"  sk    $8$(&+#-022'>$,2'>$ 88Hr!   r  r   r}   s   @r    r	  r	  !      
I 
Ir!   r	  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )	CongaDrumi/  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSSS	.U l        SS
SS.U l        U R                  U R                     U l	        g )Nz
Conga DrumzCga Drz
drum.congaTr  r  >   ?   )r  	mute high	open highr  r  )r  r  r  r+   r  r   s     r    r-   CongaDrum.__init__0  sp    $8$*&.#+/1QS'T$,1{'T$ 88Hr!   r  r   r}   s   @r    r  r  /  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )BassDrumi=  c                   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        SSS.U l        SS	S
.U l        U R                  U R                     U l	        g )Nz	Bass DrumzB Drzdrum.bass-drumTr  rH  $   )r  r  r  )rH  r  r+   r  r   s     r    r-   BassDrum.__init__>  sk    $8$)&,#/#46R'@$,6C'@$ 88Hr!   r  r   r}   s   @r    r  r  =  r  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )TaikoiK  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr  z
drum.taikot   r+   rq  r   s     r    r-   Taiko.__init__L  s+    $8$%+r!   r   r   r}   s   @r    r  r  K  rl  r!   r  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )
TambourineiU  c                l   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        SU l        g )Nr!  Tmbnzdrum.tambourineT6   r+   r  r   s     r    r-   Tambourine.__init__V  s;    $8$*&,#0r!   r  r   r}   s   @r    r!  r!  U  r  r!   r!  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Whipi`  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )Nr'  zeffect.whipr+   rh  r   s     r    r-   Whip.__init__a  s#    $8$$,r!   rj  r   r}   s   @r    r'  r'  `  r*  r!   r'  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Ratchetii  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )Nr+  zrattle.ratchetr+   rh  r   s     r    r-   Ratchet.__init__j  s#    $8$'/r!   rj  r   r}   s   @r    r+  r+  i  r  r!   r+  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Sirenir  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )Nr/  zeffect.sirenr+   rh  r   s     r    r-   Siren.__init__s  s#    $8$%-r!   rj  r   r}   s   @r    r/  r/  r  r  r!   r/  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )SandpaperBlocksi{  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NzSandpaper BlockszSand Blzwood.sand-blockr+   r   r   s     r    r-   SandpaperBlocks.__init__|  s+    $8$0&/#0r!   r   r   r}   s   @r    r3  r3  {  r  r!   r3  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )WindMachinei  c                B   > [         TU ]  " S0 UD6  SU l        SU l        g )NzWind Machinezeffect.windr+   rh  r   s     r    r-   WindMachine.__init__  s#    $8$,,r!   rj  r   r}   s   @r    r7  r7    r*  r!   r7  c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )Vocalisti  z;
n.b. called Vocalist to not be confused with stream.Voice
c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NVoiceV5   r+   r   r   s     r    r-   Vocalist.__init__  s+    $8$%&)#r!   r   r   r}   s   @r    r;  r;    s     r!   r;  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Sopranoi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NrB  Szvoice.sopranor+   r   r   s     r    r-   Soprano.__init__  s+    $8$'&)#.r!   r   r   r}   s   @r    rB  rB    s    / /r!   rB  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )MezzoSopranoi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NzMezzo-SopranoMezzvoice.mezzo-sopranor+   r   r   s     r    r-   MezzoSoprano.__init__  s+    $8$-&+#4r!   r   r   r}   s   @r    rG  rG    r  r!   rG  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Altoi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NrL  Az
voice.altor+   r   r   s     r    r-   Alto.__init__  +    $8$$&)#+r!   r   r   r}   s   @r    rL  rL    rd  r!   rL  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Tenori  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NrR  Tzvoice.tenorr+   r   r   s     r    r-   Tenor.__init__  s+    $8$%&)#,r!   r   r   r}   s   @r    rR  rR    r*  r!   rR  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Baritonei  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )NrW  Barzvoice.baritoner+   r   r   s     r    r-   Baritone.__init__  s+    $8$(&+#/r!   r   r   r}   s   @r    rW  rW    r  r!   rW  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Bassi  c                P   > [         TU ]  " S0 UD6  SU l        SU l        SU l        g )Nr\  Bz
voice.bassr+   r   r   s     r    r-   Bass.__init__  rP  r!   r   r   r}   s   @r    r\  r\    rd  r!   r\  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )Choiri  c                ^   > [         TU ]  " S0 UD6  SU l        SU l        SU l        SU l        g )Nra  Chzvoice.choir4   r+   rc  r   s     r    r-   Choir.__init__  s3    $8$%&*#,r!   r   r   r}   s   @r    ra  ra    re  r!   ra  c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )	Conductori  zh
Presently used only for tracking the MIDI track containing tempo,
key signature, and related metadata.
c                *   > [         TU ]  " SSS0UD6  g )Nr6   rg  r+   )r,   r-   r   s     r    r-   Conductor.__init__  s    @@x@r!   r+   r   r}   s   @r    rg  rg    s    
A Ar!   rg  )ezno performerssoloduettrioquartetquintetsextetseptetoctetnonetdectetundectet	duodectet	tredectetquattuordectet
quindectet	sexdectetseptendectet
octodectetnovemdectetvigetet	unvigetet
duovigetet
trevigetetquattuorvigetetquinvigetet
sexvigetetseptenvigetetoctovigetetnovemvigetettrigetet
untrigetetduotrigetettretrigetetquottuortrigetetquintrigetetsextrigetetseptentrigetetoctotrigetetnovemtrigetetquadragetetunquadragetetduoquadragetettrequadragetetquattuorquadragetetquinquadragetetsexquadragetetoctoquadragetetr  novemquadragetetquinquagetetunquinquagetetduoquinquagetettrequinguagetetquattuorquinquagetetquinquinquagetetsexquinquagetetseptenquinquagetetoctoquinquagetetnovemquinquagetet	sexagetetundexagetetduosexagetettresexagetetquoattuorsexagetetquinsexagetetsexsexagetetseptensexagetetoctosexagetetnovemsexagetetseptuagetetunseptuagetetduoseptuagetettreseptuagetetquattuorseptuagetetquinseptuagetetsexseptuagetetseptenseptuagetetoctoseptuagetetnovemseptuagetet	octogetetunoctogetetduooctogetettreoctogetetquattuoroctogetetquinoctogetetsexoctogetetseptoctogetetoctooctogetetnovemoctogetet	nonagetetunnonagetetduononagetettrenonagetetquattuornonagetetquinnonagetetsexnonagetetseptennonagetetoctononagetetnovemnonagetetcentetc                V    U S:  a  gU S:  a  [        S5      e[        [        U 5         $ )z
return the name of a generic ensemble with "number" players:

>>> instrument.ensembleNameBySize(4)
'quartet'
>>> instrument.ensembleNameBySize(1)
'solo'
>>> instrument.ensembleNameBySize(83)
'treoctogetet'
d   zlarge ensembler   z,okay, you are on your own for this one buddy)r	   ensembleNamesBySizeint)numbers    r    ensembleNameBySizer    s0     |	!!"PQQ"3v;//r!   c                   SSK Jn  U(       a  U nOU R                  S5      nUR                  5       (       d  U/nOUR	                  UR
                  5      nU GHo  n[        U[           R                  5       5      nU GHD  n[        U5      S:X  a  M  U Vs1 s H  oR                  c  M  UR                  iM     n	nU Vs1 s H  oR                  c  M  UR                  iM     n
n[        U	5      S:  d  [        U
5      S:  a  M  SnU	 H  nUnM     SnU
 H  nUnM     U Vs1 s H  oR                  iM     nn[        U5      S:X  a<  SnU H  nXl	        Xl
        Un  O   U H  nUUL a  M
  UR                  USS9  M     GM	  U H5  nUR                  [        :X  a  UR                  USS9  M)  Xl	        Xl
        M7     GMG     GMr     U$ s  snf s  snf s  snf )a1  
Check every offset in `s` for multiple instrument instances.
If the `.partName` can be standardized across instances,
i.e. if each instance has the same value or `None`,
and likewise for `.instrumentName`, standardize the attributes.
Further, and only if the above conditions are met,
if there are two instances of the same class, remove all but one;
if at least one generic `Instrument` instance is found at the same
offset as one or more specific instruments, remove the generic `Instrument` instances.

Two `Instrument` instances:

>>> i1 = instrument.Instrument(instrumentName='Semi-Hollow Body')
>>> i2 = instrument.Instrument()
>>> i2.partName = 'Electric Guitar'
>>> s1 = stream.Stream()
>>> s1.insert(4, i1)
>>> s1.insert(4, i2)
>>> list(s1.getInstruments())
[<music21.instrument.Instrument 'Semi-Hollow Body'>,
    <music21.instrument.Instrument 'Electric Guitar: '>]
>>> post = instrument.deduplicate(s1)
>>> list(post.getInstruments())
[<music21.instrument.Instrument 'Electric Guitar: Semi-Hollow Body'>]

One `Instrument` instance and one subclass instance, with `inPlace` and parts:

>>> from music21.stream import Score, Part
>>> i3 = instrument.Instrument()
>>> i3.partName = 'Piccolo'
>>> i4 = instrument.Piccolo()
>>> s2 = stream.Score()
>>> p1 = stream.Part()
>>> p1.append([i3, i4])
>>> p2 = stream.Part()
>>> p2.append([instrument.Flute(), instrument.Flute()])
>>> s2.insert(0, p1)
>>> s2.insert(0, p2)
>>> list(p1.getInstruments())
[<music21.instrument.Instrument 'Piccolo: '>, <music21.instrument.Piccolo 'Piccolo'>]
>>> list(p2.getInstruments())
[<music21.instrument.Flute 'Flute'>, <music21.instrument.Flute 'Flute'>]
>>> s2 = instrument.deduplicate(s2, inPlace=True)
>>> list(p1.getInstruments())
[<music21.instrument.Piccolo 'Piccolo: Piccolo'>]
>>> list(p2.getInstruments())
[<music21.instrument.Flute 'Flute'>]
r   r   zinstrument.deduplicaterj   NT)recurse)music21r   r   hasPartLikeStreamsgetElementsByClassStreamr   r$   rm   r0   r6   rB   r&   )r   r   r   	returnObj
substreamssuboTreeor   notNonePartNamesnotNoneInstNamesr0   pNamer6   iNameinstr%   	survivings                     r    deduplicater  !  s   b 	**+CD	''))/8k
11&--@
3z?1134A1v{45PAq


AP:;\!Q?O?O 0 0 0!\ #$q(C0@,AA,EH)  *!N)!& * 344!$~~!G47|q  	D$,M*8' $I	  Dy( JJtTJ2  D~~3

4
6(0.<+ G  X O  Q\ 5s   G+GGG%Grj   r            r   r   r   ri   
   rB  rH  rM  rX  rn  rk         r   r   r   r      r+     r9                 r>  rC  "   rH  r  r  r  '   r   r  r  r  r  r  r$  ry  r   r  r  3   rd  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  r  r  R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   `   a   b   c   r  e   f   g   rj  r]  rp  rv  r  r  n   r  p   r  rs  r  r  u   v   )	w   x   y   z   {   |   }   ~      c                     [         U    nU" 5       nXl        U$ ! [         aA  n[        U [        5      (       d  [        S[        U 5       35      Ue[        SU  35      UeSnAff = f)a  
Return the instrument with "number" as its assigned MIDI program.
Notice any of the values 0-5 will return Piano.

Lookups are performed against `instrument.MIDI_PROGRAM_TO_INSTRUMENT`.

>>> instrument.instrumentFromMidiProgram(4)
<music21.instrument.ElectricPiano 'Electric Piano'>
>>> instrument.instrumentFromMidiProgram(21)
<music21.instrument.Accordion 'Accordion'>
>>> instrument.instrumentFromMidiProgram(500)
Traceback (most recent call last):
music21.exceptions21.InstrumentException: No instrument found for MIDI program 500
>>> instrument.instrumentFromMidiProgram('43')
Traceback (most recent call last):
TypeError: Expected int, got <class 'str'>
zExpected int, got z%No instrument found for MIDI program N)MIDI_PROGRAM_TO_INSTRUMENTr8   KeyErrorr   r  	TypeErrortyper	   )r  class_r  es       r    instrumentFromMidiProgramr    sv    &	[+F3x! K	  [&#&&0f?@aG!$I&"RSYZZ[s    
A%<A  A%c           
        SSK Jn  U R                  5       (       d2  UR                  " 5       nUR	                  SU R                  5       5        OSUR                  " 5       nU R                  UR                  5       H#  nUR	                  SUR                  5       5        M%     UR                  UR                  5       H  nUR                  SSS9  M     U[           nU(       d  U$ [        5       nU H.  nUR                  U;  d  M  SU0XVR                  =(       d    S'   M0     UR                  " 5       nU HJ  nUR                  " 5       n	Xl        U	R	                  SXX   S   5        XU   S'   UR	                  SU	5        ML     U H  n
U
R                  (       d  UR	                  U
R                  U
5        U
nUR                  [        5       H  nUR                  nUR                  UR                   R"                  -   nX\R                  =(       d    S   S   n	UR%                  UUSSSS	9nUR'                  [        5       H%  n U	R	                  UR)                  U5      U5        M'     M     M     UR-                  5       R                  [        5       H  nSUR                   l        M     U$ ! UR*                   a     M  f = f)
a  
Given a single Stream, or a Score or similar multi-part structure,
partition into a Part for each unique Instrument, joining events
possibly from different parts.

>>> p1 = converter.parse("tinynotation: 4/4 c4  d  e  f  g  a  b  c'  c1")
>>> p2 = converter.parse("tinynotation: 4/4 C#4 D# E# F# G# A# B# c#  C#1")

>>> p1.getElementsByClass(stream.Measure)[0].insert(0.0, instrument.Piccolo())
>>> p1.getElementsByClass(stream.Measure)[0].insert(2.0, instrument.AltoSaxophone())
>>> p1.getElementsByClass(stream.Measure)[1].insert(3.0, instrument.Piccolo())

>>> p2.getElementsByClass(stream.Measure)[0].insert(0.0, instrument.Trombone())
>>> p2.getElementsByClass(stream.Measure)[0].insert(3.0, instrument.Piccolo())  # not likely
>>> p2.getElementsByClass(stream.Measure)[1].insert(1.0, instrument.Trombone())

>>> s = stream.Score()
>>> s.insert(0, p1)
>>> s.insert(0, p2)
>>> s.show('text')
{0.0} <music21.stream.Part ...>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.instrument.Piccolo 'Piccolo'>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
        {1.0} <music21.note.Note D>
        {2.0} <music21.instrument.AltoSaxophone 'Alto Saxophone'>
        {2.0} <music21.note.Note E>
        {3.0} <music21.note.Note F>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Note G>
        {1.0} <music21.note.Note A>
        {2.0} <music21.note.Note B>
        {3.0} <music21.instrument.Piccolo 'Piccolo'>
        {3.0} <music21.note.Note C>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Note C>
        {4.0} <music21.bar.Barline type=final>
{0.0} <music21.stream.Part ...>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.instrument.Trombone 'Trombone'>
        {0.0} <music21.clef.BassClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C#>
        {1.0} <music21.note.Note D#>
        {2.0} <music21.note.Note E#>
        {3.0} <music21.instrument.Piccolo 'Piccolo'>
        {3.0} <music21.note.Note F#>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Note G#>
        {1.0} <music21.instrument.Trombone 'Trombone'>
        {1.0} <music21.note.Note A#>
        {2.0} <music21.note.Note B#>
        {3.0} <music21.note.Note C#>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Note C#>
        {4.0} <music21.bar.Barline type=final>

>>> s2 = instrument.partitionByInstrument(s)
>>> len(s2.parts)
3

# TODO: this step might not be necessary:

>>> for p in s2.parts:
...     p.makeRests(fillGaps=True, inPlace=True)

# TODO: this step SHOULD not be necessary (.template()):

>>> for p in s2.parts:
...     p.makeMeasures(inPlace=True)
...     p.makeTies(inPlace=True)

>>> s2.show('text')
{0.0} <music21.stream.Part Piccolo>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.instrument.Piccolo 'Piccolo'>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
        {1.0} <music21.note.Note D>
        {2.0} <music21.note.Rest quarter>
        {3.0} <music21.note.Note F#>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Note G#>
        {1.0} <music21.note.Rest half>
        {3.0} <music21.note.Note C>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Note C>
        {4.0} <music21.bar.Barline type=final>
{0.0} <music21.stream.Part Alto Saxophone>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.instrument.AltoSaxophone 'Alto Saxophone'>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Rest half>
        {2.0} <music21.note.Note E>
        {3.0} <music21.note.Note F>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Note G>
        {1.0} <music21.note.Note A>
        {2.0} <music21.note.Note B>
        {3.0} <music21.bar.Barline type=final>
{0.0} <music21.stream.Part Trombone>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.instrument.Trombone 'Trombone'>
        {0.0} <music21.clef.BassClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C#>
        {1.0} <music21.note.Note D#>
        {2.0} <music21.note.Note E#>
        {3.0} <music21.note.Rest quarter>
    {4.0} <music21.stream.Measure 2 offset=4.0>
        {0.0} <music21.note.Rest quarter>
        {1.0} <music21.note.Note A#>
        {2.0} <music21.note.Note B#>
        {3.0} <music21.note.Note C#>
    {8.0} <music21.stream.Measure 3 offset=8.0>
        {0.0} <music21.note.Note C#>
        {4.0} <music21.bar.Barline type=final>

* Changed in v8: returns the original stream if there are no instruments.

TODO: parts should be in Score Order. Coincidence that this almost works.
TODO: use proper recursion to make a copy of the stream.
TODO: final barlines should be aligned.
r   r   r$   Tr   rE   PartF)includeEndBoundarymustFinishInSpanmustBeginInSpan)r  r   r  Scorer   flattenr  r  extendDurationr$   r   r6   r!  idisStreamr   durationquarterLengthgetElementsByOffsetgetElementsNotOfClasselementOffsetStreamExceptionr  )	streamObjr   r   r  instrumentIteratornamesinstrumentObjpostr  pel	subStreamr   startendcollr  r  s                     r    partitionByInstrumentr;  4  sY   D ''))LLN	I%%'(LLN//>CHHQ& ? ##FMM2<6 3 :0;E+''u49E}8UE..4"5 , <<>DKKM	EL./ eVAq  {{KK		2&	--j9AHHE((QZZ555C&&,"-f5A00#(!& $ 1 D //
;HHY44Q7; <# : > 11*=&'# >K -- s   !J//K	K	c           
         U R                  5       n/ n[        S[        U5      S-   5       HH  n[        [        U5      U-
  S-   5       H'  nUR                  SR	                  XXC-    5      5        M)     MJ     U$ )zE
find all combinations of instrumentString.  Remove all punctuation.
rj    )splitrn   rm   rF   rG   )instrumentString
sampleListallCombsizer   s        r    _combinationsrC  	  sq     "'')JGaZ1,-s:-12ANN388J$:;< 3 . Nr!   c                  4    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rg)SearchLanguagei	  allenglishfrenchgermanitalianrussianspanishabbreviationr+   N)ru   rv   rw   rx   ALLENGLISHFRENCHGERMANITALIANRUSSIANSPANISHABBREVIATIONr{   r+   r!   r    rE  rE  	  s*    
CGFFGGG!Lr!   rE  c                   SSK Jn  UR                  5       nU[        ;  a  [	        SU S35      e[        X!S-   5      nU nU R                  SS5      n U R                  5       n [        R                  " U 5      n [        U 5      nSnS	n[        R                  " S
5      nU H  n	 X9   n
[        X5      n[        R                  UR                  ;  a  [        eU" 5       nUR!                  5       R                  5       nUbD  [#        UR%                  5       5      [#        UR%                  5       5      :  a  ['        Xk5      (       d  UnXFl        UnM  M  M     Uc  [	        SU 35      eXrR*                  ;  a  U$ U HO  n	 UR,                  U	R                  5          nUR*                  U   U   n[.        R0                  " U5      Ul          U$    U$ ! [         a     GM<  f = f! [         a     Mt  f = f)ad  
Given a string with instrument content (from an orchestral score
for example), attempts to return an appropriate
:class:`~music21.instrument.Instrument`.

>>> t1 = instrument.fromString('Clarinet 2 in A')
>>> t1
<music21.instrument.Clarinet 'Clarinet 2 in A'>
>>> t1.transposition
<music21.interval.Interval m-3>

>>> t2 = instrument.fromString('Clarinetto 3')
>>> t2
<music21.instrument.Clarinet 'Clarinetto 3'>

>>> t3 = instrument.fromString('flauto 2')
>>> t3
<music21.instrument.Flute 'flauto 2'>


Excess information is ignored, and the useful information can be extracted
correctly as long as it's sequential.

>>> t4 = instrument.fromString('I <3 music saxofono tenore go beavers')
>>> t4
<music21.instrument.TenorSaxophone 'I <3 music saxofono tenore go beavers'>

Some more demos:

>>> t5 = instrument.fromString('Bb Clarinet')
>>> t5
<music21.instrument.Clarinet 'Bb Clarinet'>
>>> t5.transposition
<music21.interval.Interval M-2>

>>> t6 = instrument.fromString('Clarinet in B-flat')
>>> t5.__class__ == t6.__class__
True

>>> t5.transposition == t6.transposition
True

>>> t7 = instrument.fromString('B-flat Clarinet.')
>>> t5.__class__ == t7.__class__ and t5.transposition == t7.transposition
True

>>> t8 = instrument.fromString('Eb Clarinet')
>>> t5.__class__ == t8.__class__
True
>>> t8.transposition
<music21.interval.Interval m3>


Note that because of the ubiquity of B-flat clarinets and trumpets, and the
rareness of B-natural forms of those instruments, this gives a B-flat, not
B-natural clarinet, using the German form:

>>> t9 = instrument.fromString('Klarinette in B.')
>>> t9
<music21.instrument.Clarinet 'Klarinette in B.'>
>>> t9.transposition
<music21.interval.Interval M-2>

Use "H" or "b-natural" to get an instrument in B-major.  Or donate one to me,
and I'll change this back!


Standard abbreviations are acceptable:

>>> t10 = instrument.fromString('Cl in B-flat')
>>> t10
<music21.instrument.Clarinet 'Cl in B-flat'>
>>> t10.transposition
<music21.interval.Interval M-2>

This should work with or without a terminal period (for both 'Cl' and 'Cl.'):

>>> t11 = instrument.fromString('Cl. in B-flat')
>>> t11.__class__ == t10.__class__
True


Previously an exact instrument name was not always working:

>>> instrument.fromString('Flute')
<music21.instrument.Flute 'Flute'>

This common MIDI instrument was not previously working:

>>> instrument.fromString('Choir (Aahs)')
<music21.instrument.Choir 'Choir (Aahs)'>


By default, this function searches over all stored instrument names.
This includes multiple languages as well as the abbreviations
(an honorary 'language' for these purposes).

Alternatively, you can specify the language to search using the `language`
argument. (New in v7.3)

>>> t12 = instrument.fromString('Klarinette', language=instrument.SearchLanguage.GERMAN)
>>> t12
<music21.instrument.Clarinet 'Klarinette'>

This case works because the name 'Klarinette' is a recognised instrument name in German
and appears in the German language list.
If you search for a German name like 'Klarinette' on the French list (language='french'),
then it won't be found and an InstrumentException will be raised.
An InstrumentException is also raised if the specified language is not
one of those currently supported:
'english', 'french', 'german', 'italian', 'russian', 'spanish', and 'abbreviation'.

Note that the language string is not case-sensitive, so 'French' is also fine.
r   instrumentLookupChosen language  not currently supported.ToClassName.r=  NrE   zmusic21.instrumentz(Could not match string with instrument: )music21.languageExcerptsrX  r9  rE  r	   getattrreplacer   removePunctuationrC  	importlibimport_moduler   Music21Object__mro__r  r[   rm   r>  r   r6   r=   pitchFullNameToNamer
   r  )r?  languagerX  
sourceDictinstrumentStringOrigallCombinationsbestInstrumentr[   this_module	substring	classNamethisInstClassthisInstrumentthisBestName	bestPitchbestIntervals                   r    
fromStringrs  	  s
   h :~~H~%!$4XJ>W"XYY)m+CDJ+'//S9'--///0@A#$45ONH))*>?K$		"-I#K;M!!)>)>>*_N)224::<L&<--/0C8H4II&~EE "00D-' F J %& !67K6LMO 	O555 %		(<<Y__=NOI+99(CINL+3+<+<\+JN(  % %  		   		s&   #B)G<A
G
GG
G-,G-c                    SSK Jn  [        X!S-   5      n/ nUR                  5        H  u  pVX:X  d  M  UR	                  U5        M     U$ )z
Retrieve the key or keys (variant instrument names)
from an instrumentLookup dict, given
the language (which instrumentLookup dict) and
value (classNameString).

Returns all relevant keys as a list of strings (empty if no matches).
r   rW  r[  )r]  rX  r^  itemsrF   )classNameStringrf  rX  rg  returnskeyvalues          r    _getKeysrz  	  sJ     :)m+CDJG &&(
#NN3 ) Nr!   c                R   UR                  5       n0 nU R                  =(       d    SnU[        R                  :X  a;  [         H/  nU[        R                  L a  M  [	        X45      U[        U5      '   M1     U$ U[        ;  a  [        SU S35      e[	        U[        U5      5      X!'   U$ )uM  
Retrieves all currently stored names for a given instrument.

The instrumentClass should be a valid music21
:class:`~music21.instrument.Instrument`.

By default, this function searches over all supported languages
including instrument name abbreviations (an honorary 'language' for these purposes),
and returns a dict with keys for the language tested and values as a list of
strings for any names in that language.

>>> instrument.getAllNamesForInstrument(instrument.Flute())
{'english': ['flute', 'flutes', 'transverse flute'],
'french': ['flûte', 'flûte traversière', 'flûtes', 'grande flûte'],
'german': ['flöte', 'flöten', 'querflöte'],
'italian': ['flauti', 'flauto', 'flauto traverso'],
'russian': ['fleita'],
'spanish': ['flauta', 'flauta de boehm', 'flauta de concierto',
            'flauta traversa', 'flauta travesera', 'flautas'],
'abbreviation': ['fl']}

Alternatively, you can specify the language to search using the `language`
argument.

>>> instrument.getAllNamesForInstrument(instrument.Flute(), language='german')
{'german': ['flöte', 'flöten', 'querflöte']}

An InstrumentException is raised if the specified language is not
one of those currently supported:
'english', 'french', 'german', 'italian', 'russian', 'spanish', and 'abbreviation'.

Note that the language string is not case-sensitive, so 'German' is also fine.

rE   rY  rZ  )r9  r6   rE  rN  rz  rN   r	   )instrumentClassrf  instrumentNameDictinstrumentClassNamelangs        r    getAllNamesForInstrumentr  	  s    J ~~H)88>B>%%%"D~))),45H,Os4y) #  
	'!$4XJ>W"XYY'/0C^T\E]'^$r!   c                      \ rS rSrSrg)TestExternali
  r+   Nr-  r+   r!   r    r  r  
  r.  r!   r  c                  J    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)Testi
  c                2    SSK Jn  U" U [        5       5        g )Nr   )testCopyAll)music21.test.commonTestr  globals)r@   r  s     r    testCopyAndDeepcopyTest.testCopyAndDeepcopy
  s    7D')$r!   c                   SSK Jn  UR                  " 5       n[        5       nSUl        UR                  U5        UR                  [        R                  " 5       S5        UR                  " 5       n[        5       nSUl        UR                  U5        UR                  [        R                  " S5      S5        UR                  " 5       nUR                  SU5        UR                  SU5        g )Nr   r   testr  test2g4)r  r   r  r   r0   rF   repeatAppendr   Noter   r%  r   )r@   r   s1i1s2i2s3s          r    testMusicXMLExportTest.testMusicXMLExport
  s    "]]_X
		"
		R( ]]_W
		"
		$,\\^
		!R
		!Rr!   c                j   SSK Jn  SSK Jn  UR                  " 5       nUR                  " 5       nUR                  UR                  5       5        UR                  " 5       nUR                  UR                  5       5        UR                  SU5        UR                  SU5        UR                  U5      nU R                  [        U5      S5        U R                  [        UR                  5       R                  UR                  5      5      S5        UR                  " 5       nUR                  SUR!                  5       5        UR                  SUR#                  5       5        UR                  U5      nU R                  [        U5      S5        U R                  [        XaR                     5      S5        g )Nr   r   r   r   r   )r  r   r   r%  r!  rF   r   r  r   r;  assertEqualrm   r&  r  r$   r  r  r   r@   r   r   r   p1p2r4  s          r    testPartitionByInstrumentATest.testPartitionByInstrumentA1
  s=   &" LLN[[]
		*""$%[[]
		*$$&'	B	B//2TA&T\\^>>z?T?TUVXYZ
 MMO	J'')*	Z))+,//2TA&T"7"7891=r!   c                H   SSK Jn  SSK Jn  UR                  " 5       nUR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " 5       S5        UR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " 5       S5        UR                  SU5        UR                  SU5        UR                  U5      nU R                  [        U5      S5        U R                  [        XaR                     5      S5        U R                  [        UR                   S   R"                  5      S5        U R                  [        UR                   S   R"                  5      S5        g )Nr   r  r   r   rH  r   rj   )r  r   r   r%  r!  rF   r   r  r   r  r  r   r;  r  rm   r$   partsnotesr  s          r    testPartitionByInstrumentBTest.testPartitionByInstrumentBO
  s   &" LLN[[]
		*""$%
		Q'[[]
		*$$&'
		R(	B	B//2TA&T"7"7891=TZZ]00115TZZ]00126r!   c                   SSK Jn  SSK Jn  UR                  " 5       nUR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " S5      S	5        UR                  UR                  5       5        UR                  [        R                  " S
5      S5        UR                  SU5        UR                  SU5        UR                  U5      nU R                  [!        U5      S5        U R                  [!        XaR"                     5      S5        U R                  UR$                  S   R'                  5       R(                  S5        U R                  [!        UR$                  S   R*                  5      S5        U R                  UR$                  S   R'                  5       R(                  S5        U R                  [!        UR$                  S   R*                  5      S5        U R                  UR$                  S	   R'                  5       R(                  S5        U R                  [!        UR$                  S	   R*                  5      S	5        U R                  UR$                  S   R'                  5       R(                  S5        U R                  [!        UR$                  S   R*                  5      S5        g )Nr   r  r   ar   br  cr   dr  r   rj   r3  r  r  )r  r   r   r%  r!  rF   r   r  r   r  r1  r  r  r   r;  r  rm   r$   r  getInstrumentr6   r  r  s          r    testPartitionByInstrumentCTest.testPartitionByInstrumentCe
  s\   &" LLN[[]
		*""$%
		#*
		*++-.
		#*[[]
		*$$&'
		#*
		*""$%
		#*	B	B//2TA&T"7"7891=A446EEwOTZZ]00115A446EEGXYTZZ]00115A446EEyQTZZ]00115A446EEwOTZZ]00115r!   c                   SSK Jn  SSK Jn  UR                  " 5       nUR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  UR                  5       5        UR                  [        R                  " S5      S	5        UR                  " 5       nUR                  UR                  5       5        UR                  [        R                  " S
5      S5        UR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  UR                  5       5        UR                  [        R                  " S5      S5        UR                  SU5        UR                  SU5        UR                  U5      nU R                  [!        U5      S5        U R                  [!        XaR"                     5      S5        U R                  UR$                  S   R'                  5       R(                  S5        U R                  [!        UR$                  S   R*                  5      S5        U R                  UR$                  S   R*                   Vs/ s H  owR,                  PM     sn/ SQ5        g s  snf )Nr   r  r   r  r   r  r  r  r  r  r   r  r  frj   r   rH  )              ?       @      @      @      @g      @      "@      $@      &@      (@      *@)r  r   r   r%  r!  rF   r   r  r   r  r1  r  r  r   r;  r  rm   r$   r  r  r6   r  r   )r@   r   r   r   r  r  r4  ns           r    testPartitionByInstrumentDTest.testPartitionByInstrumentD
  s   &" LLN[[]
		*""$%
		#*
		*++-.
		#*
		*""$%
		#*[[]
		*$$&'
		#*
		*""$%
		#*
		*""$%
		#*	B	B//2TA&T"7"7891=A446EEwOTZZ]00126DJJqM,?,?@,?q((,?@Y	[@s   $Lc                   SSK Jn  SSK Jn  UR                  " 5       nUR	                  UR                  5       5        UR                  [        R                  " S5      S5        UR	                  UR                  5       5        UR                  [        R                  " S5      S5        UR	                  UR                  5       5        UR                  [        R                  " S5      S	5        UR	                  UR                  5       5        UR                  [        R                  " S
5      S5        UR	                  UR                  5       5        UR                  [        R                  " S5      S5        UR	                  UR                  5       5        UR                  [        R                  " S5      S5        UnUR                  U5      nU R                  [        U5      S5        U R                  [        XQR                     5      S5        U R                  UR                   S   R#                  5       R$                  S5        U R                  [        UR                   S   R&                  5      S5        / nUR                   S   R&                  nU H  nUR	                  UR(                  5        M      U R                  U/ SQ5        g )Nr   r  r   r  r   r  r  r  r  r  r   r  r  r  rj   r   rH  )r  r  r  r  r  r  r  r  r  r  r  g      4@)r  r   r   r!  rF   r   r  r   r  r1  r  r  r;  r  rm   r$   r  r  r6   r  r   )	r@   r   r   r  r   r4  
offsetListppnr  s	            r    testPartitionByInstrumentETest.testPartitionByInstrumentE
  s   &" [[]
		*""$%
		#*
		*++-.
		#*
		*""$%
		#*
		*$$&'
		#*
		*""$%
		#*
		*""$%
		#*//2TA&T"7"7891=A446EEwOTZZ]00126
jjm!!Aahh'  	Z	\r!   c                   SSK Jn  SSK Jn  UR                  " 5       nUR	                  UR                  5       5        UR	                  [        R                  " 5       5        UR	                  UR                  5       5        UR	                  [        R                  " 5       5        UR                  U5      nU R                  [        U5      S5        g )Nr   r  r   r   )r  r   r   r  rF   r1  r   r  r  r;  r  rm   )r@   r   r   r  r4  s        r    testPartitionByInstrumentFTest.testPartitionByInstrumentF
  s    &"]]_
		*++-.
		$))+
		*//#$
		$))+//3TA&r!   c                   SSK Jn  SnU R                  UR                  U5      R                  U5        SS/nU H-  nUR                  X$S9R                  nU R                  XR5        M/     SS/nU H#  nU R                  [        UR                  UUS9  M%     UR                  5       nU R                  UR                  U[        R                  S9S	S
/05        U R                  [        UR                  USS9  g )Nr   r  
KlarinetterI  German)rf  rH  finnishrM  fl)r  r   r  rs  r6   assertRaisesr	   r  r  rE  rU  )r@   r   
testStringworkingExampleslangStr	instrNamefailingExamplesr  s           r    testLanguageChoiceTest.testLanguageChoice
  s!   & "
 	..z:II#	% $# 'G"--j-KZZIY3 ' $$ 'G1(33('.  0 ' !<<TFTFaFa = c(4&1	3 	-$==#, 	 	.r!   r+   N)ru   rv   rw   rx   r  r  r  r  r  r  r  r  r  r{   r+   r!   r    r  r  
  s5    %,><7, 6J"[N%\N'H(.r!   r  __main__)r   stream.Streamreturnzstream.Stream | None)F)r   r  r   boolr  r  )r  r  r  r$   )r0  r  r  r  )r?  rN   rf  rE  )rv  rN   rf  rE  )r|  r$   rf  rE  )ry   
__future__r   collectionsr   collections.abcr   ra  unittesttypingtr  r   r   r   music21.exceptions21r	   r
   r   r   music21.tree.treesr   TYPE_CHECKINGr   EnvironmentenvironLocalr   r#   rc  r$   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r!  r(  r1  r7  r<  rA  rF  rK  rS  rZ  r`  rg  rn  rt  ry  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  r&  r,  rh   r?  rE  rK  rP  rU  r[  r`  rf  rl  rq  rv  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  r  r!  r'  r+  r/  r3  r7  r;  rB  rG  rL  rR  rW  r\  ra  rg  r  r  r  r  r  r;  rC  enumsStrEnumrE  rN  rs  rz  r  TestCaser  r  
_DOC_ORDERru   mainTestr+   r!   r    <module>r     s    # # $       4    )??&&|4
 !&$*<$R $'(:'T@## @N0 0- -*
-$ 
-5# 52  2  E *0J 0	- 	-	-E 	-
- 
-
- 
-
-
 
-4z 4n
7 
7
7 
7
7" 
76! 6&
. 
.
C 
C7V 77V 7
76 
7
76 
7
76 
7	7 	7	7 	76 6    + +	, 	,
5e 
5	,u 	,u  
e 
e 	- 	-
6$ 
6
6! 
668 6,	-  	-	-G 	-	-" 	-	6y 	6	6I 	6	6Y 	6	7	 	7!   j 6? 6.
6o 
6	, 	,-8 -	,? 	,- -	
 	4	* 4	n"  ! $ # $ , ,>! >  !   I# I 3% 30# 0/! /# ,! ,5G 5I7 I&8g 857 55G 53' 3I' I.I" I&! 	 	.  .:% :I# I(1# 1I$ II  I I" II# II" I $ - -0! 0. .1) 1-% -
z 
/h /57 5,8 ,-H -0x 0,8 ,H A
 A3 @0&i i^AuAuA }A u	A
 }A }A {A zA wA |A A 
A A 	A A  !A" #A$ %A& 'A( 	)A* 	+A, 	-A. 	/A0 	1A2 3A4 5A6 7A8 9A: ;A< =A> ?A@ AAB CAD EAF GAH IAJ KAL MAN OAP QAR SAT UAV WAX 
YAZ [A\ ]A^ _A` aAb cAd eAf gAh iAj kAl mAn oAp qAr sAt uAv wAx yAz {A| }A~ A@ AAB CAD EAF GAH IAJ KAL MAN OAP QAR SAT UAV WAX YAZ [A\ 
]A^ _A` aAb cAd eAf gAh iAj kAl mAn oAp qAr sAt uAv wAx yAz {A| }A~ A@ AAB CAD EAF GAH IAJ KAL MAN OAP QAR SAT UAV WAX YAZ [A\ ]A^ _A` aAb cAd eAf gAh iAj kAl mAn oAp 
								AA H@K\	"V\\)) " +9*<*<h'hX )7(:(:%, 9G8J8J4'54p	8$$ 	O.8 O.h \
zT	 r!   