
    rh                       S r SSKJr  SSKJr  SSKrSSKrSSKJ	r	  SSKJ
r
  SSKJr  \R                  (       a  SSKJr   " S	 S
\
R                  5      r " S S\R                   5      r\S:X  a  SSKr\R&                  " \5        gg)z
This module contains classes for representing unpitched events such as percussion.
For backwards compatibility reasons, the module does not contain the actual
:class:`~music21.note.Unpitched` which is in the `note` module.
    )annotations)IterableN)common)chord)note)pitchc                     ^  \ rS rSrSrSrSU 4S jjrU 4S jrS r\	SS j5       r
\
R                  SS j5       r
SU 4S	 jjr\	SS
 j5       r\R                  SS j5       rSrU =r$ )PercussionChord!   a$  
A representation of one or (normally) more than one unpitched object sharing a stem
and treated like a "chord."  It may also contain standard notes (pitches) for cases
such as a percussionist playing a cymbal and marimba at the same time.

It is a :class:`~music21.chord.ChordBase` and `:class:`~music21.note.NotRest` subclass
that is NOT a :class:`~music21.chord.Chord` because one or more
notes is an :class:`~music21.note.Unpitched`
object.

>>> vibraslapNote = note.Unpitched(displayName='D4', storedInstrument=instrument.Vibraslap())
>>> pChord = percussion.PercussionChord([vibraslapNote, note.Note('E5')])
>>> pChord
<music21.percussion.PercussionChord [Vibraslap E5]>

>>> pChord.isChord
False

A PercussionChord has "notes," just like anything deriving from ChordBase.  Some of these
are Unpitched objects.

>>> pChord.notes
(<music21.note.Unpitched 'Vibraslap'>, <music21.note.Note E>)

The same notes can also be assigned to another PercussionChord:

>>> pChord2 = percussion.PercussionChord()
>>> pChord2.notes = pChord.notes
>>> pChord2.notes
(<music21.note.Unpitched 'Vibraslap'>, <music21.note.Note E>)

Don't attempt setting anything but Note or Unpitched objects as notes:

>>> pChord2.notes = [note.Rest()]
Traceback (most recent call last):
TypeError: every element of notes must be a note.Note or note.Unpitched object

**Equality**

Two PercussionChord objects are equal if their notes are equal *and in the same
order* (this is different from Chord, but necessary because we cannot compare
based just on pitch equality)

>>> pChord == pChord2
True
>>> pChord3 = percussion.PercussionChord([note.Unpitched('D4')])
>>> pChord == pChord3
False

OMIT_FROM_DOCS

See the repr of an empty percussion chord:

>>> percussion.PercussionChord()
<music21.percussion.PercussionChord object at 0x...>

This is in OMIT
Fc                T   > [         TU ]  US9nUR                   H	  nX#l        M     U$ )N)memo)super__deepcopy___notes_chordAttached)selfr   newn	__class__s       L/home/james-whalen/.local/lib/python3.13/site-packages/music21/percussion.pyr   PercussionChord.__deepcopy__^   s.    g""-A" 
    c                   > [         TU ]  U5      (       d  g[        U R                  UR                  5       H  u  p#X#:w  d  M    g   g)z@
Returns True if all the notes are equal and in the same order.
FT)r   __eq__zipnotes)r   othermy_nother_nr   s       r   r   PercussionChord.__eq__d   s?     w~e$$ U[[9MD : r   c                    [        U 5      S-	  $ )N   )idr   s    r   __hash__PercussionChord.__hash__p   s    $x1}r   c                ,    [        U R                  5      $ Ntupler   r$   s    r   r   PercussionChord.notess   s    T[[!!r   c                    [         R                  " U5      (       d  [        S5      e[        S U 5       5      (       d  [        S5      eU R                  R                  5         U R                  U5        g)z8
Sets notes to an iterable of Note or Unpitched objects
z"notes must be set with an iterablec              3  v   #    U  H/  n[        U[        R                  [        R                  45      v   M1     g 7fr(   )
isinstancer   	UnpitchedNote).0r   s     r   	<genexpr>(PercussionChord.notes.<locals>.<genexpr>~   s'     Px!:a$..$))!<==xs   79zCevery element of notes must be a note.Note or note.Unpitched objectN)r   
isIterable	TypeErrorallr   clearadd)r   newNotess     r   r   r+   w   sZ    
   **@AAPxPPPabbr   c                  > U R                   (       d  [        TU ]	  5       $ / nU R                    H  n[        U[        R
                  5      (       a  UR                  UR                  5        M?  [        U[        R                  5      (       d  M`  UR                  (       a0  UR                  [        UR                  R                  5      5        M  UR                  SUR                   S35        M     SSR                  U5      -   S-   $ )Nz
unpitched[][ )r   r   _reprInternalr.   r   r0   appendnameWithOctaver/   storedInstrumentstrinstrumentNamedisplayNamejoin)r   allNotesthisNoter   s      r   r>   PercussionChord._reprInternal   s    zz7(**

H(DII.. 7 78Hdnn55,,OOC(A(A(P(P$QROOj1E1E0Fa$HI # SXXh''#--r   c                >    [        S U R                   5       5      nU$ )a  
Get or set a list or tuple of all Pitch objects in this PercussionChord.

Unpitched members (that at most have only display pitches) are ignored.

>>> pChord = percussion.PercussionChord([note.Unpitched(displayName='D4'), note.Note('E5')])
>>> pChord.pitches
(<music21.pitch.Pitch E5>,)

>>> pChord.pitches = [60]
>>> pChord.pitches
(<music21.pitch.Pitch C4>,)

Notice that setting pitches has now just cleared any existing notes, pitched or unpitched:

>>> pChord.notes
(<music21.note.Note C>,)
c              3  |   #    U  H2  n[        U[        R                  5      (       d  M$  UR                  v   M4     g 7fr(   )r.   r   r0   r   )r1   	components     r   r2   *PercussionChord.pitches.<locals>.<genexpr>   s*      1^-8	JyRVR[R[<\OIOO[s   #<<r)   )r   pitchess     r   rM   PercussionChord.pitches   s'    ( ,1 1^-1[[1^ ,^r   c                    / U l         U H2  nU R                   R                  [        R                  " U5      5        M4     g r(   )r   r?   r   r0   )r   valueps      r   rM   rN      s-    AKKtyy|, r   )r   r(   )returnztuple[note.NotRest, ...])r9   z$Iterable[note.Unpitched | note.Note]rR   None)rR   rB   )rR   ztuple[pitch.Pitch, ...])rP   zt.Iterable[pitch.Pitch]rR   rS   )__name__
__module____qualname____firstlineno____doc__isChordr   r   r%   propertyr   setterr>   rM   __static_attributes____classcell__)r   s   @r   r
   r
   !   s|    9t G
 " " \\	 	."  . ^^- -r   r
   c                      \ rS rSrSrg)Test    N)rT   rU   rV   rW   r\   ra   r   r   r_   r_      s    r   r_   __main__)rX   
__future__r   collections.abcr   typingtunittestmusic21r   r   r   TYPE_CHECKINGr   	ChordBaser
   TestCaser_   rT   mainTestra   r   r   <module>rm      sr   
 # $      ??Q-eoo Q-h	8 	 zT r   