
    rh                        S r SSKJr  SSKrSSKJs  J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  \R                   (       a  SSKJr   " S	 S
5      r\S:X  a  SSK
r
\
R*                  " 5         gg)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                  ^    \ rS rSrSrSS jr          S	S jr          S	S jrSrg)
SoundTagMixin!   z
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.
c                   [         R                  (       a,  [        U [        5      (       a  [        U [        5      (       d   eU R                  U5      nX R                  -   nU R                  U5      nU R                  USUU5        g)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)selfmxSoundoffsetDirectiontotalOffsetstaffKeys        Y/home/james-whalen/.local/lib/python3.13/site-packages/music21/musicxml/xmlSoundParser.pyxmlSoundSoundTagMixin.xmlSound'   sq     ??dM22z$7V7VVV **73%(>(>>&&w/g!	#    c                    [         R                  (       a,  [        U [        5      (       a  [        U [        5      (       d   eSUR
                  ;   a  U R                  XX45        gg)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   mxDirr   r   s        r   r   SoundTagMixin.setSound;   sM     ??dM22z$7V7VVV& gnn$wxE %r   c                Z   [         R                  (       a,  [        U [        5      (       a  [        U [        5      (       d   e[
        R                  " [        UR                  SS5      5      5      nUS:X  a  [        R                  " S5        g[        R                  " [        R                  " SS9SUS9n[        R                   " X5        U R#                  X5        U R%                  X5        Ub)  [        R&                  " XbSS5        U R)                  X&5        U R+                  XCU5        g)	zA
Add a metronome mark from the tempo attribute of a <sound> tag.
r   r   z 0 qpm tempo tag found, skipping.Nquarter)type)referentnumbernumberSounding	placement)r   r   r   r   r
   r   numToIntOrFloatfloatgetwarningswarnr   MetronomeMarkr   Durationr   synchronizeIdsToM21setPrintObjectsetPositionsetM21AttributeFromAttributesetEditorialinsertCoreAndRef)r   r   r    r   r   qpmmms          r   r   SoundTagMixin.setSoundTempo`   s     ??dM22z$7V7VVV$$U7;;w+B%CD!8MM<=  (*;*;*K(,03# 	##G0G(%00; e(kR8r    N)r   
ET.ElementreturnNone)
r   r:   r    zET.Element | Noner   intr   r*   r;   r<   )	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r9   r   r   r
   r
   !   s}    
#("F"F "F 	"F
 "F 
"FJ99 9 	9
 9 
9r   r
   __main__)rB   
__future__r   typingr   xml.etree.ElementTreeetreeElementTreeETr,   music21r   r   r   music21.musicxmlr   r   music21.musicxml.xmlToM21r   r
   r>   mainTestr9   r   r   <module>rO      s\    #  " "     $??7\9 \9~ z r   