§
    ƒØj» ã                  ó~  — U d Z ddlmZ ddl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 ddlmZ ddlmZ ej        rddlmZ ej        Zej        Zej        Z e
j        d¦  «        Zi Zded<   g d¢Zd„ ZdHd„Zd„ ZdId„Z dJd„Z!d„ Z"dKd„Z#d„ Z$d„ Z%dddœdLd!„Z&d"„ Z'dJdMd%„Z(dNd'„Z)d(„ Z*d)d*œdOd/„Z+dJd0„Z,d1„ Z-d2„ Z.	 	 	 	 	 dPd3„Z/dQd5„Z0dKd6„Z1d7„ Z2dRd9„Z3dSd<„Z4d=„ Z5dIdTd?„Z6dUdVdB„Z7 G dC„ dDej8        ¦  «        Z9 G dE„ dFej:        ¦  «        Z;e<dGk    rddlZ ej=        e;¦  «         dS dS )Wu\  
Basic tools for working with Braille in `music21`.  Most users will not need to
use these.  Simply call `.show('braille')` or `.show('braille.ascii')`

>>> soprano = corpus.parse('bwv66.6').parts[0]
>>> #_DOCS_SHOW soprano.show('braille.ascii')
>>> print(converter.toData(soprano, 'braille.ascii'))  # _DOCS_HIDE
                     %%%.C
    #J .DJ [W?<L$ ?W[<L? IJ\]<L[ WW]$ [W?<L?
      "[W?[ \]R<L Q]]@C ]G%F]<L<K

Normally this would open up in a new window.  But to store the data, use
`converter.toData(..., 'braille')`.  Here we show this in Unicode braille
(the default for format braille)

>>> data = converter.toData(soprano, 'braille')
>>> print(data)
    â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â ©â ©â ©â ¨â ‰â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €
    â ¼â šâ €â ¨â ™â šâ €â ªâ ºâ ¹â £â ‡â «â €â ¹â ºâ ªâ £â ‡â ¹â €â Šâ šâ ³â »â £â ‡â ªâ €â ºâ ºâ »â «â €â ªâ ºâ ¹â £â ‡â ¹
    â €â €â �â ªâ ºâ ¹â ªâ €â ³â »â —â £â ‡â €â Ÿâ »â »â ˆâ ‰â €â »â ›â ©â ‹â »â £â ‡â £â …

Any :class:`~music21.base.Music21Object` which cannot be transcribed in
:mod:`~music21.braille.basic` returns a braille literary question mark
and outputs a warning to the console, rather than raising an exception.
This is so that a transcription of a :class:`~music21.stream.Stream` in
:class:`~music21.braille.translate` is completed as thoroughly as possible.
é    )ÚannotationsN)Úarticulations)Úclef)Úduration)Úenvironment)Úexceptions21)Úexpressions)Úinterval)Únote)Úlookup)ÚstringTools)Útempozbasic.pyzdict[str, bool]Ú
beamStatus)ÚbeginLongBracketSlurÚendLongBracketSlurÚbeginLongDoubleSlurÚendLongDoubleSlurÚ	shortSlurÚ	beamStartÚbeamContinuec                ó  — 	 t           j        | j                 }d| j        › d|› �g| j        _        |S # t
          $ rD t                               d| › d�¦  «         d| j        › d�g| j        _        t          d         cY S w xY w)uk  
    Takes in a :class:`~music21.bar.Barline` and returns its representation
    as a braille string in UTF-8 unicode.

    .. note:: Only dashed, double barlines, and final barlines can be transcribed.

    >>> from music21.braille.basic import barlineToBraille
    >>> doubleBarline = bar.Barline('double')
    >>> print(barlineToBraille(doubleBarline))
    â £â …â „
    >>> finalBarline = bar.Barline('final')
    >>> print(barlineToBraille(finalBarline))
    â £â …

    Heavy gives an "unusual barline" symbol

    >>> heavyBarline = bar.Barline('heavy')
    >>> print(barlineToBraille(heavyBarline))
    â ‡
    zBarline ú ú" cannot be transcribed to braille.ú NoneÚbasic_exception)	r   ÚbarlinesÚtypeÚ	editorialÚbrailleEnglishÚKeyErrorÚenvironRulesÚwarnÚsymbols)Úmusic21BarlineÚbrailleBarlines     úŠ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/braille/basic.pyÚbarlineToBrailler'   S   s¨   € ð**Ýœ¨Ô)<Ô=ˆà=�~Ô*Ð=Ð=¨^Ð=Ð=ð3?ˆÔ Ô/àÐøÝð *ð *ð *Ý×ÒÐW ^ÐWÐWÐWÑXÔXÐXØ3X¸nÔ>QÐ3XÐ3XÐ3XÐ2YˆÔ Ô/ÝÐ(Ô)Ð)Ð)Ð)ð*øøøs   ‚03 ³ABÂ BTc           	     óò  — g | j         _        t          | j        ¦  «        }d}|r|                     ¦   «          nd}g }|d         }t          j        || j        ¬¦  «        }t          ||¬¦  «        }|t          d         k    rMt                               d| › d�¦  «         | j         j                             | › d	�¦  «         t          d         S |                     |¦  «         d
                     |j                              dg ¦  «        ¦  «        }	| j         j                             |› d|	› �¦  «         t          dt!          |¦  «        ¦  «        D �]}
||
         }	 t#          ||| j         j        ¦  «         n6# t$          $ r) t                               d|j        › d| › d�¦  «         Y nw xY wt)          j        ||¦  «        j        }|dk    rÚ|dz
  dz  dz   }|
dk    rOt/          |¦  «        }|                     |¦  «         | j         j                             d|j        › d|› �¦  «         nÎ||
dz
           }t)          j        ||¦  «        j        }|dk    rNt/          |¦  «        }|                     |¦  «         | j         j                             d|j        › d|› �¦  «         nT|dk    rNt/          |¦  «        }|                     |¦  «         | j         j                             d|j        › d|› �¦  «         |dk    rd}|                     t2          j        |         ¦  «         | j         j                             d|› dt2          j        |         › �¦  «         �Œd                     |¦  «        S )u
  
    Takes in a :class:`~music21.chord.Chord` and returns its representation
    as a braille string in UTF-8 unicode.

    In braille, only one pitch of a chord is brailled, with the rest represented
    as numeric intervals from that one pitch. If descending is True, the highest
    (sounding) pitch is brailled, and intervals are labeled in descending order;
    if descending is False, the lowest (sounding) pitch is brailled, and the
    intervals are labeled in ascending order. Convention dictates that chords
    found in the treble clef are brailled descending, and those found in the bass
    clef are brailled ascending.

    If showOctave is True, the octave of the brailled pitch is shown. Other
    octave marks are shown in context relative to the brailled pitch.

    >>> from music21.braille.basic import chordToBraille
    >>> gMajorTriadA = chord.Chord(['G4', 'B4', 'D5', 'G5'], quarterLength=4.0)
    >>> print(chordToBraille(gMajorTriadA, descending=True))
    â ¨â ·â ¼â ´â ¤
    >>> gMajorTriadB = chord.Chord(['G2', 'B2', 'D3', 'G3'], quarterLength=4.0)
    >>> print(chordToBraille(gMajorTriadB, descending=False))
    â ˜â ·â ¬â ”â ¤
    >>> gMajorTriadRightHand = chord.Chord(['D4', 'B4', 'G5'], quarterLength=4.0)
    >>> print(chordToBraille(gMajorTriadRightHand, descending=True))
    â ¨â ·â ´â ¼
    >>> gMajorTriadLeftHand = chord.Chord(['G2', 'D3', 'B3'], quarterLength=4.0)
    >>> print(chordToBraille(gMajorTriadLeftHand, descending=False))
    â ˜â ·â ”â ¬
    >>> cMajorTriadRightHand = chord.Chord(['C4', 'E5'], quarterLength=4.0)
    >>> print(chordToBraille(cMajorTriadRightHand, descending=True))
    â ¨â ¯â �â ¬
    >>> cMajorTriadLeftHand = chord.Chord(['C2', 'E3'], quarterLength=4.0)
    >>> print(chordToBraille(cMajorTriadLeftHand, descending=False))
    â ˜â ½â ¸â ¬
    >>> cMajorSeventhRightHand = chord.Chord(['C6', 'E5', 'B4'], quarterLength=4.0)
    >>> print(chordToBraille(cMajorSeventhRightHand, descending=True))
    â °â ½â ´â Œ
    >>> cMajorSeventhLeftHand = chord.Chord(['G2', 'E3', 'E4'], quarterLength=4.0)
    >>> print(chordToBraille(cMajorSeventhLeftHand, descending=False))
    â ˜â ·â ´â �â ´

    >>> chordWithoutAccidentals = chord.Chord(['C4', 'E4', 'F4'], quarterLength=4.0)
    >>> print(chordToBraille(chordWithoutAccidentals, descending=True))
    â �â ¿â Œâ ¼

    >>> chordWithAccidentals = chord.Chord(['C4', 'E-4', 'F#4'], quarterLength=4.0)
    >>> chordWithAccidentals.pitches[0].accidental = 'natural'
    >>> print(chordToBraille(chordWithAccidentals, descending=True))
    â ©â �â ¿â £â Œâ ¡â ¼
    Ú
DescendingÚ	Ascendingr   ©ÚquarterLength)Úmusic21NoteÚ
showOctaver   zChord r   r   ú
r   z Chord:
é   úAccidental z
 of chord é   é   úOctave r   z	Interval Ú )r   r   ÚsortedÚpitchesÚreverser   ÚNoter,   ÚnoteToBrailler#   r!   r"   ÚappendÚjoinÚgetÚrangeÚlenÚhandlePitchWithAccidentalr    Ú
accidentalr
   ÚnotesToGenericÚ
undirectedÚpitchToOctaveÚoctaver   Ú	intervals)Úmusic21ChordÚ
descendingr.   Ú
allPitchesÚ	directionÚ
chordTransÚ	basePitchÚinitNoteÚbrailleNoteÚenglishJoinedÚcurrentPitchIndexÚcurrentPitchÚintervalDistanceÚbrailleOctaveÚpreviousPitchÚrelativeIntervalDists                   r&   ÚchordToBraillerV   s   s7  € ðf -/€LÔÔ)Ý˜Ô,Ñ-Ô-€JØ€IØð  Ø×ÒÑÔÐÐàˆ	à€JØ˜1”€IÝŒyØØ"Ô0ðñ ô €Hõ  ØØðñ ô €Kð •gÐ/Ô0Ò0Ð0Ý×ÒÐS <ÐSÐSÐSÑTÔTÐTØÔÔ-×4Ò4¸Ð5KÐ5KÐ5KÑLÔLÐLÝÐ(Ô)Ð)Ø×Ò�kÑ"Ô"Ð"Ø—I’I˜hÔ0×4Ò4Ð5EÀrÑJÔJÑKÔK€MØÔÔ)×0Ò0ØÐ.Ð.˜}Ð.Ð.ñô ð õ # 1¥c¨*¡o¤oÑ6Ô6ð )
ñ )
ÐØ!Ð"3Ô4ˆð
	Ý%ØØØÔ&Ô5ñô ð ð øõ
 ð 	ð 	ð 	Ý×ÒðJ˜lÔ5ð Jð JØ%ðJð Jð Jñô ð ð ð ð	øøøõ
 $Ô2°9¸lÑKÔKÔVÐØ˜aÒÐØ 0°1Ñ 4¸Ñ9¸AÑ=ÐØ  AÒ%Ð%Ý -¨lÑ ;Ô ;�Ø×!Ò! -Ñ0Ô0Ð0ØÔ&Ô5×<Ò<ØC˜lÔ1ÐCÐC°MÐCÐCñEô Eð Eð Eð !+Ð+<¸qÑ+@Ô A�Ý'/Ô'>¸}Ø?Kñ(Mô (MÜMWð %à'¨1Ò,Ð,Ý$1°,Ñ$?Ô$?�MØ×%Ò% mÑ4Ô4Ð4Ø Ô*Ô9×@Ò@ØG ,Ô"5ÐGÐG¸ÐGÐGñô ð øð  Ò"Ð"Ý)¨,Ñ7Ô7ˆMØ×Ò˜mÑ,Ô,Ð,ØÔ"Ô1×8Ò8Ø?˜,Ô-Ð?Ð?°Ð?Ð?ñAô Að Aà˜qÒ Ð Ø ÐØ×Ò�&Ô*Ð+;Ô<Ñ=Ô=Ð=ØÔÔ-×4Ò4ØOÐ(ÐOÐO­6Ô+;Ð<LÔ+MÐOÐOñ	
ô 	
ð 	
ñ 	
ð �7Š7�:ÑÔÐs   Å E<Å<0F/Æ.F/c                óò   — t          | d¦  «        r| j        }n| }|t          j        v rt          j        |         S |dk     rt          j        d         d|z
  z  S |dk    rt          j        d         |dz
  z  S dS )u�  
    takes a pitch object and returns the brailling for the octave.

    Can also be given an int specifying the octave.

    Expands the definition given in Degarmo Ch 7 to allow even less commonly used octaves such
    as -1, and > 8 by tripling, etc. the number of octave marks.

    >>> pitchToOctave = braille.basic.pitchToOctave
    >>> print(pitchToOctave(pitch.Pitch('C4')))
    â �
    >>> print(pitchToOctave(pitch.Pitch('B-4')))
    â �
    >>> print(pitchToOctave(4))
    â �
    >>> print(pitchToOctave(3))
    â ¸
    >>> print(pitchToOctave(2))
    â ˜
    >>> print(pitchToOctave(1))
    â ˆ
    >>> print(pitchToOctave(0))
    â ˆâ ˆ
    >>> print(pitchToOctave(-1))
    â ˆâ ˆâ ˆ
    >>> print(pitchToOctave(5))
    â ¨
    >>> print(pitchToOctave(6))
    â °
    >>> print(pitchToOctave(7))
    â  
    >>> print(pitchToOctave(8))
    â  â  
    >>> print(pitchToOctave(9))
    â  â  â  
    rE   r0   é   r3   é   N)ÚhasattrrE   r   Úoctaves)Úmusic21PitchOrIntrE   s     r&   rD   rD   ï   s†   € õL Ð  (Ñ+Ô+ð #Ø"Ô)ˆˆà"ˆà•”ÐÐÝŒ~˜fÔ%Ð%Ø	�!ŠˆÝŒ~˜aÔ  A¨¡JÑ/Ð/Ø	�!ŠˆÝŒ~˜aÔ  F¨Q¡JÑ/Ð/ð 
ˆó    Fc                óÎ  — ddddddddd	d
ddœ}t          | t          j        ¦  «        rd| › �g| j        _        dS t
          j        }|d         }	 ||| j                 | j                 z  }	 || j	        j
                 d|› �z   g| j        _        n # t          $ r d| › �g| j        _        Y nw xY wt          | t          j        t          j        f¦  «        r3||d         |         z  }|r| j        j                             d¦  «         n||d         d         z  }|S # t          $ r> t                               d| › d�¦  «         | › d�g| j        _        t"          d         cY S w xY w)u"  
    Takes in a :class:`~music21.clef.Clef` and returns its representation
    as a braille string in UTF-8 unicode.

    Only :class:`~music21.clef.GClef`, :class:`~music21.clef.CClef`,
    :class:`~music21.clef.FClef`, :class:`~music21.clef.NoClef` and
    their subclasses (such as :class:`~music21.clef.TrebleClef`,
    :class:`~music21.clef.BassClef`) can be transcribed.

    If keyboardHandSwitched is True, the suffix of the brailled clef changes from dots
    1-2-3 to dots 1-3. In scores of keyboard instruments, this change indicates
    that the playing hand differs from which implied by the clef. (E.g. A G clef
    in the left-hand part of a piano score needs the change of suffix.) Note
    that changeSuffix works only for G and F clefs.

    >>> from music21.braille.basic import clefToBraille
    >>> trebleClef = clef.TrebleClef()
    >>> print(clefToBraille(trebleClef))
    â œâ Œâ ‡
    >>> print(clefToBraille(trebleClef, keyboardHandSwitched=True))
    â œâ Œâ …
    >>> bassClef = clef.BassClef()
    >>> print(clefToBraille(bassClef))
    â œâ ¼â ‡
    >>> print(clefToBraille(bassClef, keyboardHandSwitched=True))
    â œâ ¼â …

    >>> altoClef = clef.AltoClef()
    >>> print(clefToBraille(altoClef))
    â œâ ¬â ‡
    >>> tenorClef = clef.TenorClef()
    >>> print(clefToBraille(tenorClef))
    â œâ ¬â �â ‡
    >>> noClef = clef.NoClef()
    >>> clefToBraille(noClef) == ''
    True
    >>> sopranoClef = clef.SopranoClef()
    >>> print(f'{sopranoClef.sign}, {sopranoClef.line}, {clefToBraille(sopranoClef)}')
    C, 1, â œâ ¬â ˆâ ‡
    zFrench ViolinÚTreblez	G-sopranoÚSopranozMezzo-sopranoÚAltoÚTenorz
C-baritonez
F-baritoneÚBasszSub-bass)ÚFrenchViolinClefÚ
TrebleClefÚGSopranoClefÚSopranoClefÚMezzoSopranoClefÚAltoClefÚ	TenorClefÚCBaritoneClefÚFBaritoneClefÚBassClefÚSubBassClefzNo Clef r5   Úprefixz Clef zUnnamed Clef Úsuffixz Keyboard hand switchedFzClef r   r   r   )Ú
isinstancer   ÚNoClefr   r   r   ÚclefsÚsignÚlineÚ	__class__Ú__name__r    re   rm   r;   r!   r"   r#   )Úmusic21ClefÚkeyboardHandSwitchedÚ	clefNamesrs   ÚbrailleClefs        r&   ÚclefToBrailler|   "  sÓ  € ðT ,ØØ#Ø Ø+ØØØ%Ø%ØØ!ðð €Iõ �+�tœ{Ñ+Ô+ð Ø0H¸;Ð0HÐ0HÐ/IˆÔÔ,ØˆrÝŒL€EØ˜”/€Kð*Ø�u˜[Ô-Ô.¨{Ô/?Ô@Ñ@ˆð	Sà˜;Ô0Ô9Ô:Ð=SÀkÐ=SÐ=SÑSÐTð Ô!Ô0Ð0øõ ð 	Sð 	Sð 	SØ4QÀKÐ4QÐ4QÐ3RˆKÔ!Ô0Ð0Ð0ð	Søøøå�k¥D¤OµT´]Ð#CÑDÔDð 	2Ø˜5 œ?Ð+?Ô@Ñ@ˆKØ#ð WØÔ%Ô4×;Ò;Ð<UÑVÔVÐVøà˜5 œ?¨5Ô1Ñ1ˆKØÐøÝð *ð *ð *Ý×ÒÐQ +ÐQÐQÐQÑRÔRÐRØ3>Ð0EÐ0EÐ0EÐ/FˆÔÔ,ÝÐ(Ô)Ð)Ð)Ð)ð*øøøs8   ÁD Á,#B ÂD ÂB-Â*D Â,B-Â-A.D ÄAE$Å#E$c                ól  — g }g | j         _        |rM|                     t          d         ¦  «         | j         j                             dt          d         › �¦  «         	 t	          | j        d¬¦  «        }nl# t          $ r_}t                               d| › d|› �¦  «         | j         j                             d| j        › d�¦  «         t          d         cY d	}~S d	}~ww xY w| j         j                             d| j        › d
|› �¦  «         |                     |¦  «         d 	                    |¦  «        S )u´  
    Takes in a :class:`~music21.dynamics.Dynamic` and returns its
    :attr:`~music21.dynamics.Dynamic.value` as a braille string in
    UTF-8 unicode.

    If precedeByWordSign is True, the value is preceded by a word
    sign (â œ).

    >>> from music21.braille.basic import dynamicToBraille
    >>> print(dynamicToBraille(dynamics.Dynamic('f')))
    â œâ ‹
    >>> print(dynamicToBraille(dynamics.Dynamic('pp')))
    â œâ �â �
    ÚwordzWord: T©ÚisTextExpressionzDynamic ú: r   r   Nr   r5   )
r   r   r;   r#   ÚwordToBrailleÚvalueÚBrailleBasicExceptionr!   r"   r<   )Úmusic21DynamicÚprecedeByWordSignÚdynamicTransÚbrailleDynamicÚwordExceptions        r&   ÚdynamicToBraillerŠ   r  s\  € ð €LØ.0€NÔÔ+Øð SØ×Ò�G FœOÑ,Ô,Ð,ØÔ Ô/×6Ò6Ð7QÅÈÄÐ7QÐ7QÑRÔRÐRð*Ý& ~Ô';ÈdÐSÑSÔSˆˆøÝ ð *ð *ð *Ý×ÒÐF ^ÐFÐF°}ÐFÐFÑGÔGÐGØÔ Ô/×6Ò6Ð7]À.ÔBVÐ7]Ð7]Ð7]Ñ^Ô^Ð^ÝÐ(Ô)Ð)Ð)Ð)Ð)Ð)Ð)øøøøð*øøøð
 ÔÔ+×2Ò2Ø:�>Ô'Ð:Ð:¨.Ð:Ð:ñ<ô <ð <à×Ò˜Ñ'Ô'Ð'Ø�7Š7�<Ñ Ô Ð s   ÁA6 Á6
CÂ ACÃCÃCc                ó&  — g | j         _        |                      ¦   «                              ¦   «         }	 d„ |D ¦   «         }ny# t          $ rl}t
                               d| › d|› �¦  «         | j         j                             d|                      ¦   «         › d�¦  «         t          d         cY d}~S d}~ww xY wt          d          	                    |¦  «        }| j         j                             d|                      ¦   «         › d|› �¦  «         |S )	u„  
    Takes in a :class:`~music21.instrument.Instrument` and returns its "best name"
    as a braille string in UTF-8 unicode.

    >>> from music21.braille.basic import instrumentToBraille
    >>> print(instrumentToBraille(instrument.Bassoon()))
    â  â ƒâ �â Žâ Žâ •â •â �
    >>> print(instrumentToBraille(instrument.BassClarinet()))
    â  â ƒâ �â Žâ Žâ €â ‰â ‡â �â —â Šâ �â ‘â ž
    c                ó,   — g | ]}t          |¦  «        ‘ŒS © )r‚   )Ú.0r~   s     r&   ú
<listcomp>z'instrumentToBraille.<locals>.<listcomp>¢  s    € Ð:Ð:Ð:¨•˜tÑ$Ô$Ð:Ð:Ð:r]   zInstrument r�   r   r   NÚspacer   )
r   r   ÚbestNameÚsplitr„   r!   r"   r;   r#   r<   )Úmusic21InstrumentÚallWordsÚtransr‰   ÚbrailleInsts        r&   ÚinstrumentToBrailler—   ”  sA  € ð 24ÐÔÔ.Ø ×)Ò)Ñ+Ô+×1Ò1Ñ3Ô3€Hð*Ø:Ð:°Ð:Ñ:Ô:ˆˆøÝ ð *ð *ð *Ý×ÒÐLÐ(9ÐLÐL¸]ÐLÐLÑMÔMÐMØÔ#Ô2×9Ò9Ø=Ð+×4Ò4Ñ6Ô6Ð=Ð=Ð=ñ	?ô 	?ð 	?åÐ(Ô)Ð)Ð)Ð)Ð)Ð)Ð)øøøøð	*øøøõ ˜'Ô"×'Ò'¨Ñ.Ô.€KØÔÔ.×5Ò5ØBÐ'×0Ò0Ñ2Ô2ÐBÐB°[ÐBÐBñDô Dð DàÐs   ´A Á
B7ÁA!B2Â,B7Â2B7c                óÎ  — t           j        }g | j        _        | j        }	 t           j        |         }n^# t          $ rQ t                               d| › d�¦  «         | j        j         	                    d| › d�¦  «         t          d         cY S w xY w|dk    r&| j        j         	                    d|› d|› �¦  «         n2| j        j         	                    dt          |¦  «        › d|› �¦  «         |€|S |j        }t          |¦  «        }t          |¦  «        }g }	 |dk    s|dk    s||z  ||z  k    rH| 	                    ||         ¦  «         | j        j                             dd|› d
||         › �¦  «         no||k    ri| 	                    |t          ||z
  ¦  «                 ¦  «         |t          ||z
  ¦  «                 }	| j        j                             dd|› d
|	› �¦  «         | 	                    |¦  «         d                     |¦  «        S # t          $ rE t                               d|› d�¦  «         | j        j         	                    |› d�¦  «         |cY S w xY w)ué  
    Takes in a :class:`~music21.key.KeySignature` and returns its representation
    in braille as a string in UTF-8 unicode.

    >>> from music21.braille.basic import keySigToBraille
    >>> print(keySigToBraille(key.KeySignature(4)))
    â ¼â ™â ©

    If given an old key signature, then its cancellation will be applied before
    and in relation to the new key signature.

    >>> print(keySigToBraille(key.KeySignature(0), outgoingKeySig = key.KeySignature(-3)))
    â ¡â ¡â ¡
    zIncoming Key Signature r   zKey Signature z sharps Noner   r   z
 sharp(s) z	 flat(s) Nz
 naturals r5   zOutgoing Key Signature z naturals=None)r   Únaturalsr   r   ÚsharpsÚkeySignaturesr    r!   r"   r;   r#   ÚabsÚinsertr<   )
Úmusic21KeySignatureÚoutgoingKeySigr™   ÚincomingSharpsÚ
ks_brailleÚoutgoingSharpsÚabsOutgoingÚabsIncomingr•   ÚnaturalsPrints
             r&   ÚkeySigToBrailler¦   ¯  s  € õ Œ€HØ35ÐÔ!Ô0Ø(Ô/€Nð	*ÝÔ)¨.Ô9ˆ
ˆ
øÝð *ð *ð *Ý×ÒØ]Ð&9Ð]Ð]Ð]ñ	
ô 	
ð 	
ð 	Ô%Ô4×;Ò;Ø>Ð0Ð>Ð>Ð>ñ	
ô 	
ð 	
õ Ð(Ô)Ð)Ð)Ð)ð*øøøð ˜ÒÐØÔ%Ô4×;Ò;ØC˜^ÐCÐC°zÐCÐCñ	
ô 	
ð 	
ð 	
ð 	Ô%Ô4×;Ò;ØG�S Ñ0Ô0ÐGÐG¸:ÐGÐGñ	
ô 	
ð 	
ð ÐØÐà#Ô*€NÝ�nÑ%Ô%€KÝ�nÑ%Ô%€Kà€EðØ˜aÒÐØ! QÒ&Ð&Ø" [Ñ0°nÀ{Ñ6RÒSÐSØ�LŠL˜ +Ô.Ñ/Ô/Ð/ØÔ)Ô8×?Ò?ØØR ÐRÐR¸8ÀKÔ;PÐRÐRñTô Tð Tð Tð ˜KÒ'Ð'Ø�LŠL˜¥# n°~Ñ&EÑ"FÔ"FÔGÑHÔHÐHØ$¥S¨¸.Ñ)HÑ%IÔ%IÔJˆMØÔ)Ô8×?Ò?ØØJ ÐJÐJ¸=ÐJÐJñô ð ð 	�Š�ZÑ Ô Ð Ø�wŠw�u‰~Œ~Ðøåð ð ð Ý×ÒØX nÐXÐXÐXñ	Zô 	Zð 	ZàÔ%Ô4×;Ò;¸~Ð<]Ð<]Ð<]Ñ^Ô^Ð^ØÐÐÐð	øøøs$   ¡4 ´ABÂBÄC8H ÈAI$É#I$c                ó”  — | j         €dS g | j        _        	 g }t          j        d| j        j        ¬¦  «        }t          |d¬¦  «        }|                     |¦  «         d 	                    |j         
                    dg ¦  «        ¦  «        }| j        j                             d	|› �¦  «         |                     t          d
         ¦  «         | j        j                             dt          d
         › �¦  «         t          | j         ¦  «        }|                     |¦  «         | j        j                             d| j         › d|› �¦  «         d 	                    |¦  «        S # t          $ rY}t                               d| › d|› �¦  «         | j        j                             | › d�¦  «         t          d         cY d}~S d}~ww xY w)uš  
    Takes in a :class:`~music21.tempo.MetronomeMark` and returns it as a
    braille string in UTF-8 unicode.
    The format is (note C with duration of metronome's referent)(metronome symbol)(number/bpm).

    >>> from music21.braille.basic import metronomeMarkToBraille
    >>> mm1 = tempo.MetronomeMark(number=80, referent=note.Note(type='half'))
    >>> print(metronomeMarkToBraille(mm1))
    â �â ¶â ¼â “â š
    >>> mm2 = tempo.MetronomeMark(number=135, referent=note.Note(quarterLength=0.5))
    >>> print(metronomeMarkToBraille(mm2))
    â ™â ¶â ¼â �â ‰â ‘

    >>> mm3 = tempo.MetronomeMark(numberSounding=80)
    >>> metronomeMarkToBraille(mm3)
    ''
    Nr5   ÚC4r+   F)r.   r   r   zMetronome Note Ú	metronomezMetronome symbol zMetronome number zMetronome Mark r�   r   r   )Únumberr   r   r   r9   Úreferentr,   r:   r;   r<   r=   r#   ÚnumberToBrailler„   r!   r"   )Úmusic21MetronomeMarkÚ
metroTransÚ	metroNoterN   rO   ÚbrailleNumberÚnumberExceptions          r&   ÚmetronomeMarkToBrailler²   ö  sô  € ð$ Ô"Ð*Øˆrà46ÐÔ"Ô1ð*Øˆ
Ý”I˜dÐ2FÔ2OÔ2]Ð^Ñ^Ô^ˆ	Ý# I¸%Ð@Ñ@Ô@ˆØ×Ò˜+Ñ&Ô&Ð&ØŸš Ô!4×!8Ò!8Ð9IÈ2Ñ!NÔ!NÑOÔOˆØÔ&Ô5×<Ò<Ø-˜mÐ-Ð-ñ	
ô 	
ð 	
ð 	×Ò�' +Ô.Ñ/Ô/Ð/ØÔ&Ô5×<Ò<Ø6¥¨Ô 4Ð6Ð6ñ	
ô 	
ð 	
õ (Ð(<Ô(CÑDÔDˆØ×Ò˜-Ñ(Ô(Ð(ØÔ&Ô5×<Ò<ØMÐ 4Ô ;ÐMÐM¸mÐMÐMñ	
ô 	
ð 	
ð �wŠw�zÑ"Ô"Ð"øÝ ð *ð *ð *Ý×ÒÐUÐ,@ÐUÐUÀOÐUÐUÑVÔVÐVØÔ&Ô5×<Ò<Ð@TÐ=[Ð=[Ð=[Ñ\Ô\Ð\ÝÐ(Ô)Ð)Ð)Ð)Ð)Ð)Ð)øøøøð*øøøs   —EE$ Å$
GÅ.AGÆ<GÇGc              #  ó‚  K  — d„ }t          | d¦  «        r§t          | j        |¬¦  «        D ]’}|j        t          j        v rt          j        |j                 }n,|j        t          j        v rt          j        |j                 }nŒYd| j        v r*| j        j         	                    d|j        › d|› �¦  «         |V — Œ‘dS dS )uÃ  
    Generator that yields braille before note articulations from a given note.
    Might yield nothing.

    "When a staccato or staccatissimo is shown with any of the other
    [before note expressions], it is brailled first."

    "The up-bow and down-bow marks for bowed string instruments are brailled before any other
    signs from Column A and before an ornament." (BMTM, 114)

    Beyond that, we yield in alphabetical order, which happens to satisfy this:
    "When an accent is shown with a tenuto, the accent is brailled first." (BMTM, 113)

    For reference:

    >>> brailleArt = braille.lookup.beforeNoteExpr
    >>> print(brailleArt['tenuto'])
    â ¸â ¦
    >>> print(brailleArt['staccato'])
    â ¦
    >>> print(brailleArt['accent'])
    â ¨â ¦

    >>> brailleBowings = braille.lookup.bowingSymbols
    >>> print(brailleBowings['down bow'])
    â £â ƒ
    >>> print(brailleBowings['up bow'])
    â £â „

    >>> n = note.Note()
    >>> n.articulations.append(articulations.DownBow())
    >>> n.articulations.append(articulations.Tenuto())
    >>> n.articulations.append(articulations.Staccato())
    >>> n.articulations.append(articulations.Accent())
    >>> n.articulations.append(articulations.Scoop())  # example unsupported articulation

    This will yield in order: DownBow, Staccato, Accent, Tenuto.

    >>> for brailleArt in braille.basic.yieldBrailleArticulations(n):
    ...     print(brailleArt)
    â £â ƒ
    â ¦
    â ¨â ¦
    â ¸â ¦

    c                ó‚   — t          | t          j        ¦  «        }t          | t          j        ¦  «        }| | | j        fS ©N)rq   r   ÚBowingÚStaccatoÚname)Úinner_articulationÚisBowingÚ
isStaccatos      r&   Ú_brailleArticulationsSortKeyz?yieldBrailleArticulations.<locals>._brailleArticulationsSortKeyU  s=   € ÝÐ0µ-Ô2FÑGÔGˆÝÐ 2µMÔ4JÑKÔKˆ
à� *˜nÐ.@Ô.EÐFÐFr]   r   )Úkeyr   zArticulation r   N)
rZ   r6   r   r¸   r   ÚbowingSymbolsÚbeforeNoteExprr   r   r;   )ÚnoteElr¼   ÚartÚ
brailleArts       r&   ÚyieldBrailleArticulationsrÃ   %  sñ   è è € ð`Gð Gð Gõ ˆv�Ñ'Ô'ð 
Ý˜&Ô.Ð4PÐQÑQÔQð 		ð 		ˆCØŒx�6Ô/Ð/Ð/Ý#Ô1°#´(Ô;�
�
Ø”�VÔ2Ð2Ð2Ý#Ô2°3´8Ô<�
�
àØ 6Ô#3Ð3Ð3ØÔ Ô/×6Ò6Ð7^ÀsÄxÐ7^Ð7^ÐR\Ð7^Ð7^Ñ_Ô_Ð_ØÐÐÐÐð
ð 
ð		ð 		r]   )r.   ÚupperFirstInFingeringr-   ú	note.Notec               ó²  — g | j         _        t          D ]5}	 t          | |¦  «        t          |<   Œ# t
          $ r dt          |<   Y Œ2w xY wg }t          d         rN|                     t          d         ¦  «         | j         j                             dt          d         › �¦  «         nZt          d         rM|                     t          d         ¦  «         | j         j                             dt          d         › �¦  «         t          d         rZt          d         rM|                     t          d	         ¦  «         | j         j                             d
t          d	         › �¦  «         | j        j	        }|�rNt          d         �r)|d         j
        dk    r2|d         j        dk    r!|                     t          d         ¦  «         n°|d         j        dk    rM|                     t          d         ¦  «         | j         j                             dt          d         › �¦  «         t          d         }|t          |d         j        dd¬¦  «        z  }|t          d         z  }|                     |¦  «         | j         j                             |d         j
        › d|d         › �¦  «         nt          d         r
dt          d<   t          | ¦  «        D ]}|                     |¦  «         Œ	 t          | j        || j         j        ¦  «         n># t"          $ r1 t$                               d| j        j        › d| › d�dz   ¦  «         Y nw xY w|rSt+          | j        ¦  «        }|                     |¦  «         | j         j                             d| j        › d|› �¦  «         	 t.          j        | j        j                 }	nx# t"          $ rk t$                               d| j        j        ›d| › d�dz   ¦  «         | j         j                             d| j        j        › d�¦  «         t          d         cY S w xY wt5          | j        t          j        ¦  «        rK|	d          }
|                     |
¦  «         | j         j                             | j        › dd › d!|
› �¦  «         �nu	 t          d         r2|	d          }
| j         j                             | j        › d"|
› �¦  «         nH|	| j        j                 }
| j         j                             | j        › d| j        j        › d|
› �¦  «         |                     |
¦  «         t;          | j        j        ¦  «        D ]O}|                     t          d         ¦  «         | j         j                             d#t          d         › �¦  «         ŒPnn# t"          $ ra t$                               d$| j        › d| › d�dz   ¦  «         | j         j                             d$| j        › d�¦  «         t          d         cY S w xY wt?          | ||¦  «         tA          | |¦  «         t          d%         rM|                     t          d&         ¦  «         | j         j                             d't          d&         › �¦  «         t          d         rt          d         sµt          d(         rN|                     t          d)         ¦  «         | j         j                             d
t          d)         › �¦  «         nZt          d         rM|                     t          d	         ¦  «         | j         j                             d
t          d	         › �¦  «         | j!        �]| j!        j        d+k    rM|                     t          d,         ¦  «         | j         j                             d-t          d,         › �¦  «         d. "                    |¦  «        S )/uÃ  
    Given a :class:`~music21.note.Note`, returns the appropriate braille
    characters as a string in UTF-8 unicode.

    The format for note display in braille is the accidental (if necessary)
    + octave (if necessary) + pitch name with length.

    If the note has an :class:`~music21.pitch.Accidental`, the accidental is always
    displayed unless its :attr:`~music21.pitch.Accidental.displayStatus` is set to
    False. The octave of the note is only displayed if showOctave is set to True.

    >>> from music21.braille.basic import noteToBraille
    >>> C4 = note.Note('C4')
    >>> print(noteToBraille(C4))
    â �â ¹
    >>> C4.quarterLength = 2.0
    >>> print(noteToBraille(C4))
    â �â �
    >>> Ds4 = note.Note('D#4')
    >>> print(noteToBraille(Ds4))
    â ©â �â ±
    >>> print(noteToBraille(Ds4, showOctave=False))
    â ©â ±
    >>> Ds4.pitch.accidental.displayStatus=False
    >>> print(noteToBraille(Ds4))
    â �â ±
    >>> A2 = note.Note('A2')
    >>> A2.quarterLength = 3.0
    >>> print(noteToBraille(A2))
    â ˜â Žâ „

    >>> B = note.Note('B4')
    >>> f = expressions.Fermata()
    >>> B.expressions.append(f)
    >>> print(noteToBraille(B))
    â �â ºâ £â ‡
    >>> for x in B.editorial.brailleEnglish:
    ...     print(x)
    Octave 4 â �
    B quarter â º
    Note-fermata: Shape normal: â £â ‡

    >>> f.shape = 'square'
    >>> print(noteToBraille(B))
    â �â ºâ °â £â ‡
    >>> for x in B.editorial.brailleEnglish:
    ...     print(x)
    Octave 4 â �
    B quarter â º
    Note-fermata: Shape square: â °â £â ‡

    >>> C4 = note.Note('C4')
    >>> print(noteToBraille(C4))
    â �â ¹
    >>> C4.duration.appendTuplet(duration.Tuplet(3, 2))  # triplet
    >>> print(noteToBraille(C4))
    â �â ¹
    >>> C4.beamStart = True
    >>> print(noteToBraille(C4))
    â †â �â ¹
    >>> for x in C4.editorial.brailleEnglish:
    ...     print(x)
    Triplet â †
    Octave 4 â �
    C quarter â ¹

    >>> C4 = note.Note('C4')
    >>> C4.duration.appendTuplet(duration.Tuplet(7, 4))  # septuplet
    >>> C4.beamStart = True
    >>> print(noteToBraille(C4))
    â ¸â ¶â „â �â ¹
    >>> for x in C4.editorial.brailleEnglish:
    ...     print(x)
    Septuplet â ¸â ¶â „
    Octave 4 â �
    C quarter â ¹
    Fr   Úopening_bracket_slurzOpening bracket slur r   Úopening_double_slurzOpening double slur r   Úclosing_bracket_slurzClosing bracket slur r   r   ÚTripletÚnoneÚtripletztranscriber-added_signztranscriber-added Útuplet_prefixT©ÚwithNumberSignÚlowerÚdotr   éÿÿÿÿr   r1   ú	 of note ú!cannot be transcribed to braille.r4   zName r   r   Úeighthz Gracenote--not supported z beam úDot z	Duration r   Úopening_single_slurzOpening single slur r   Úclosing_double_slurNÚstopÚtiezTie r5   )#r   r   ÚTEMPORARY_ATTRIBUTESÚgetattrr   ÚAttributeErrorr;   r#   r   ÚtupletsÚfullNameÚtupletActualShowr¬   ÚnumberNotesActualrÃ   r@   Úpitchr    r!   r"   rA   rD   rE   r   ÚpitchNameToNotesÚsteprq   ÚGraceDurationr   r>   ÚdotsÚhandleArticulationsÚhandleExpressionsrÚ   r<   )r-   r.   rÄ   ÚkeywordÚ	noteTransÚ
allTupletsÚtupletTransÚbrailleArticulationrS   ÚnotesInStepÚnameWithDurationÚunused_counter_dots               r&   r:   r:   h  sÓ  € ðn ,.€KÔÔ(å'ð (ð (ˆð	(Ý")¨+°wÑ"?Ô"?�J�wÑÐøÝð 	(ð 	(ð 	(Ø"'�J�wÑÐÐð	(øøøð €Iõ
 Ð(Ô)ð EØ×Ò�Ð!7Ô8Ñ9Ô9Ð9ØÔÔ,×3Ò3ØE¥GÐ,BÔ$CÐEÐEñ	Gô 	Gð 	Gð 	Gå	Ð)Ô	*ð EØ×Ò�Ð!6Ô7Ñ8Ô8Ð8ØÔÔ,×3Ò3ØC¥7Ð+@Ô#AÐCÐCñ	Eô 	Eð 	EåÐ&Ô'ð G­JÐ7MÔ,Nð GØ×Ò�Ð!7Ô8Ñ9Ô9Ð9ØÔÔ,×3Ò3ØE¥GÐ,BÔ$CÐEÐEñ	Gô 	Gð 	Gð
 Ô%Ô-€JØñ /Ý�kÔ"ñ 	/Ø˜!Œ}Ô%¨Ò2Ð2°zÀ!´}Ô7UÐY_Ò7_Ð7_Ø× Ò ¥¨Ô!3Ñ4Ô4Ð4Ð4à˜a”=Ô1°VÒ;Ð;Ø×$Ò$¥WÐ-EÔ%FÑGÔGÐGØÔ)Ô8×?Ò?ØP­WÐ5MÔ-NÐPÐPñRô Rð Rå% oÔ6�Ø�¨z¸!¬}Ô/NØ@EØ7;ð =ñ  =ô  =ñ =�ð �w uœ~Ñ-�Ø× Ò  Ñ-Ô-Ð-ØÔ!Ô0×7Ò7Ø˜a”=Ô)Ð;Ð;¨I°b¬MÐ;Ð;ñô ð ð õ ˜Ô'ð 	/Ø).�J�~Ñ&õ
  9¸ÑEÔEð .ð .ÐØ×ÒÐ,Ñ-Ô-Ð-Ð-ð

Ý!ØÔØØÔ!Ô0ñ	
ô 	
ð 	
ð 	
øõ
 ð 
ð 
ð 
Ý×ÒØO˜+Ô+Ô6ÐOÐOÀÐOÐOÐOØ1ñ2ñ	
ô 	
ð 	
ð 	
ð 	
ð
øøøð ð dÝ% kÔ&7Ñ8Ô8ˆØ×Ò˜Ñ'Ô'Ð'ØÔÔ,×3Ò3Ð4b¸kÔ>PÐ4bÐ4bÐS`Ð4bÐ4bÑcÔcÐcð*ÝÔ-¨kÔ.?Ô.DÔEˆˆøÝð *ð *ð *Ý×ÒØE�KÔ%Ô*ÐEÐE°{ÐEÐEÐEØ1ñ2ñ	3ô 	3ð 	3ð 	ÔÔ,×3Ò3Ð4Y¸KÔ<MÔ<RÐ4YÐ4YÐ4YÑZÔZÐZÝÐ(Ô)Ð)Ð)Ð)ð*øøøõ �+Ô&­Ô(>Ñ?Ô?ð .à& xÔ0ÐØ×ÒÐ)Ñ*Ô*Ð*ØÔÔ,×3Ò3ØÔÐXÐX (ÐXÐXÐFVÐXÐXñ	
ô 	
ð 	
ñ 	
ð	.Ý˜.Ô)ð Ø#.¨xÔ#8Ð ØÔ%Ô4×;Ò;Ø"Ô'ÐAÐAÐ/?ÐAÐAñCô Cð Cð Cð $/¨{Ô/CÔ/HÔ#IÐ ØÔ%Ô4×;Ò;Ø"Ô'ÐXÐX¨+Ô*>Ô*CÐXÐXÐFVÐXÐXñô ð ð ×ÒÐ-Ñ.Ô.Ð.Ý&+¨KÔ,@Ô,EÑ&FÔ&Fð Uð UÐ"Ø× Ò ¥¨¤Ñ0Ô0Ð0ØÔ%Ô4×;Ò;Ð<SÅ7È5Ä>Ð<SÐ<SÑTÔTÐTÐTðUøõ ð 	.ð 	.ð 	.Ý×ÒØI˜KÔ0ÐIÐI¸;ÐIÐIÐIØ5ñ6ñ7ô 7ð 7ð Ô!Ô0×7Ò7Ð8_ÀKÔDXÐ8_Ð8_Ð8_Ñ`Ô`Ð`ÝÐ,Ô-Ð-Ð-Ð-ð	.øøøõ ˜ YÐ0EÑFÔFÐFÝ�k 9Ñ-Ô-Ð-õ �+Ôð EØ×Ò�Ð!6Ô7Ñ8Ô8Ð8ØÔÔ,×3Ò3ØC¥7Ð+@Ô#AÐCÐCñ	Eô 	Eð 	EåÐ+Ô,ð KµÐ<RÔ1Sð KÝÐ)Ô*ð 	KØ×Ò�WÐ%:Ô;Ñ<Ô<Ð<ØÔ!Ô0×7Ò7ØH­Ð0EÔ(FÐHÐHñJô Jð Jð JåÐ,Ô-ð 	KØ×Ò�WÐ%;Ô<Ñ=Ô=Ð=ØÔ!Ô0×7Ò7ØI­Ð0FÔ(GÐIÐIñKô Kð Kð
 „Ð" {¤Ô';¸vÒ'EÐ'EØ×Ò� œÑ(Ô(Ð(ØÔÔ,×3Ò3Ð4K½7À5¼>Ð4KÐ4KÑLÔLÐLà�7Š7�9ÑÔÐsH   —0°AÁAË- L Ì8M	ÍM	Î"N? Î?A2P4Ð3P4Ò"DV( Ö(A(XØXc                ó  — | j         }|�ô|j        durí|j        dk    r:t          d         }|                     |¦  «         |                     d|› �¦  «         |                     t
          j        |j                 ¦  «         |                     d|j        › dt
          j        |j                 › �¦  «         |j        dk    r@t          d         }|                     |¦  «         |                     d|› �¦  «         d S d S d S d S )NFÚparentheseszbraille-music-parenthesiszParenthesis r1   r   )rA   ÚdisplayStatusÚdisplayStyler#   r;   r   Úaccidentalsr¸   )Úmusic21PitchÚ
pitchTransr   ÚaccÚpss        r&   r@   r@   U  s  € Ø
Ô
!€CØ
€˜3Ô,°EÐ9Ð9ØÔ˜}Ò,Ð,ÝÐ4Ô5ˆBØ×Ò˜bÑ!Ô!Ð!Ø×!Ò!Ð"5°Ð"5Ð"5Ñ6Ô6Ð6à×Ò�&Ô,¨S¬XÔ6Ñ7Ô7Ð7Ø×ÒÐU¨C¬HÐUÐUµvÔ7IÈ#Ì(Ô7SÐUÐUÑVÔVÐVØÔ˜}Ò,Ð,ÝÐ4Ô5ˆBØ×Ò˜bÑ!Ô!Ð!Ø×!Ò!Ð"5°Ð"5Ð"5Ñ6Ô6Ð6Ð6Ð6ð €Ð9Ð9ð -Ð,r]   rê   ú	list[str]c                ó  — 	 | j         D ]6}d|j        v r+t          |j        |¬¦  «        }|                     |¦  «         Œ7d S # t
          $ r2 t                               d| j        j	        › d| › d�dz   ¦  «         Y d S w xY w)NÚ	Fingering)rÄ   z
Fingering rÓ   r   rÔ   )
r   ÚclassesÚtranscribeNoteFingeringÚfingerNumberr;   r„   r!   r"   r   Ú	fingering)r-   rê   rÄ   rÁ   ÚtranscribedFingerings        r&   rç   rç   e  sÑ   € ð
3ØÔ,ð 	7ð 	7ˆCØ˜cœkÐ)Ð)Ý'>ØÔ$Ø*?ð(Añ (Aô (AÐ$ð × Ò Ð!5Ñ6Ô6Ð6øð	7ð 	7øõ !ð 3ð 3ð 3Ý×ÒØQ˜Ô.Ô8ÐQÐQÀ;ÐQÐQÐQØ1ñ2ñ	3ô 	3ð 	3ð 	3ð 	3ð 	3ð3øøøs   ‚>A Á8A>Á=A>únote.GeneralNotec           	     ól  — | j         D ]«}t          |t           j        ¦  «        r�	 t          j        d         |j                 }|                     |¦  «         | j        j                             d|j        › d|› �¦  «         Œz# t          $ r$ t                               d|› d| › d�¦  «         Y Œ§w xY wŒ¬dS )z<
    Transcribe the expressions for a note.GeneralNote.
    ÚshapezNote-fermata: Shape r�   zFermata rÓ   z cannot be transcribed.N)r	   rq   ÚFermatar   Úfermatasr  r;   r   r   r    r!   r"   )r-   rê   ÚexprÚfermataBrailles       r&   rè   rè   u  sö   € ð Ô'ð bð bˆÝ�d�KÔ/Ñ0Ô0ð 	bðbÝ!'¤°Ô!9¸$¼*Ô!E�Ø× Ò  Ñ0Ô0Ð0ØÔ%Ô4×;Ò;ØI¨4¬:ÐIÐI¸ÐIÐIñKô Kð Kð Køåð bð bð bÝ×!Ò!Ð"`¨TÐ"`Ð"`¸KÐ"`Ð"`Ð"`ÑaÔaÐaÐaÐaðbøøøð	bðbð bs   ¥ABÂ+B0Â/B0c                óæ  — g | j         _        g }| j        j        }| j        j        }| j        du rd}d}	 t          j        |         }nm# t          $ r` t           
                    d| j        › d�¦  «         | j         j                             d| j        j        › d�¦  «         t          d         cY S w xY w|                     |¦  «         | j         j                             d|› d	|› �¦  «         t          |¦  «        D ]O}|                     t          d
         ¦  «         | j         j                             dt          d
         › �¦  «         ŒPt          | |¦  «         d                     |¦  «        S )u˜  
    Given a :class:`~music21.note.Rest`, returns the appropriate braille
    characters as a string in UTF-8 unicode.

    Currently, only supports single rests with or without dots.
    Complex rests are not supported.

    >>> from music21.braille.basic import restToBraille
    >>> dottedQuarter = note.Rest(quarterLength=1.5)
    >>> print(restToBraille(dottedQuarter))
    â §â „
    >>> whole = note.Rest(quarterLength=4.0)
    >>> print(restToBraille(whole))
    â �

    This would give a warning and gives the basic_exception symbol:

    quarterPlusSixteenth = note.Rest(quarterLength=1.25)
    print(restToBraille(quarterPlusSixteenth))
    â œâ ¦
    TÚwholer   zRest of duration r   zRest r   r   r   rÑ   rÖ   r5   )r   r   r   r   ræ   ÚfullMeasurer   Úrestsr    r!   r"   r;   r#   r>   rè   r<   )Úmusic21RestÚ	restTransÚrestTypeÚrestDotsÚ
simpleRestrð   s         r&   ÚrestToBrailler  †  s—  € ð, ,.€KÔÔ(Ø€IØÔ#Ô(€HØÔ#Ô(€HØÔ $Ð&Ð&ØˆØˆð*Ý”\ (Ô+ˆ
ˆ
øÝð *ð *ð *Ý×ÒØX Ô 4ÐXÐXÐXñ	Zô 	Zð 	ZàÔÔ,×3Ò3Ð4\¸KÔ<PÔ<UÐ4\Ð4\Ð4\Ñ]Ô]Ð]ÝÐ(Ô)Ð)Ð)Ð)ð	*øøøð ×Ò�ZÑ Ô Ð ØÔÔ(×/Ò/Ð0O¸Ð0OÐ0OÀ:Ð0OÐ0OÑPÔPÐPÝ# H™oœoð Mð MÐØ×Ò� œÑ(Ô(Ð(ØÔÔ,×3Ò3Ð4K½7À5¼>Ð4KÐ4KÑLÔLÐLÐLå�k 9Ñ-Ô-Ð-à�7Š7�9ÑÔÐs   µA ÁA'B2Â1B2é(   ©ÚmaxLineLengthÚmusic21TempoTextútempo.TempoTextÚreturnÚstrc          	     óÎ  — g }|| j         _        | j                             d¦  «        }g }|D �]Y}|                     ¦   «         }g }|D �]}	 t	          |¦  «        }	np# t
          $ rc}
t                               d| › d|
› �¦  «         | j         j                             d| j        › d�¦  «         t          d         cY d}
~
c c S d}
~
ww xY wd}|D ]}|dk    rd}Œ|t          |¦  «        z  }Œ|t          |	¦  «        z   d	z   |d
z
  k    r|                     d¦  «         |                     |	¦  «         |                     t          d         ¦  «         �Œ|                     d                     |dd…         ¦  «        ¦  «         �Œ[t          d         dz   }|                     |¦  «        t          d         z   }| j         j                             d| j        › d|› �¦  «         |S )uå  
    Takes in a :class:`~music21.tempo.TempoText` and returns its representation in braille
    as a string in UTF-8 unicode. The tempo text is returned uncentered, and is split around
    the comma, each split returned on a separate line. The literary period required at the end
    of every tempo text expression in braille is also included.

    >>> from music21.braille.basic import tempoTextToBraille
    >>> print(tempoTextToBraille(tempo.TempoText('Lento assai, cantante e tranquillo')))
    â  â ‡â ‘â �â žâ •â €â �â Žâ Žâ �â Šâ ‚
    â ‰â �â �â žâ �â �â žâ ‘â €â ‘â €â žâ —â �â �â Ÿâ ¥â Šâ ‡â ‡â •â ²
    >>> print(tempoTextToBraille(tempo.TempoText('Andante molto grazioso')))
    â  â �â �â ™â �â �â žâ ‘â €â �â •â ‡â žâ •â €â ›â —â �â µâ Šâ •â Žâ •â ²

    >>> print(tempoTextToBraille(tempo.TempoText('Andante molto grazioso ma cantabile')))
    â  â �â �â ™â �â �â žâ ‘â €â �â •â ‡â žâ •â €â ›â —â �â µâ Šâ •â Žâ •â €â �â �â €
    â ‰â �â �â žâ �â ƒâ Šâ ‡â ‘â ²

    >>> print(tempoTextToBraille(tempo.TempoText('Andante molto grazioso ma cantabile'),
    ...                          maxLineLength=20))
    â  â �â �â ™â �â �â žâ ‘â €
    â �â •â ‡â žâ •â €
    â ›â —â �â µâ Šâ •â Žâ •â €â �â �â €
    â ‰â �â �â žâ �â ƒâ Šâ ‡â ‘â ²
    ú,zTempo Text r�   r   r   Nr   r/   r0   rY   r�   r5   rÒ   ú.r   )r   r   Útextr’   r‚   r„   r!   r"   r;   r#   r?   r<   Úalphabet)r  r  ÚnewBrailleEnglishÚ
allPhrasesÚbraillePhrasesÚsamplePhraser”   ÚphraseTransÚ
sampleWordÚbrailleWordr‰   Útotal_widthÚphraseÚjoinerÚbrailleUnicodeTexts                  r&   ÚtempoTextToBrailler*  ¶  sH  € ð< $&ÐØ0AÐÔÔ-Ø!Ô&×,Ò,¨SÑ1Ô1€JØ€NØ"ð :ñ :ˆØ×%Ò%Ñ'Ô'ˆØ!#ˆØ"ð 	1ñ 	1ˆJð2Ý+¨JÑ7Ô7��øÝ(ð 2ð 2ð 2Ý×!Ò!Ð"SÐ0@Ð"SÐ"SÀMÐ"SÐ"SÑTÔTÐTØ Ô*Ô9×@Ò@Ø>Ð"2Ô"7Ð>Ð>Ð>ñô ð õ Ð0Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1øøøøð2øøøð ˆKØ%ð /ð /�Ø˜T’>�>Ø"#�K�Kà¥3 v¡;¤;Ñ.�K�Kà�S Ñ-Ô-Ñ-°Ñ1°]ÀQÑ5FÒGÐGØ×"Ò" 4Ñ(Ô(Ð(à×Ò˜{Ñ+Ô+Ð+Ø×Ò�w wÔ/Ñ0Ô0Ð0Ñ0Ø×Ò˜bŸgšg k°!°B°$Ô&7Ñ8Ô8Ñ9Ô9Ð9Ñ9å�cŒ]˜TÑ!€FØŸš ^Ñ4Ô4µxÀ´}ÑDÐàÔÔ-×4Ò4ØBÐ&Ô+ÐBÐBÐ.@ÐBÐBñô ð ð Ðs   ÁAÁ
C	Á&ACÂ:C	ÃC	c                ó´  — g | j         _        | j        }|t          j        v r9t          j        |         }| j         j                             d|› d|› �¦  «         |S |                     ¦   «         }g }	 |D ]&}|                     t          |d¬¦  «        ¦  «         Œ'ng# t          $ rZ}t           
                    d| › d|› �¦  «         | j         j                             d|› d�¦  «         t          d         cY d}~S d}~ww xY wt          d	                              |¦  «        }| j         j                             d|› d|› �¦  «         |r>t          d
         |z   }| j         j                             ddt          d
         › �¦  «         t          |¦  «        dk    r=|t          d
         z   }| j         j                             dt          d
         › �¦  «         |S )u£  
    Takes in a :class:`~music21.expressions.TextExpression` and returns its
    representation in UTF-8 unicode.

    From the lookup table:

    >>> from music21.braille.basic import textExpressionToBraille
    >>> print(textExpressionToBraille(expressions.TextExpression('cresc.')))
    â œâ ‰â —â „

    Single word expression has word symbol (â œ) only at beginning:

    >>> print(textExpressionToBraille(expressions.TextExpression('dolce')))
    â œâ ™â •â ‡â ‰â ‘

    Multiple word expression has word symbol at beginning and end.

    >>> print(textExpressionToBraille(expressions.TextExpression('dim. e rall.')))
    â œâ ™â Šâ �â „â €â ‘â €â —â �â ‡â ‡â „â œ
    zText Expression r   Tr   r�   r   r   Nr�   r~   r   zWord r0   )r   r   Úcontentr   ÚtextExpressionsr;   r’   r‚   r„   r!   r"   r#   r<   r�   r?   )	Úmusic21TextExpressionr†   ÚteWordsÚsimpleReturnÚallExprÚtextExpressionTransr  r‰   ÚbrailleTextExprs	            r&   ÚtextExpressionToBrailler4  ü  s!  € ð* 68ÐÔ#Ô2Ø#Ô+€GØ•&Ô(Ð(Ð(ÝÔ-¨gÔ6ˆØÔ'Ô6×=Ò=Ø7˜wÐ7Ð7¨Ð7Ð7ñ	9ô 	9ð 	9àÐð �mŠm‰oŒo€GØÐð*Øð 	Sð 	SˆDØ×&Ò&¥}°TÈDÐ'QÑ'QÔ'QÑRÔRÐRÐRð	Søå ð *ð *ð *Ý×ÒÐUÐ-BÐUÐUÀmÐUÐUÑVÔVÐVØÔ'Ô6×=Ò=Ð>_ÐQXÐ>_Ð>_Ð>_Ñ`Ô`Ð`ÝÐ(Ô)Ð)Ð)Ð)Ð)Ð)Ð)øøøøð*øøøõ
 ˜gÔ&×+Ò+Ð,?Ñ@Ô@€OØÔ#Ô2×9Ò9Ø6˜7Ð6Ð6 _Ð6Ð6ñ8ô 8ð 8ð ð \Ý! &œ/¨OÑ;ˆØÔ'Ô6×=Ò=¸aÐAZÍÐQWÌÐAZÐAZÑ[Ô[Ð[å
ˆ7�|„|�aÒÐØ)­G°F¬OÑ;ˆØÔ'Ô6×=Ò=Ð>WÅgÈfÄoÐ>WÐ>WÑXÔXÐXàÐs   Á2)B Â
D Â&AC;Ã5D Ã;D c                óh  — g | j         _        | j        dv r>t          | j                 }| j         j                             d| j        › d|› �¦  «         |S 	 t          | j        ¦  «        t          | j        dd¬¦  «        g}d                     |¦  «        }| j         j                             d| j        › d| j        › d|› �¦  «         |S # t          t          f$ rW}t                               d| › d	�¦  «         | j         j                             | › d
�¦  «         t          d         cY d}~S d}~ww xY w)ué  
    Takes in a :class:`~music21.meter.TimeSignature` and returns its
    representation in braille as a string in UTF-8 unicode.

    >>> from music21.braille.basic import timeSigToBraille
    >>> print(timeSigToBraille(meter.TimeSignature('4/4')))
    â ¼â ™â ²
    >>> print(timeSigToBraille(meter.TimeSignature('3/4')))
    â ¼â ‰â ²
    >>> print(timeSigToBraille(meter.TimeSignature('12/8')))
    â ¼â �â ƒâ ¦
    >>> print(timeSigToBraille(meter.TimeSignature('c')))
    â ¨â ‰
    )ÚcommonÚcutzTime Signature r   FTrÎ   r5   ú/r   r   r   N)r   r   Úsymbolr#   r;   r¬   Ú	numeratorÚdenominatorr<   r„   r    r!   r"   )Úm21TimeSignatureÚ
brailleSigÚtimeSigTransÚunused_errors       r&   ÚtimeSigToBrailler@  5  sœ  € ð 13ÐÔÔ-àÔÐ"3Ð3Ð3ÝÐ-Ô4Ô5ˆ
ØÔ"Ô1×8Ò8ØDÐ.Ô5ÐDÐD¸
ÐDÐDñ	Fô 	Fð 	FàÐð*Ý'Ð(8Ô(BÑCÔCÝ'Ð(8Ô(DØ7<Ø.2ð4ñ 4ô 4ð5ˆð —W’W˜\Ñ*Ô*ˆ
ØÔ"Ô1×8Ò8ðÐ.Ô8ð ð Ð;KÔ;Wð ð Øðð ñ	
ô 	
ð 	
ð ÐøÝ!¥8Ð,ð *ð *ð *Ý×ÒØRÐ.ÐRÐRÐRñ	Tô 	Tð 	TàÔ"Ô1×8Ò8Ð<LÐ9SÐ9SÐ9SÑTÔTÐTÝÐ(Ô)Ð)Ð)Ð)Ð)Ð)Ð)øøøøð	*øøøs    ÁA3C	 Ã	D1ÃAD,Ä&D1Ä,D1c                ó¨   — | €dS t          j        | |¦  «        }|j        j        dk    }|j        j        dv }| j        |j        k    }d}|s|r|sd}|S )a9  
    Determines whether a currentNote carries an octave designation
    in relation to a previous Note.

    Rules:

    * If currentNote is found within a second or third
      of previousNote, currentNote does not
      carry an octave designation.

    * If currentNote is found a sixth or
      more away from previousNote, currentNote does carry
      an octave designation.

    * If currentNote is found within a fourth or fifth
      of previousNote, currentNote carries
      an octave designation if and only if currentNote and
      previousNote are not found in the
      same octave.

    Of course, these rules cease to apply in quite a few cases,
    which are not directly reflected
    in the results of this function:

    1) If a braille measure goes to a new line, the first note in the measure carries an
       octave designation regardless of what the previous note was.

    2) If a braille measure contains a new key or time signature, the first note carries
       an octave designation regardless of what the previous note was.

    3) If a new key or time signature occurs in the middle of a measure, or if a double bar
       line is encountered, both of which would necessitate a music hyphen, the next note after
       those cases needs an octave marking.

    If any special case happens, previousNote can be set to None and the function will return
    True.

    >>> from music21.braille.basic import showOctaveWithNote
    >>> showOctaveWithNote(note.Note('C4'), note.Note('E4'))
    False
    >>> showOctaveWithNote(note.Note('C4'), note.Note('F4'))
    False
    >>> showOctaveWithNote(note.Note('C4'), note.Note('F3'))
    True
    >>> showOctaveWithNote(note.Note('C4'), note.Note('A4'))
    True

    If previousNote is None, it is always True

    >>> showOctaveWithNote(None, note.Note('A4'))
    True
    NTrY   )é   é   F)r
   ÚIntervalÚgenericrC   rE   )ÚpreviousNoteÚcurrentNoteÚiÚisSixthOrGreaterÚisFourthOrFifthÚsameOctaveAsPreviousÚdoShowOctaves          r&   ÚshowOctaveWithNoterM  a  sy   € ðj ÐØˆtÝÔ˜,¨Ñ4Ô4€AØ”yÔ+¨qÒ0ÐØ”iÔ*¨fÐ4€OØ'Ô.°+Ô2DÒDÐØ€LØð ˜Oð Ð4Hð ØˆàÐr]   c                óÌ  — | €|€|€|€t          d¦  «        ‚d}|�t          ||¬¦  «        }| €Þ|€Ü|€Ú|                     ¦   «         }g }|D ]}|                     |¦  «         Œt	          |¦  «        |dz
  k    r6d                     |¦  «        }|                     |t          d         ¦  «        S t          t	          |¦  «        ¦  «        D ],}	||	                              |t          d         ¦  «        ||	<   Œ-d                     |¦  «        S g }
|�$t          |¦  «        }|
                     |¦  «         	 t          | |¦  «        }|� |
                     t          d         ¦  «         |
                     |¦  «         n## t           $ r |€|€t          d¦  «        ‚Y nw xY wd                     |
¦  «        }|€!|                     |t          d         ¦  «        S |                     ¦   «         }g }|D ]}|                     |¦  «         Œ|                     |¦  «         t	          |¦  «        dk    r-|d	         s%|dd…         }t	          |¦  «        dk    r|d	         ¯%t	          |¦  «        dk    r-|d
         s%|dd
…         }t	          |¦  «        dk    r|d
         ¯%t	          |¦  «        t	          |¦  «        z   dz   |dz
  k    rAt          d                              |¦  «        }|                     |t          d         ¦  «        S t          t	          |¦  «        ¦  «        D ],}	||	                              |t          d         ¦  «        ||	<   Œ-d                     |¦  «        S )u6	  
    Takes in a :class:`~music21.key.KeySignature`, :class:`~music21.meter.TimeSignature`,
    :class:`~music21.tempo.TempoText`, and
    :class:`~music21.tempo.MetronomeMark` and returns its representation in braille as a
    string in UTF-8 unicode. The contents
    are always centered on a line, whose width is 40 by default.

    In most cases, the format is (tempo text)(space)(metronome mark)(space)(key/time signature),
    centered, although all of
    these need not be included. If all the contents do not fit on one line with at
    least 3 blank characters on each side, then
    the tempo text goes on the first line (and additional lines if necessary),
    and the metronome mark + key and time signature
    goes on the last line.

    If the resulting heading is of length zero, a BrailleBasicException is raised.

    >>> from music21.braille.basic import transcribeHeading
    >>> print(transcribeHeading(
    ...         key.KeySignature(5),
    ...         meter.TimeSignature('3/8'),
    ...         tempo.TempoText('Allegretto'),
    ...         tempo.MetronomeMark(number=135, referent=note.Note(type='eighth'))))
    â €â €â €â €â €â €â €â  â �â ‡â ‡â ‘â ›â —â ‘â žâ žâ •â ²â €â ™â ¶â ¼â �â ‰â ‘â €â ¼â ‘â ©â ¼â ‰â ¦â €â €â €â €â €â €â €
    >>> print(transcribeHeading(
    ...          key.KeySignature(-2),
    ...          meter.TimeSignature('common'),
    ...          tempo.TempoText('Lento assai, cantante e tranquillo'),
    ...          None))
    â €â €â €â €â €â €â €â €â €â €â €â €â €â  â ‡â ‘â �â žâ •â €â �â Žâ Žâ �â Šâ ‚â €â €â €â €â €â €â €â €â €â €â €â €â €â €
    â €â €â €â €â €â €â €â €â €â ‰â �â �â žâ �â �â žâ ‘â €â ‘â €â žâ —â �â �â Ÿâ ¥â Šâ ‡â ‡â •â ²â €â €â €â €â €â €â €â €â €
    â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â £â £â ¨â ‰â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €
    >>> print(transcribeHeading(
    ...          key.KeySignature(-2),
    ...          meter.TimeSignature('common'),
    ...          tempo.TempoText('Lento assai, cantante e tranquillo'),
    ...          None,
    ...          maxLineLength=10))
    â €â  â ‡â ‘â �â žâ •â €â €â €
    â €â €â �â Žâ Žâ �â Šâ ‚â €â €
    â €â €â €â €â €â €â €â €â €â €
    â ‰â �â �â žâ �â �â žâ ‘â €â €
    â €â €â €â €â ‘â €â €â €â €â €
    â žâ —â �â �â Ÿâ ¥â Šâ ‡â ‡â •â ²
    â €â €â €â £â £â ¨â ‰â €â €â €

    NzNo heading can be made.r  rY   r5   r�   r/   r0   r   rÒ   )r„   r*  Ú
splitlinesr;   r?   r<   Úcenterr#   r>   r²   ÚtranscribeSignatures)rž   Úmusic21TimeSignaturer  r­   r  ÚtempoTextTransÚtempoTextLinesÚheadingTransÚtempoText_lineÚheading_line_indexÚ
otherTransÚmetronomeMarkTransÚkeyAndTimeSigÚotherTransStrÚtempo_text_lineÚheadingTrans_strs                   r&   ÚtranscribeHeadingr^  £  sÒ  € ðn 	Ð#Ø$Ð,Ø Ð(Ø$Ð,Ý#Ð$=Ñ>Ô>Ð>à€NØÐ#Ý+Ð,<ÈMÐZÑZÔZˆàÐ#Ø$Ð,Ø$Ð,Ø'×2Ò2Ñ4Ô4ˆØˆØ,ð 	0ð 	0ˆNØ×Ò Ñ/Ô/Ð/Ð/Ýˆ~ÑÔ =°1Ñ#4Ò5Ð5ØŸ7š7 <Ñ0Ô0ˆLØ×&Ò& }µg¸gÔ6FÑGÔGÐGå&+­C°Ñ,=Ô,=Ñ&>Ô&>ð ð Ð"Ø3?Ð@RÔ3S×3ZÒ3ZØ!Ý˜GÔ$ñ4ô 4�Ð/Ñ0Ð0ð —9’9˜\Ñ*Ô*Ð*à€JàÐ'Ý3Ð4HÑIÔIÐØ×ÒÐ,Ñ-Ô-Ð-ðCÝ,Ð-@ÐBVÑWÔWˆØÐ+Ø×Ò�g gÔ.Ñ/Ô/Ð/Ø×Ò˜-Ñ(Ô(Ð(Ð(øÝ ð Cð Cð CØÐ'Ð,<Ð,DÝ'Ð(AÑBÔBÐBøøðCøøøð —G’G˜JÑ'Ô'€MàÐØ×#Ò# Mµ7¸7Ô3CÑDÔDÐDà'×2Ò2Ñ4Ô4ˆØˆØ-ð 	1ð 	1ˆOØ×Ò Ñ0Ô0Ð0Ð0Ø×Ò˜MÑ*Ô*Ð*Ý�,ÑÔ !Ò#Ð#¨L¸¬OÐ#à'¨¨¨Ô+ˆLõ �,ÑÔ !Ò#Ð#¨L¸¬OÐ#õ �,ÑÔ !Ò#Ð#¨L¸Ô,<Ð#à'¨¨¨Ô,ˆLõ �,ÑÔ !Ò#Ð#¨L¸Ô,<Ð#õ ˆ~ÑÔ¥ ]Ñ!3Ô!3Ñ3°aÑ7¸MÈAÑ<MÒNÐNÝ& wÔ/×4Ò4°\ÑBÔBÐØ#×*Ò*¨=½'À'Ô:JÑKÔKÐKå&+­C°Ñ,=Ô,=Ñ&>Ô&>ð ð Ð"Ø3?Ð@RÔ3S×3ZÒ3ZØ!Ý˜GÔ$ñ4ô 4�Ð/Ñ0Ð0ð —9’9˜\Ñ*Ô*Ð*s   Ä6AE> Å>FÆFÚ1c                ó„  — t           j        }t          | t          ¦  «        rt	          | ¦  «        } t          | ¦  «        dk    r)	 ||          S # t          $ r t          d| › �¦  «        ‚w xY wg }|                      d¦  «        }t          |¦  «        dk    rd}n2t          |¦  «        dk    r|                      d¦  «        }d}nt          ‚|s| 	                    ¦   «          t          t          |¦  «        ¦  «        D �]-}||                              d¦  «        }	 t          |¦  «        dk    rc|                     ||d	                  ¦  «         |                     t          d
         ¦  «         |                     ||d                  ¦  «         nxt          |¦  «        dk    re|d	         }d}		 ||         }	n<# t          $ r/}
|s|
‚|d	k    rt          d         }	nt          d         }	Y d}
~
nd}
~
ww xY w|                     |	¦  «         �Œ# t          $ r t          d| › �¦  «        ‚w xY wd                     |¦  «        S )u  
    Takes in a note fingering and returns its correct transcription to braille.

    >>> from music21.braille.basic import transcribeNoteFingering
    >>> print(transcribeNoteFingering('4'))
    â ‚

    A change of fingering:

    >>> print(transcribeNoteFingering('2-1'))
    â ƒâ ‰â �

    A choice of fingering, both on either the top or bottom of the staff:

    >>> print(transcribeNoteFingering('5|4', upperFirstInFingering=True))
    â …â ‚
    >>> print(transcribeNoteFingering('5|4', upperFirstInFingering=False))
    â ‚â …

    A choice of fingering, one on top and one below the staff:

    >>> print(transcribeNoteFingering('2,1', upperFirstInFingering=True))
    â ƒâ �
    >>> print(transcribeNoteFingering('2,1', upperFirstInFingering=False))
    â �â ƒ

    A choice of fingering, first set missing fingermark:

    >>> print(transcribeNoteFingering('2,x'))
    â ƒâ „

    A choice of fingering, second set missing fingermark:

    >>> print(transcribeNoteFingering('x,2'))
    â  â ƒ

    Missing fingermarks change with upperFirstInFingering

    >>> print(transcribeNoteFingering('x,4', upperFirstInFingering=True))
    â  â ‚
    >>> print(transcribeNoteFingering('x,4', upperFirstInFingering=False))
    â ‚â „
    >>> print(transcribeNoteFingering('4,x', upperFirstInFingering=True))
    â ‚â „
    >>> print(transcribeNoteFingering('4,x', upperFirstInFingering=False))
    â  â ‚

    A change of fingering and a choice of fingering combined (thanks to Bo-cheng Jhan
    for the patch):

    >>> print(transcribeNoteFingering('1-2|3-4'))
    â �â ‰â ƒâ ‡â ‰â ‚

    Incorrect fingerings raise a BrailleBasicException:

    >>> transcribeNoteFingering('6')
    Traceback (most recent call last):
    music21.braille.basic.BrailleBasicException: Cannot translate note fingering: 6
    r0   z!Cannot translate note fingering: r  rX   Tú|Fú-r   Úfinger_changer5   Úfirst_set_missing_fingermarkÚsecond_set_missing_fingermarkN)r   ÚfingerMarksrq   Úintr  r?   r    r„   r’   r8   r>   r;   r#   r<   )ÚsampleNoteFingeringrÄ   rf  r•   ÚchoiceÚallowAbsencerH  ÚchangeÚ
changeMarkÚfingerMarkToAppendÚes              r&   rþ   rþ   "  s�  € õx Ô$€KÝÐ%¥sÑ+Ô+ð 7Ý!Ð"5Ñ6Ô6Ðå
ÐÑÔ 1Ò$Ð$ð	cØÐ2Ô3Ð3øÝð 	cð 	cð 	cÝ'Ð(aÐL_Ð(aÐ(aÑbÔbÐbð	cøøøð €EØ ×&Ò& sÑ+Ô+€FÝ
ˆ6�{„{�aÒÐØˆˆÝ	ˆV‰Œ˜Ò	Ð	Ø$×*Ò*¨3Ñ/Ô/ˆØˆˆåˆØ ð Ø�ŠÑÔÐå•3�v‘;”;ÑÔð cñ cˆØ˜”—’ Ñ%Ô%ˆð	cÝ�6‰{Œ{˜aÒÐØ—’˜[¨°¬Ô3Ñ4Ô4Ð4Ø—’�W _Ô5Ñ6Ô6Ð6Ø—’˜[¨°¬Ô3Ñ4Ô4Ð4Ð4Ý�V‘” Ò!Ð!Ø# AœY�
Ø%'Ð"ð
VØ)4°ZÔ)@Ð&Ð&øÝð Vð Vð VØ'ð  Ø˜ð ˜A’v�vÝ-4Ð5SÔ-TÐ*Ð*å-4Ð5TÔ-UÐ*øøøøøøøøøðVøøøð —’Ð/Ñ0Ô0Ð0ùøÝð 	cð 	cð 	cÝ'Ð(aÐL_Ð(aÐ(aÑbÔbÐbð	cøøøð �7Š7�5‰>Œ>ÐsC   ÁA ÁA*ÄBHÆ1F:Æ9HÆ:
G3Ç%G.Ç)HÇ.G3Ç3HÈH*c                óê   — |€| �| j         dk    r|€dS g }| �$|                     t          | |¬¦  «        ¦  «         |�"|                     t          |¦  «        ¦  «         d                     |¦  «        S )uE  
    Takes in a :class:`~music21.key.KeySignature` and
    :class:`~music21.meter.TimeSignature` and returns its representation
    in braille as a string in UTF-8 unicode. If given an old key signature,
    then its cancellation will be applied before
    and in relation to the new key signature.

    Raises a BrailleBasicException if the resulting key and time signature is
    empty, which happens if the time signature
    is None and (a) the key signature is None or (b) the key signature has
    zero sharps and there is no previous key signature.

    >>> from music21.braille.basic import transcribeSignatures
    >>> print(transcribeSignatures(key.KeySignature(5), meter.TimeSignature('3/8'), None))
    â ¼â ‘â ©â ¼â ‰â ¦
    >>> print(transcribeSignatures(key.KeySignature(0), None, key.KeySignature(-3)))
    â ¡â ¡â ¡
    Nr   r5   )rŸ   )rš   r;   r¦   r@  r<   )rž   rR  rŸ   r•   s       r&   rQ  rQ  �  s…   € ð& 	Ð$Ø$Ð,Ø(Ô/°1Ò4Ð4¸Ð9OØˆrà€EØÐ&Ø�Š•_Ð%8ÈÐXÑXÔXÑYÔYÐYØÐ'Ø�ŠÕ%Ð&:Ñ;Ô;Ñ<Ô<Ð<à�7Š7�5‰>Œ>Ðr]   c                ó   — |                       ¦   «         }g }|D ]Q}g }|D ]"}|                     t          |         ¦  «         Œ#|                     d                     |¦  «        ¦  «         ŒRd                     |¦  «        S )a©  
    translates a braille UTF-8 unicode string into braille ASCII,
    which is the format compatible with most braille embossers.

    .. note:: The function works by corresponding braille symbols to ASCII symbols.
        The table which corresponds to said values can be found
        `here <https://en.wikipedia.org/wiki/Braille_ASCII#Braille_ASCII_values>`_.
        Because of the way in which the braille symbols translate, the resulting
        ASCII string will look to a non-reader as gibberish. Also, the eighth-note notes
        in braille music are one-off their corresponding letters
        in both ASCII and written braille.
        The written D is really a C eighth-note, the written E is really a
        D eighth note, etc.

    >>> from music21.braille.basic import brailleUnicodeToBrailleAscii, noteToBraille
    >>> brailleUnicodeToBrailleAscii('\u2800')
    ' '
    >>> Cs8 = note.Note('C#4', quarterLength=0.5)
    >>> Cs8_braille = noteToBraille(Cs8)
    >>> brailleUnicodeToBrailleAscii(Cs8_braille)
    '%"D'
    >>> Eb8 = note.Note('E-4', quarterLength=0.5)
    >>> Eb8_braille = noteToBraille(Eb8)
    >>> brailleUnicodeToBrailleAscii(Eb8_braille)
    '<"F'
    r5   r/   )rO  r;   Úascii_charsr<   )ÚbrailleUnicodeÚbrailleLinesÚ
asciiLinesÚ
sampleLineÚallCharsÚchars         r&   ÚbrailleUnicodeToBrailleAsciirx  ´  sŒ   € ð6 "×,Ò,Ñ.Ô.€LØ€Jà"ð -ð -ˆ
ØˆØð 	/ð 	/ˆDØ�OŠO�K¨Ô-Ñ.Ô.Ð.Ð.Ø×Ò˜"Ÿ'š' (Ñ+Ô+Ñ,Ô,Ð,Ð,à�9Š9�ZÑ Ô Ð r]   ÚbrailleAsciic                óR  — i }t           D ]}||t           |         <   Œ|                      ¦   «         }g }|D ]^}g }|D ]/}|                     ||                     ¦   «                  ¦  «         Œ0|                     d                     |¦  «        ¦  «         Œ_d                     |¦  «        S )ut  
    translates a braille ASCII string to braille UTF-8 unicode, which
    can then be displayed on-screen in braille on compatible systems.

    .. note:: The function works by corresponding ASCII symbols to braille
        symbols in a very direct fashion. It is not a translator from plain
        text to braille, because ASCII symbols may not correspond to their
        equivalents in braille. For example, a literal period is a 4 in
        braille ASCII. Also, all letters are translated into their lowercase
        equivalents, and any capital letters are indicated by preceding them
        with a comma.

    >>> t1 = braille.basic.brailleAsciiToBrailleUnicode(',ANDANTE ,MAESTOSO4')
    >>> t1
    'â  â �â �â ™â �â �â žâ ‘â €â  â �â �â ‘â Žâ žâ •â Žâ •â ²'
    >>> t2 = braille.basic.tempoTextToBraille(tempo.TempoText('Andante Maestoso'))
    >>> t1 == t2
    True
    r5   r/   )rq  rO  r;   Úupperr<   )ry  Úbraille_charsr½   rt  rs  ru  rv  rw  s           r&   ÚbrailleAsciiToBrailleUnicoder}  Û  sº   € ð( €MÝð .ð .ˆØ*-ˆ•k #Ô&Ñ'Ð'à×(Ò(Ñ*Ô*€JØ€Là ð /ð /ˆ
ØˆØð 	9ð 	9ˆDØ�OŠO˜M¨$¯*ª*©,¬,Ô7Ñ8Ô8Ð8Ð8Ø×Ò˜BŸGšG HÑ-Ô-Ñ.Ô.Ð.Ð.à�9Š9�\Ñ"Ô"Ð"r]   Úoõ   Â·c                ó¢  — |› |› �|› |› �|› |› �|› |› �dœ}|                       ¦   «         }g }|D �]}g }g }g }	|D ]i}
t          j        |
         \  }}}|                     ||         ¦  «         |                     ||         ¦  «         |	                     ||         ¦  «         Œj|                     d                     |¦  «        ¦  «         |                     d                     |¦  «        ¦  «         |                     d                     |	¦  «        ¦  «         |                     d¦  «         �Œd                     |dd…         ¦  «        S )u«   
    translates a braille unicode string into symbols (unicode) -- for debugging.

    >>> print(braille.basic.brailleUnicodeToSymbols('â œ'))
    Â·o
    Â·o
    oÂ·
    )Ú00Ú01Ú10Ú11z  r5   r/   r   rÒ   )rO  r   Úbinary_dotsr;   r<   )rr  ÚfilledSymbolÚemptySymbolÚsymbolTransrs  ÚbinaryLinesru  ÚbinaryLine1ÚbinaryLine2ÚbinaryLine3rw  Údots14Údots25Údots36s                 r&   ÚbrailleUnicodeToSymbolsr�  ÿ  s�  € ð (Ð6¨Ð6Ð6Ø'Ð7¨Ð7Ð7Ø(Ð7¨+Ð7Ð7Ø(Ð8¨,Ð8Ð8ð:ð :€Kð
 "×,Ò,Ñ.Ô.€LØ€Kà"ð ñ ˆ
ØˆØˆØˆØð 	4ð 	4ˆDÝ'-Ô'9¸$Ô'?Ñ$ˆV�V˜VØ×Ò˜{¨6Ô2Ñ3Ô3Ð3Ø×Ò˜{¨6Ô2Ñ3Ô3Ð3Ø×Ò˜{¨6Ô2Ñ3Ô3Ð3Ð3Ø×Ò˜4Ÿ9š9 [Ñ1Ô1Ñ2Ô2Ð2Ø×Ò˜4Ÿ9š9 [Ñ1Ô1Ñ2Ô2Ð2Ø×Ò˜4Ÿ9š9 [Ñ1Ô1Ñ2Ô2Ð2Ø×Ò˜2ÑÔÐÑà�9Š9�[  2 Ô&Ñ'Ô'Ð'r]   c              #  óZ   K  — t           j        |          D ]}|dv rt          d         V — ŒdS )uý  
    Generator that yields symbol['dot'] characters for each row of a
    braille character that where the left dot is filled.  These
    are used in many places in Braille Music Code.

    >>> B = braille.lookup.brailleDotDict
    >>> gen = braille.basic.yieldDots(B[1])
    >>> gen
    <generator object yieldDots at 0x10aee5f68>
    >>> for dot in gen:
    ...     print(dot)
    â „
    >>> gen = braille.basic.yieldDots(B[1235])
    >>> for dot in gen:
    ...     print(dot)
    â „
    â „
    â „
    )rƒ  r„  rÑ   N)r   r…  r#   )ÚbrailleCharacterræ   s     r&   Ú	yieldDotsr“  !  sF   è è € õ( Ô"Ð#3Ô4ð !ð !ˆØ�<ÐÐÝ˜%”.Ð Ð Ð øð!ð !r]   r$  c           	     óˆ  ‡— g Šdˆfd„}|rÃ| D ]«}|                      ¦   «         r ||                     ¦   «         ¦  «         Œ4|dk    r!‰                     t          d         ¦  «         Œ[|dk    r |d¦  «          |d¦  «         Œx	  ||¦  «         Œ…# t          $ r t          d|› d	| › d
�dz   ¦  «        ‚w xY wd                     ‰¦  «        S d}| D �]Z}	 |                     ¦   «         r%|s#‰                     t          d         ¦  «         d}n8|                     ¦   «         r$|r"‰                     t          d         ¦  «         d}|                      ¦   «         r>‰                     t          d         ¦  «          ||                     ¦   «         ¦  «         no|                     ¦   «         r3‰                     t          j
        t          |¦  «                 ¦  «         n(|dk    r |d¦  «          |d¦  «         n ||¦  «         �Œ8# t          $ r t          d|› d| › d�¦  «        ‚w xY wd                     ‰¦  «        S )u¬  
    Transcribes a word to UTF-8 braille.

    >>> from music21.braille.basic import wordToBraille
    >>> print(wordToBraille('Andante'))
    â  â �â �â ™â �â �â žâ ‘

    Try the German for violin.

    >>> print(wordToBraille('Geige'))
    â  â ›â ‘â Šâ ›â ‘

    Tests number symbol at beginning, punctuation in number
    and switch back to letters.

    >>> print(wordToBraille('25.4cm'))
    â ¼â ƒâ ‘â ²â ™â °â ‰â �
    Úinner_letterr  c                ó6  •— | t           v r"‰                     t           |          ¦  «         d S t          j        | ¦  «        }|| k    rt	          d| z   ¦  «        ‚‰                     t           d         ¦  «         ‰                     t           |         ¦  «         d S )NzCannot translate ú^)r  r;   r   ÚstripAccentsr    )r•  Úl2Ú	wordTranss     €r&   Ú
add_letterz!wordToBraille.<locals>.add_letterS  s’   ø€ Ø�8Ð#Ð#Ø×Ò�X lÔ3Ñ4Ô4Ð4Ð4Ð4åÔ)¨,Ñ7Ô7ˆBØ�\Ò!Ð!ÝÐ2°\ÑAÑBÔBÐBØ×Ò�X cœ]Ñ+Ô+Ð+Ø×Ò�X bœ\Ñ*Ô*Ð*Ð*Ð*r]   r  rÑ   õ   ÃŸÚszCharacter 'z' in Text Expression 'z' rÔ   r5   Frª   TÚletter_signÚ	uppercasez' in word 'ú#' cannot be transcribed to braille.)r•  r  )ÚisupperrÐ   r;   r#   r    r„   r<   ÚisdigitÚisalphar   ÚnumbersUpperrg  )r$  r€   r›  ÚletterÚlastCharWasNumberrš  s        @r&   r‚   r‚   =  sÇ  ø€ ð( €Ið+ð +ð +ð +ð +ð +ð ð "Ø ð 	?ð 	?ˆFØ�~Š~ÑÔð ?Ø�
˜6Ÿ<š<™>œ>Ñ*Ô*Ð*Ð*Ø˜3’�Ø× Ò ¥¨¤Ñ0Ô0Ð0Ð0Ø˜4’�Ø�
˜3‘”�Ø�
˜3‘”��ð?Ø�J˜vÑ&Ô&Ð&Ð&øÝð ?ð ?ð ?Ý/ØR fÐRÐRÀJÐRÐRÐRØ=ñ>ñ?ô ?ð ?ð?øøøð �wŠw�yÑ!Ô!Ð!àÐàð ñ ˆð	Ø�~Š~ÑÔð *Ð(9ð *Ø× Ò ¥¨Ô!2Ñ3Ô3Ð3Ø$(Ð!Ð!Ø—’Ñ!Ô!ð *Ð&7ð *Ø× Ò ¥¨Ô!7Ñ8Ô8Ð8Ø$)Ð!à�~Š~ÑÔð 	#Ø× Ò ¥¨Ô!5Ñ6Ô6Ð6Ø�
˜6Ÿ<š<™>œ>Ñ*Ô*Ð*Ð*Ø—’Ñ!Ô!ð #Ø× Ò ¥Ô!4µS¸±[´[Ô!AÑBÔBÐBÐBØ˜4’�Ø�
˜3‘”�Ø�
˜3‘”��à�
˜6Ñ"Ô"Ð"ùøåð 	ð 	ð 	Ý'Ø`˜fÐ`Ð`°Ð`Ð`Ð`ñô ð ð	øøøð
 �7Š7�9ÑÔÐs   ÂBÂ$B7ÃD2HÈ!H,ÚsampleNumberrg  c           	     óh  — g }|r |                      t          d         ¦  «         |rt          j        }nt          j        }t          | ¦  «        D ]O}	 |                      |t          |¦  «                 ¦  «         Œ,# t          $ r t          d|› d| › d�¦  «        ‚w xY wd 	                    |¦  «        S )u*  
    Transcribes a number to UTF-8 braille. By default, the result number
    occupies the upper two thirds of braille cells with a leading number sign.
    If withNumberSign is set to False, the leading number sign will be removed.
    If lower is set to True, the position will be changed from the upper (1245
    dots) to the lower (2356 dots).

    >>> from music21.braille.basic import numberToBraille
    >>> print(numberToBraille(12))
    â ¼â �â ƒ
    >>> print(numberToBraille(7))
    â ¼â ›
    >>> print(numberToBraille(37))
    â ¼â ‰â ›
    rª   zDigit 'z' in number 'r   r5   )
r;   r#   r   ÚnumbersLowerr¤  r  rg  Ú
ValueErrorr„   r<   )r§  rÏ   rÐ   ÚnumberTransÚnumbersÚdigits         r&   r¬   r¬   �  sÙ   € ð  €KØð .Ø×Ò�7 8Ô,Ñ-Ô-Ð-Øð &ÝÔ%ˆˆåÔ%ˆÝ�\Ñ"Ô"ð ð ˆð	Ø×Ò˜w¥s¨5¡z¤zÔ2Ñ3Ô3Ð3Ð3øÝð 	ð 	ð 	Ý'Ø_˜%Ð_Ð_¨lÐ_Ð_Ð_ñô ð ð	øøøð �7Š7�;ÑÔÐs   Á(A;Á;!Bc                  ó   — e Zd ZdS )r„   N©rw   Ú
__module__Ú__qualname__r�   r]   r&   r„   r„   °  ó   € € € € € Ø€Dr]   r„   c                  ó   — e Zd ZdS )ÚTestNr¯  r�   r]   r&   r´  r´  ¶  r²  r]   r´  Ú__main__)TT)F)Trµ   )r-   rÅ   )rê   rú   )r-   r  rê   rú   )r  r  r  r  )NNNNr  )r_  T)ry  r  r  r  )r~  r  )r$  r  r  r  )TF)r§  rg  r  r  )>Ú__doc__Ú
__future__r   ÚtypingÚtÚunittestÚmusic21r   r   r   r   r   r	   r
   r   Úmusic21.brailler   Úmusic21.commonr   ÚTYPE_CHECKINGr   r  rq  r#   ÚEnvironmentr!   r   Ú__annotations__rÛ   r'   rV   rD   r|   rŠ   r—   r¦   r²   rÃ   r:   r@   rç   rè   r  r*  r4  r@  rM  r^  rþ   rQ  rx  r}  r�  r“  r‚   r¬   ÚMusic21Exceptionr„   ÚTestCaser´  rw   ÚmainTestr�   r]   r&   ú<module>rÄ     sS  ððð ð ð: #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€à !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à "Ð "Ð "Ð "Ð "Ð "Ø &Ð &Ð &Ð &Ð &Ð &à„?ð ØÐÐÐÐÐð Œ?€ØÔ €Ø
Œ.€à&ˆ{Ô& zÑ2Ô2€à €
Ð  Ð  Ð  Ñ  ð(ð (ð (Ð ð*ð *ð *ð@yð yð yð yðx00ð 00ð 00ðfM*ð M*ð M*ð M*ð`!ð !ð !ð !ðDð ð ð6Dð Dð Dð DðN,*ð ,*ð ,*ð^@ð @ð @ðL Øð	jð jð jð jð jð jðZ7ð 7ð 7ð 3ð 3ð 3ð 3ð 3ð bð bð bð bð"-ð -ð -ðf ðCð Cð Cð Cð Cð CðL6ð 6ð 6ð 6ðr&*ð &*ð &*ðX?ð ?ð ?ðF ØØØØð|+ð |+ð |+ð |+ð~kð kð kð kð\ð ð ð ðH$!ð $!ð $!ðN!#ð !#ð !#ð !#ðH(ð (ð (ð (ðD!ð !ð !ð8Mð Mð Mð Mð Mð` ð  ð  ð  ð  ðF	ð 	ð 	ð 	ð 	˜LÔ9ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	ˆ8Ôñ 	ô 	ð 	ð ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr]   