§
    ƒØjõ  ã                  óÒ   — d Z ddlmZ ddlZddlmc mZ ddl	Z	ddl
mZ ddl
mZ ddl
mZ ddlmZ ej        rddlmZ  G d	„ d
¦  «        Zedk    rddl
Z
 e
j        ¦   «          dS dS )z”
Functions that convert <sound> tag to the many music21
objects that this tag might represent.

Pulled out because xmlToM21 is getting way too big.
é    )ÚannotationsN)Úcommon)Úduration)Útempo)Úhelpers)ÚMeasureParserc                  ó*   — e Zd ZdZdd„Zdd„Zdd„ZdS )ÚSoundTagMixinz¥
    This Mixin is applied to MeasureParser -- it is moved
    out from there because there is still a lot to write
    here and xmlToM21.py is getting too big.
    ÚmxSoundú
ET.ElementÚreturnÚNonec                ó  — t           j        r,t          | t          ¦  «        rt          | t          ¦  «        sJ ‚|                      |¦  «        }|| j        z   }|                      |¦  «        }|                      |d||¦  «         dS )zª
        Convert a <sound> tag to one or more relevant objects
        (presently just MetronomeMark),
        and add it or them to the core and staffReference.
        N)	ÚtÚTYPE_CHECKINGÚ
isinstancer   r
   ÚxmlToOffsetÚoffsetMeasureNoteÚgetStaffNumberÚsetSound)Úselfr   ÚoffsetDirectionÚtotalOffsetÚstaffKeys        ú”/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/musicxml/xmlSoundParser.pyÚxmlSoundzSoundTagMixin.xmlSound&   s”   € õ Œ?ð 	WÝ˜d¥MÑ2Ô2ÐVµzÀ$ÍÑ7VÔ7VÐVÐVÐVð ×*Ò*¨7Ñ3Ô3ˆØ%¨Ô(>Ñ>ˆà×&Ò& wÑ/Ô/ˆà�Š�gØØØ!ñ	#ô 	#ð 	#ð 	#ð 	#ó    ÚmxDirúET.Element | Noner   Úintr   Úfloatc                ó¼   — t           j        r,t          | t          ¦  «        rt          | t          ¦  «        sJ ‚d|j        v r|                      ||||¦  «         dS dS )a/  
        Takes a <sound> tag and creates objects from it.
        Presently only handles <sound tempo='x'> events and inserts them as MetronomeMarks.
        If the <sound> tag is a child of a <direction> tag, the direction information
        is used to set the placement of the MetronomeMark.
        r   N)r   r   r   r   r
   ÚattribÚsetSoundTempo)r   r   r   r   r   s        r   r   zSoundTagMixin.setSound:   sk   € õ Œ?ð 	WÝ˜d¥MÑ2Ô2ÐVµzÀ$ÍÑ7VÔ7VÐVÐVÐVð& �g”nÐ$Ð$Ø×Ò˜w¨¨x¸ÑEÔEÐEÐEÐEð %Ð$r   c                ó~  — t           j        r,t          | t          ¦  «        rt          | t          ¦  «        sJ ‚t          j        t          |                     dd¦  «        ¦  «        ¦  «        }|dk    rt          j
        dd¬¦  «         dS t          j        t          j        d¬¦  «        d|¬	¦  «        }t          j        ||¦  «         |                      ||¦  «         |                      ||¦  «         |�-t          j        ||d
d
¦  «         |                      ||¦  «         |                      |||¦  «         dS )zQ
        Add a metronome mark from the tempo attribute of a <sound> tag.
        r   r   z 0 qpm tempo tag found, skipping.é   )Ú
stacklevelNÚquarter)Útype)ÚreferentÚnumberÚnumberSoundingÚ	placement)r   r   r   r   r
   r   ÚnumToIntOrFloatr!   ÚgetÚwarningsÚwarnr   ÚMetronomeMarkr   ÚDurationr   ÚsynchronizeIdsToM21ÚsetPrintObjectÚsetPositionÚsetM21AttributeFromAttributeÚsetEditorialÚinsertCoreAndRef)r   r   r   r   r   ÚqpmÚmms          r   r$   zSoundTagMixin.setSoundTempo_   sF  € õ Œ?ð 	WÝ˜d¥MÑ2Ô2ÐVµzÀ$ÍÑ7VÔ7VÐVÐVÐVåÔ$¥U¨7¯;ª;°wÀÑ+BÔ+BÑ%CÔ%CÑDÔDˆØ�!Š8ˆ8ÝŒMÐ<ÈÐKÑKÔKÐKØˆFÝÔ ­(Ô*;ÀÐ*KÑ*KÔ*KØ(,Ø03ð#ñ #ô #ˆõ 	Ô# G¨RÑ0Ô0Ð0Ø×Ò˜G RÑ(Ô(Ð(Ø×Ò˜ "Ñ%Ô%Ð%ØÐÝÔ0Ø�E˜;¨ñô ð ð ×Ò˜e RÑ(Ô(Ð(Ø×Ò˜k¨8°RÑ8Ô8Ð8Ð8Ð8r   N)r   r   r   r   )
r   r   r   r   r   r    r   r!   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r$   © r   r   r
   r
       s_   € € € € € ðð ð
#ð #ð #ð #ð("Fð "Fð "Fð "FðJ9ð 9ð 9ð 9ð 9ð 9r   r
   Ú__main__)r?   Ú
__future__r   Útypingr   Úxml.etree.ElementTreeÚetreeÚElementTreeÚETr0   Úmusic21r   r   r   Úmusic21.musicxmlr   r   Úmusic21.musicxml.xmlToM21r   r
   r<   ÚmainTestr@   r   r   ú<module>rL      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø €€€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à $Ð $Ð $Ð $Ð $Ð $à„?ð 8Ø7Ð7Ð7Ð7Ð7Ð7ð\9ð \9ð \9ð \9ð \9ñ \9ô \9ð \9ð~ ˆzÒÐØ€N€N€NØ€GÔÑÔÐÐÐð Ðr   