§
    ƒØj4#  ã                  óâ   — d dl mZ d dlZd dlmZ d dlmZ d dlmZ  G d„ dej        ¦  «        Z G d„ d	¦  «        Z	 G d
„ dej
        ¦  «        Ze	gZedk    rd dlZ ej        e¦  «         dS dS )é    )ÚannotationsN)Úpitch)Úexceptions21)Ú
instrumentc                  ó   — e Zd ZdS )ÚMIDIPercussionExceptionN)Ú__name__Ú
__module__Ú__qualname__© ó    úŒ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/midi/percussion.pyr   r      s   € € € € € Ø€Dr   r   c                  ód  — e Zd ZdZeZi dej        “dej        “dej        “dej        “dej        “dej        “dej	        “d	ej        “d
ej	        “dej        “dej	        “dej        “dej        “dej
        “dej        “dej        “dej        “i dej
        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “dej        “d ej        “d!ej        “d"ej        “d#ej        “¥d$ej        i¥Zd%„ Zd&„ ZeegZd'S )(ÚPercussionMapperaV  
    PercussionMapper provides tools to convert between 0-indexed MIDI pitches
    and music21 instruments, based on the official General MIDI Level 1 Percussion Key Map.
    This mapping is conventionally applied to MIDI channel 10;
    see https://midi.org/general-midi-level-1 for more info.

    Give me the instrument that corresponds to MIDI note 58!

    >>> pm = midi.percussion.PercussionMapper()
    >>> pm.reverseInstrumentMapping[58]
    <class 'music21.instrument.Vibraslap'>

    That's right, vibraslap.

    But you're better off using the midiPitchToInstrument() method below!
    é#   é$   é%   é&   é(   é)   é*   é+   é,   é-   é.   é/   é0   é1   é2   é6   é8   é9   é:   é<   é=   é>   é?   é@   éA   éB   éC   éD   éF   éG   éH   éL   éM   éP   éQ   c                ó  — t          |t          ¦  «        r|}n|j        }|| j        vrt	          |›d�¦  «        ‚| j        |         } |¦   «         }|j        du r-t          |d¦  «        r||j        v r|j        |         }||_        |S )a´  
        Takes a pitch.Pitch object or int ranging from 0-127 and returns
        the corresponding instrument in the GM Percussion Map.

        >>> pm = midi.percussion.PercussionMapper()
        >>> cowPitch = pitch.Pitch(56)
        >>> cowbell = pm.midiPitchToInstrument(cowPitch)
        >>> cowbell
        <music21.instrument.Cowbell 'Cowbell'>

        Or it can just take an integer (representing MIDI note) for the pitch instead:

        >>> moreCowbell = pm.midiPitchToInstrument(56)
        >>> moreCowbell
        <music21.instrument.Cowbell 'Cowbell'>

        The standard GM Percussion list goes from 35 to 81;
        pitches outside this range raise an exception.

        >>> bassDrum1Pitch = pitch.Pitch('B-1')
        >>> pm.midiPitchToInstrument(bassDrum1Pitch)
        Traceback (most recent call last):
        music21.midi.percussion.MIDIPercussionException: 34 does not map to a valid instrument!

        Also, certain GM instruments do not have corresponding music21 instruments,
        so at present they also raise an exception.

        >>> cabasaPitch = 69
        >>> pm.midiPitchToInstrument(cabasaPitch)
        Traceback (most recent call last):
        music21.midi.percussion.MIDIPercussionException: 69 does not map to a valid instrument!

        Some music21 Instruments have more than one MidiPitch.  In this case you'll
        get the same Instrument object but with a different modifier

        >>> acousticBassDrumPitch = pitch.Pitch(35)
        >>> acousticBDInstrument = pm.midiPitchToInstrument(acousticBassDrumPitch)
        >>> acousticBDInstrument
        <music21.instrument.BassDrum 'Bass Drum'>
        >>> acousticBDInstrument.modifier
        'acoustic'

        >>> oneBassDrumPitch = pitch.Pitch(36)
        >>> oneBDInstrument = pm.midiPitchToInstrument(oneBassDrumPitch)
        >>> oneBDInstrument
        <music21.instrument.BassDrum 'Bass Drum'>
        >>> oneBDInstrument.modifier
        '1'

        z$ does not map to a valid instrument!TÚ_percMapPitchToModifier)	Ú
isinstanceÚintÚmidiÚreverseInstrumentMappingr   ÚinGMPercMapÚhasattrr5   Úmodifier)ÚselfÚ	midiPitchÚ
midiNumberÚmidiInstrumentÚmidiInstrumentObjectr<   s         r   ÚmidiPitchToInstrumentz&PercussionMapper.midiPitchToInstrumenta   s²   € õh �i¥Ñ%Ô%ð 	(Ø"ˆJˆJà"œˆJØ˜TÔ:Ð:Ð:Ý)¨ZÐ*_Ð*_Ð*_Ñ`Ô`Ð`ØÔ6°zÔBˆà-˜~Ñ/Ô/ÐØ Ô,°Ð4Ð4ÝÐ0Ð2KÑLÔLð 5àÐ1ÔIÐIÐIØ/ÔGÈ
ÔS�Ø08Ð$Ô-à#Ð#r   c                óž   — t          |d¦  «        r	|j        du rt          |›d�¦  «        ‚|j        }t	          j        ¦   «         }||_        |S )a“  
        Takes an instrument.Instrument object and returns a pitch object
        with the corresponding 1-indexed MIDI note, according to the GM Percussion Map.

        >>> pm = midi.percussion.PercussionMapper()
        >>> myCow = instrument.Cowbell()
        >>> cowPitch = pm.midiInstrumentToPitch(myCow)
        >>> cowPitch.midi
        56

        Note that cowPitch is an actual pitch.Pitch object
        even though it's meaningless!

        >>> cowPitch
        <music21.pitch.Pitch G#3>

        If the instrument does not have an equivalent in the GM Percussion Map,
        return an Exception:

        >>> myBagpipes = instrument.Bagpipes()
        >>> pipePitch = pm.midiInstrumentToPitch(myBagpipes)
        Traceback (most recent call last):
        music21.midi.percussion.MIDIPercussionException: <music21.instrument.Bagpipes 'Bagpipes'>
            is not in the GM Percussion Map!
        r:   Fz! is not in the GM Percussion Map!)r;   r:   r   ÚpercMapPitchr   ÚPitchr8   )r=   r@   r>   ÚpitchObjects       r   ÚmidiInstrumentToPitchz&PercussionMapper.midiInstrumentToPitch¦   s]   € õ4 �~ }Ñ5Ô5ð 	b¸Ô9SÐW\Ð9\Ð9\Ý)¨^Ð*`Ð*`Ð*`ÑaÔaÐaØ"Ô/ˆ	Ý”k‘m”mˆØ$ˆÔØÐr   N)r	   r
   r   Ú__doc__r   ÚiÚBassDrumÚ	SnareDrumÚTomTomÚHiHatCymbalÚCrashCymbalsÚ
TambourineÚCowbellÚ	VibraslapÚ
BongoDrumsÚ	CongaDrumÚTimbalesÚAgogoÚMaracasÚWhistleÚ	WoodblockÚTriangler9   rB   rG   Ú
_DOC_ORDERr   r   r   r   r      s\  € € € € € ðð ð" 	€Að/ "  A¤Jð / "Ø " A¤Jð/ "à " A¤Kð/ "ð !# A¤Kð/ "ð
 !# A¤Kð/ "ð !# A¤Hð/ "ð !# A¤Mð/ "ð !# A¤Hð/ "ð !# A¤Mð/ "ð !# A¤Hð/ "ð !# A¤Mð/ "ð !# A¤Hð/ "ð !# A¤Hð/ "ð !# A¤Nð/ "ð !# A¤Hð/ "ð& !# A¤Lð'/ "ð* !# A¤Ið+/ "ð / "ð, !# A¤Nð-/ "ð. !# A¤Kð// "ð2 !# A¤Lð3/ "ð4 !# A¤Lð5/ "ð6 !# A¤Kð7/ "ð8 !# A¤Kð9/ "ð: !# A¤Kð;/ "ð< !# A¤Jð=/ "ð> !# A¤Jð?/ "ð@ !# A¤GðA/ "ðB !# A¤GðC/ "ðF !# A¤IðG/ "ðH !# A¤IðI/ "ðJ !# A¤IðK/ "ðR !# A¤KðS/ "ðT !# A¤KðU/ "ðZ !# A¤Jð[/ "ð / "ð\ !# A¤Jð]/ "ð / "ÐðlC$ð C$ð C$ðJð ð ðB (Ð)>Ð?€J€J€Jr   r   c                  ó   — e Zd Zd„ ZdS )ÚTestc                óB   — ddl m}  || t          ¦   «         ¦  «         d S )Nr   )ÚtestCopyAll)Úmusic21.test.commonTestr^   Úglobals)r=   r^   s     r   ÚtestCopyAndDeepcopyzTest.testCopyAndDeepcopyÌ   s0   € Ø7Ð7Ð7Ð7Ð7Ð7Øˆ�D�'™)œ)Ñ$Ô$Ð$Ð$Ð$r   N)r	   r
   r   ra   r   r   r   r\   r\   Ê   s#   € € € € € ð%ð %ð %ð %ð %r   r\   Ú__main__)Ú
__future__r   ÚunittestÚmusic21r   r   r   ÚMusic21Exceptionr   r   ÚTestCaser\   rZ   r	   ÚmainTestr   r   r   ú<module>ri      s,  ðð #Ð "Ð "Ð "Ð "Ð "à €€€à Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð ð	ð 	ð 	ð 	ð 	˜lÔ;ñ 	ô 	ð 	ðo@ð o@ð o@ð o@ð o@ñ o@ô o@ð o@ðd%ð %ð %ð %ð %ˆ8Ôñ %ô %ð %ð Ð€
ð ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr   