
    3j{L                       d Z ddl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
 ddlmZ dd	lmZ dd
lmZ ddlmZ  ej                  d      Z G d dej"                        Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d ee      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z  G d+ d,e      Z! G d- d.e      Z" G d/ d0e      Z# G d1 d2e      Z$ G d3 d4ee      Z% G d5 d6e      Z& G d7 d8e      Z' G d9 d:e'      Z( G d; d<e'      Z) G d= d>e'      Z* G d? d@e)      Z+ G dA dBe)      Z, G dC dDe)e(      Z- G dE dFe)      Z. G dG dHe)      Z/ G dI dJe)      Z0 G dK dLe/e*      Z1 G dM dNe)      Z2 G dO dPe2      Z3 G dQ dRe2      Z4 G dS dTe'      Z5 G dU dVe5e*      Z6 G dW dXejn                  e'      Z8 G dY dZejn                  e'      Z9 G d[ d\e5      Z: G d] d^e5      Z; G d_ d`e'      Z< G da dbe<      Z= G dc dde<      Z> G de dfe<      Z? G dg dhe?      Z@ G di dje?      ZA G dk dle<      ZB G dm dne'      ZC G do dpeC      ZD G dq dreC      ZE G ds dte'      ZF G du dveF      ZG G dw dxe'      ZH G dy dzej                        ZJegZKeLd{k(  rddlZ ej                  eJ       yy)|a  
Classes for representing and processing articulations.
Specific articulations are modeled as :class:`~music21.articulations.Articulation` subclasses.

A :class:`~music21.note.Note` object has an :attr:`~music21.note.Note.articulations` attribute.
This list can be used to store one or more :class:`music21.articulations.Articulation` subclasses.

As much as possible, MusicXML names are used for Articulation classes,
with xxx-yyy changed to XxxYyy.  For instance, "strong-accent" in
MusicXML is "StrongAccent" here.

Fingering and other playing marks are found here.  Fermatas, trills, etc.
are found in music21.expressions.

>>> n1 = note.Note('D#4')
>>> n1.articulations.append(articulations.Tenuto())
>>> #_DOCS_SHOW n1.show()

>>> c1 = chord.Chord(['C3', 'G4', 'E-5'])
>>> c1.articulations = [articulations.OrganHeel(), articulations.Accent()]
>>> #_DOCS_SHOW c1.show()

A longer test showing the utility of the module:

>>> s = stream.Stream()
>>> n1 = note.Note('c#5')
>>> n1.articulations = [articulations.Accent()]
>>> n1.quarterLength = 1.25
>>> s.append(n1)

>>> n2 = note.Note('d5')
>>> n2.articulations = [articulations.StrongAccent()]
>>> n2.quarterLength = 0.75
>>> s.append(n2)

>>> n3 = note.Note('b4')
>>> n3.articulations = [articulations.Staccato()]
>>> n3.quarterLength = 1.25
>>> n3.tie = tie.Tie('start')
>>> s.append(n3)

>>> n4 = note.Note('b4')
>>> n4.articulations = [articulations.Staccatissimo()]
>>> n4.quarterLength = 0.75
>>> s.append(n4)

>>> n5 = note.Note('a4')
>>> n5.articulations = [articulations.Tenuto()]
>>> n5.quarterLength = 4/3
>>> s.append(n5)

>>> n6 = note.Note('b-4')
>>> n6.articulations = [articulations.Staccatissimo(), articulations.Tenuto()]
>>> n6.quarterLength = 2/3
>>> s.append(n6)

>>> s.metadata = metadata.Metadata()
>>> s.metadata.title = 'Prova articolazioni'  # ital: 'Articulation Test'
>>> s.metadata.composer = 'Giuliano Lancioni'

>>> #_DOCS_SHOW s.show()

.. image:: images/prova_articolazioni.*
    :width: 628
    )annotationsN)base)common)tempAttribute)OffsetQL)environment)interval)spanner)stylearticulationsc                       e Zd ZU dZej
                  Zded<   d fdZd Z	e
dd       Zd Zd Z e
eed	
      Z xZS )Articulationa
  
    Base class for all Articulation sub-classes.

    >>> x = articulations.Articulation()
    >>> x.placement = 'below'
    >>> x.style.absoluteY = 20
    >>> x.displayText = '>'

    **Equality**

    Equality of articulations is based only on the class, as other attributes are independent
    of context and deployment.

    >>> at1 = articulations.StrongAccent()
    >>> at2 = articulations.StrongAccent()
    >>> at1.placement = 'above'
    >>> at2.placement = 'below'
    >>> at1 == at2
    True

    Comparison between classes and with the object itself behaves as expected:

    >>> at3 = articulations.Accent()
    >>> at4 = articulations.Staccatissimo()
    >>> at1 == at3
    False
    >>> at4 == at4
    True

    OMIT_FROM_DOCS

    >>> at5 = articulations.Staccato()
    >>> at6 = articulations.Spiccato()
    >>> [at1, at4, at3] == [at1, at4, at3]
    True
    >>> [at1, at2, at3] == [at2, at3, at1]
    False
    >>> {at1, at2, at3} == {at2, at3, at1}
    True
    >>> at6 == True
    False

    This is in OMIT
    ztype[style.Style]_styleClassc                j    t        |   di | d | _        d| _        d| _        d| _        d | _        y )Ng        g      ?first )super__init__	placement_volumeShiftlengthShift	tieAttachdisplayTextselfkeywords	__class__s     B/DATA/.local/lib/python3.12/site-packages/music21/articulations.pyr   zArticulation.__init__   s9    $8$#&"%%%)    c                     y)N r   r   s    r   _reprInternalzArticulation._reprInternal   s    r   c                \    | j                   j                  }t        j                  |d      S )aj  
        returns the name of the articulation, which is generally the
        class name without the leading letter lowercase.

        Subclasses can override this as necessary.

        >>> st = articulations.Staccato()
        >>> st.name
        'staccato'

        >>> sp = articulations.SnapPizzicato()
        >>> sp.name
        'snap pizzicato'
         )replacement)r   __name__r   camelCaseToHyphen)r   	classNames     r   namezArticulation.name   s&      NN++	''	sCCr   c                    | j                   S Nr   r"   s    r   _getVolumeShiftzArticulation._getVolumeShift   s       r   c                >    |dkD  r
d}|| _         y |dk  rd}|| _         y )N   r-   )r   values     r   _setVolumeShiftzArticulation._setVolumeShift   s.    19E " RZE!r   a  
        Get or set the volumeShift of this Articulation. This value, between -1 and 1,
        that is used to shift the final Volume of the object it is attached to.


        >>> at1 = articulations.StrongAccent()
        >>> at1.volumeShift > 0.1
        True
        )doc)returnNone)r5   str)r'   
__module____qualname____doc__r   	TextStyler   __annotations__r   r#   propertyr*   r.   r3   volumeShift__classcell__r   s   @r   r   r   _   sZ    +X &+__K"4* D D$!" ?O B Kr   r   c                  "     e Zd ZdZ fdZ xZS )LengthArticulationzL
    Superclass for all articulations that change the length of a note.
    c                2    t        |   di | d| _        y Nlastr   r   r   r   r   s     r   r   zLengthArticulation.__init__       $8$r   r'   r8   r9   r:   r   r?   r@   s   @r   rB   rB      s       r   rB   c                      e Zd ZdZy)DynamicArticulationzM
    Superclass for all articulations that change the dynamic of a note.
    Nr'   r8   r9   r:   r   r   r   rJ   rJ          r   rJ   c                      e Zd ZdZy)PitchArticulationzK
    Superclass for all articulations that change the pitch of a note.
    NrK   r   r   r   rN   rN      rL   r   rN   c                      e Zd ZdZy)TimbreArticulationzL
    Superclass for all articulations that change the timbre of a note.
    NrK   r   r   r   rP   rP      rL   r   rP   c                  "     e Zd ZdZ fdZ xZS )Accentz)

    >>> a = articulations.Accent()
    c                2    t        |   di | d| _        y )Ng?r   r   r   r   r   s     r   r   zAccent.__init__   s    $8$r   rH   r@   s   @r   rR   rR      s       r   rR   c                  "     e Zd ZdZ fdZ xZS )StrongAccentz
    Like an accent but even stronger.  Has an extra
    attribute of pointDirection

    >>> a = articulations.StrongAccent()
    >>> a.pointDirection
    'up'
    >>> a.pointDirection = 'down'
    >>> a.pointDirection
    'down'
    c                @    t        |   di | d| _        d| _        y )Ng333333?upr   )r   r   r   pointDirectionr   s     r   r   zStrongAccent.__init__   s#    $8$ "r   rH   r@   s   @r   rV   rV      s    
# #r   rV   c                  "     e Zd ZdZ fdZ xZS )Staccatoz+

    >>> a = articulations.Staccato()
    c                @    t        |   di | d| _        d| _        y )N皙?ffffff?r   r   r   r   r   r   s     r   r   zStaccato.__init__   #    $8$ r   rH   r@   s   @r   r[   r[      s     r   r[   c                  "     e Zd ZdZ fdZ xZS )Staccatissimoz
    A very short note (derived from staccato), usually
    represented as a wedge.

    >>> a = articulations.Staccatissimo()
    c                @    t        |   di | d| _        d| _        y )Nr]   g      ?r   r_   r   s     r   r   zStaccatissimo.__init__  r`   r   rH   r@   s   @r   rb   rb     s     r   rb   c                      e Zd ZdZd Zy)Spiccatoa$  
    A staccato note + accent in one

    >>> spiccato = articulations.Spiccato()
    >>> staccato = articulations.Staccato()
    >>> accent = articulations.Accent()
    >>> spiccato.lengthShift == staccato.lengthShift
    True
    >>> spiccato.volumeShift == accent.volumeShift
    True
    c                    t         j                  |        t        | d      5  t        j                  |        d d d        y # 1 sw Y   y xY w)Nr   )r[   r   r   rR   )r   r   s     r   r   zSpiccato.__init__  s2    $4/OOD! 0//s   AA
N)r'   r8   r9   r:   r   r   r   r   re   re     s    
"r   re   c                  "     e Zd ZdZ fdZ xZS )Tenutoz(
    >>> a = articulations.Tenuto()
    c                @    t        |   di | d| _        d| _        y )N皙皙?r   r_   r   s     r   r   zTenuto.__init__#  s#    $8$!r   rH   r@   s   @r   rh   rh     s     r   rh   c                  "     e Zd ZdZ fdZ xZS )DetachedLegatoz0
    >>> a = articulations.DetachedLegato()
    c                2    t        |   di | d| _        y )Ng?r   )r   r   r   r   s     r   r   zDetachedLegato.__init__,  s    $8$r   rH   r@   s   @r   rm   rm   (  s     r   rm   c                  (    e Zd ZdZej
                  Zy)IndeterminateSlidez
    Represents a whole class of slides that are
    of an indeterminate pitch amount (scoops, plops, etc.)

    All these have style information of .style.lineShape
    .style.lineType, .style.dashLength, and .style.spaceLength
    N)r'   r8   r9   r:   r   	LineStyler   r   r   r   rp   rp   2  s     //Kr   rp   c                      e Zd ZdZy)Scoopzk
    An indeterminateSlide coming before the main note and going up

    >>> a = articulations.Scoop()
    NrK   r   r   r   rs   rs   =      r   rs   c                      e Zd ZdZy)Plopzm
    An indeterminateSlide coming before the main note and going down.

    >>> a = articulations.Plop()
    NrK   r   r   r   rv   rv   E  rt   r   rv   c                  "     e Zd ZdZ fdZ xZS )Doitzj
    An indeterminateSlide coming after the main note and going up.

    >>> a = articulations.Doit()
    c                2    t        |   di | d| _        y rD   rF   r   s     r   r   zDoit.__init__R  rG   r   rH   r@   s   @r   rx   rx   L      
   r   rx   c                  "     e Zd ZdZ fdZ xZS )Falloffzo
    An indeterminateSlide coming after the main note and going down.

    >>> a = articulations.Falloff()
    c                2    t        |   di | d| _        y rD   rF   r   s     r   r   zFalloff.__init__\  rG   r   rH   r@   s   @r   r|   r|   V  rz   r   r|   c                  "     e Zd ZdZ fdZ xZS )
BreathMarkz{
    Can have as a symbol 'comma' or 'tick' or None

    >>> a = articulations.BreathMark()
    >>> a.symbol = 'comma'
    c                @    t        |   di | d| _        d | _        y )Nr^   r   )r   r   r   symbolr   s     r   r   zBreathMark.__init__j  s"    $8$r   rH   r@   s   @r   r   r   c  s     r   r   c                      e Zd ZdZy)Caesuraz)
    >>> a = articulations.Caesura()
    NrK   r   r   r   r   r   o  rL   r   r   c                  "     e Zd ZdZ fdZ xZS )Stresszt
    An articulation indicating stress.  Played a little longer and louder.

    >>> a = articulations.Stress()
    c                @    t        |   di | d| _        d| _        y )Nr]   rk   r   r_   r   s     r   r   zStress.__init__z  r`   r   rH   r@   s   @r   r   r   t  s    
 r   r   c                  "     e Zd ZdZ fdZ xZS )Unstresszt
    An articulation indicating lack of stress.  Played a little quieter.

    >>> a = articulations.Unstress()
    c                2    t        |   di | d| _        y )Nrj   r   rT   r   s     r   r   zUnstress.__init__      $8$!r   rH   r@   s   @r   r   r     s    
" "r   r   c                      e Zd ZdZy)TechnicalIndicationz
    TechnicalIndications (MusicXML: technical) give performance
    indications specific to different instrument types, such
    as harmonics or bowing.

    TechnicalIndications can include an optional content.
    NrK   r   r   r   r   r     s    r   r   c                      e Zd ZdZy)HarmoniczS
    A general harmonic indicator -- StringHarmonic is probably what you want.
    NrK   r   r   r   r   r     rL   r   r   c                      e Zd ZdZy)BowingzW
    Indication that bowing is being affected.

    >>> a = articulations.Bowing()
    NrK   r   r   r   r   r     rt   r   r   c                  *     e Zd ZdZd fd	Zd Z xZS )	Fingeringa  
    Fingering is a technical indication that covers the fingering of
    a note (in a guitar/fret context, this covers the fret finger,
    see FrettedPluck for that).

    Converts the MusicXML -- <fingering> object

    >>> f = articulations.Fingering(5)
    >>> f
    <music21.articulations.Fingering 5>
    >>> f.fingerNumber
    5

    `.substitution` indicates that this fingering indicates a substitute fingering:

    >>> f.substitution = True

    MusicXML distinguishes between a substitution and an alternate
    fingering:

    >>> f.alternate = True

    Fingerings are the only articulations that apply per note in a chord.
    Other articulations, e.g., accents, apply to the whole chord and will,
    therefore, only be associated with the first note of a chord when serializing.
    Since chords store all articulations in an ordered list, Fingerings
    are mapped implicitly to the notes of a chord in order. Superfluous
    Fingerings will be ignored and may be discarded when serializing.
    c                N    t        |   di | || _        d| _        d| _        y NFr   )r   r   fingerNumbersubstitution	alternate)r   r   r   r   s      r   r   zFingering.__init__  s*    $8$(!r   c                ,    t        | j                        S r,   )r7   r   r"   s    r   r#   zFingering._reprInternal  s    4$$%%r   r,   r'   r8   r9   r:   r   r#   r?   r@   s   @r   r   r     s    :&r   r   c                      e Zd ZdZy)UpBowz'
    >>> a = articulations.UpBow()
    NrK   r   r   r   r   r     rL   r   r   c                      e Zd ZdZy)DownBowz)
    >>> a = articulations.DownBow()
    NrK   r   r   r   r   r     rL   r   r   c                  "     e Zd ZdZ fdZ xZS )StringHarmonicae  
    Indicates that a note is a harmonic, and can also specify
    whether it is the base pitch, the sounding pitch, or the touching pitch.

    >>> h = articulations.StringHarmonic()
    >>> h.harmonicType
    'natural'
    >>> h.harmonicType = 'artificial'

    pitchType can be 'base', 'sounding', or 'touching' or None

    >>> h.pitchType = 'base'
    c                @    t        |   di | d| _        d | _        y )Nnaturalr   )r   r   harmonicType	pitchTyper   s     r   r   zStringHarmonic.__init__  s"    $8$%r   rH   r@   s   @r   r   r     s     r   r   c                      e Zd Zy)
OpenStringNr'   r8   r9   r   r   r   r   r         r   r   c                  *     e Zd ZdZd fd	Zd Z xZS )StringIndicationaA  
    StringIndication indicates which string a note is played on.

    A StringIndication can be constructed as

    >>> si = articulations.StringIndication(2)
    >>> si
    <music21.articulations.StringIndication 2>
    >>> si.number
    2

    If no argument to the constructor is specified, number defaults to 0.
    c                2    t        |   di | || _        y Nr   r   r   numberr   r   r   r   s      r   r   zStringIndication.__init__      $8$r   c                    | j                    S r,   r   r"   s    r   r#   zStringIndication._reprInternal      ++r   r   r   r@   s   @r   r   r          r   r   c                      e Zd ZdZy)StringThumbPositionz$
    MusicXML -- thumb-position
    NrK   r   r   r   r   r          	r   r   c                      e Zd ZdZy)StringFingeringzO
    Indicates a fingering on a specific string.  Nothing special for now.
    NrK   r   r   r   r   r     r   r   r   c                      e Zd ZdZy)	Pizzicatoz
    in MusicXML, Pizzicato is an element of every note.
    Here we represent pizzicatos along with all bowing marks.

    For pluck, see FrettedPluck.
    NrK   r   r   r   r   r     s     	r   r   c                      e Zd Zy)SnapPizzicatoNr   r   r   r   r   r     r   r   r   c                      e Zd ZdZy)NailPizzicatoz$
    Does not exist in MusicXML
    NrK   r   r   r   r   r     r   r   r   c                  *     e Zd ZdZd fd	Zd Z xZS )FretIndicationaC  
    FretIndication indicates which fret of a string a note is played on.

    A FretIndication can be constructed as

    >>> fi = articulations.FretIndication(3)
    >>> fi
    <music21.articulations.FretIndication 3>
    >>> fi.number
    3

    If no argument to the constructor is specified, number defaults to 0.
    c                2    t        |   di | || _        y r   r   r   s      r   r   zFretIndication.__init__+  r   r   c                    | j                    S r,   r   r"   s    r   r#   zFretIndication._reprInternal/  r   r   r   r   r@   s   @r   r   r     r   r   r   c                      e Zd ZdZy)FrettedPluckzU
    specifies plucking fingering for fretted instruments

    pluck in musicxml
    NrK   r   r   r   r   r   2  s    
 	r   r   c                      e Zd ZdZy)HammerOnzA
    A hammer-on represented as a spanner between two Notes.
    NrK   r   r   r   r   r   :  r   r   r   c                      e Zd ZdZy)PullOffz@
    A pull-off represented as a spanner between two Notes.
    NrK   r   r   r   r   r   @  r   r   r   c                  p     e Zd ZU dZded<   ded<   ded<   ded	<   	 dd
dd
d
d	 	 	 	 	 	 	 	 	 d fdZ xZS )FretBenda  
    Bend indication for fretted instruments

    Bend in musicxml

    `number` is an identifier for the articulation. Defaults to 0.

    `bendAlter` is the interval defined by the bend,
    bend-alter in musicxml. Defaults to `None`.

    `preBend` indicates if the string is bent before
    the onset of the note. Defaults to `False`.

    `release` is the quarterLength value from the start
    of the note for releasing the bend, if any. Defaults to `None`.

    `withBar` indicates what whammy bar movement is used, if any.
    MusicXML supports 'scoop' or 'dip'. Defaults to `None`.

    >>> fb = articulations.FretBend(1, bendAlter=interval.ChromaticInterval(-2),  release=0.5)
    >>> fb
    <music21.articulations.FretBend 1>
    >>> fb.preBend
    False
    >>> fb.withBar is None
    True
    >>> fb.bendAlter
    <music21.interval.ChromaticInterval -2>
    >>> fb.release
    0.5
    5interval.Interval | interval.ChromaticInterval | None	bendAlterboolpreBendOffsetQL | Nonerelease
str | NonewithBarNF)r   r   r   r   c               `    t        |   dd|i| || _        || _        || _        || _        y )Nr   r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   s          r   r   zFretBend.__init__k  s6     	33(3"r   r   )
r   intr   r   r   r   r   r   r   r   )r'   r8   r9   r:   r<   r   r?   r@   s   @r   r   r   F  sw    > EDM  LP#'" I	
  !  r   r   c                      e Zd Zy)FretTapNr   r   r   r   r   r   {  r   r   r   c                      e Zd Zy)WindIndicationNr   r   r   r   r   r   ~  r   r   r   c                      e Zd Zy)WoodwindIndicationNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)BrassIndicationNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)TonguingIndicationNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)DoubleTongueNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)TripleTongueNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)StoppedNr   r   r   r   r   r     r   r   r   c                  "     e Zd ZdZ fdZ xZS )OrganIndicationz
    Indicates whether a pitch should be played with heel or toe.

    Has one attribute, "substitution" default to False, which
    indicates whether the mark is a substitution mark
    c                2    t        |   di | d| _        y r   )r   r   r   r   s     r   r   zOrganIndication.__init__  r   r   rH   r@   s   @r   r   r     s    " "r   r   c                      e Zd Zy)	OrganHeelNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)OrganToeNr   r   r   r   r   r     r   r   r   c                      e Zd Zy)HarpIndicationNr   r   r   r   r   r     r   r   r   c                      e Zd ZdZy)HarpFingerNailsz!
    musicXML -- fingernails
    NrK   r   r   r   r   r     r   r   r   c                      e Zd ZdZy)HandbellIndicationz
    displayText is used to store any of the techniques in handbell music.

    Values are damp, echo, gyro, hand martellato, mallet lift,
    mallet table, martellato, martellato lift,
    muted martellato, pluck lift, and swing
    NrK   r   r   r   r   r     s     	r   r   c                      e Zd Zd Zd Zy)Testc                2    ddl m}  || t                      y )Nr   )testCopyAll)music21.test.commonTestr   globals)r   r   s     r   testCopyAndDeepcopyzTest.testCopyAndDeepcopy  s    7D')$r   c                P    t               }| j                  |j                  d        y r,   )r   assertEqualr   )r   as     r   	testBasiczTest.testBasic  s    Jd+r   N)r'   r8   r9   r   r   r   r   r   r   r     s    %
,r   r   __main__)Nr:   
__future__r   unittestmusic21r   r   music21.common.classToolsr   music21.common.typesr   r   r	   r
   r   EnvironmentenvironLocalMusic21Objectr   rB   rJ   rN   rP   rR   rV   r[   rb   re   rh   rm   rp   rs   rv   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Spannerr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   TestCaser   
_DOC_ORDERr'   mainTestr   r   r   <module>r     s?  @B #    3 )     '{&&7a4%% aH   , 
 
     #6 #"! 
H 
"x "$ ' "* "         
# 
l 
	 "4 	"" ", " 
  %&# %&RF 
f 
VX &	 	 v  ,	& 		&	 		 		I 		I 	 (  *	>9 		w 3 		goo2 	3~ 3j	n 		( 		 		n 		 		% 		% 		n 		") 	"	 		 		( 		n 		, 	,8 ,@ ^
zGT r   