§
    ƒØj:�  ã                  óB  — 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dddddddddddddddœd&d„Zdddddddddddddddddœd'd„Zdddddddddddddddddœd(d„Zd)d*d„Zdddddddddddddddddœd(d„Zdddddddddddddddddœd(d„Zdddddddddddddddddœd(d„Zdddddddddddddddddœd(d „ZegZ G d!„ d"ej        ¦  «        Z G d#„ d$ej        ¦  «        Zed%k    rddlZ ej        e¦  «         dS dS )+ay  
Functions for exporting music21 data as braille.

This module was made in consultation with the manual "Introduction to Braille
Music Transcription, Second Edition" by Mary Turner De Garmo, 2005. It is
available from the Library of Congress
`here <https://www.loc.gov/nls/services-and-resources/music-service-and-materials/>`_,
and will henceforth be referred to as BMTM.

The most important function, and the only one that is needed to translate music
into braille, is :func:`~music21.braille.translate.objectToBraille`. This function,
as well as the others, accepts keyword arguments that serve to modify the output.
If no keyword arguments are needed, then using the function is equivalent to
calling :meth:`~music21.base.Music21Object.show` on the music.

Keywords:

* **inPlace** (False): If False, then :meth:`~music21.stream.base.Stream.makeNotation` is called
  on all :class:`~music21.stream.Measure`, :class:`~music21.stream.Part`, and
  :class:`~music21.stream.PartStaff` instances. Copies of those objects are then
  used to transcribe the music. If True, the transcription is done "as is."
  This is useful for strict transcription because
  sometimes :meth:`~music21.stream.base.Stream.makeNotation`
  introduces some unwanted artifacts in the music. However, the music needs
  to be organized into measures for transcription to work.
* **debug** (False): If True, a braille-english representation of the music is returned. Useful
  for knowing how the music was interpreted by the braille transcriber.

The rest of the keywords are segment keywords. A segment is "a group of measures occupying
more than one braille line." Music is divided into segments to "present the music to
the reader in a meaningful manner and to give him convenient reference points to use in
memorization" (BMTM, 71). Some of these keywords are changed automatically in context.

* **cancelOutgoingKeySig** (True): If True, whenever a key signature change is
    encountered, the new signature should be preceded by the old one.
* **descendingChords** (True): If True, then chords are spelled around the highest note.
    If False, then chords are spelled around the lowest note. This keyword is
    overridden by any valid clefs present in the music.
* **dummyRestLength** (None) For a given positive integer n, adds n "dummy rests"
    near the beginning of a segment. Designed for test purposes, as the rests
    are used to demonstrate measure division at the end of braille lines.
* **maxLineLength** (40): The maximum amount of braille characters
    that should be present in a line of braille.
* **segmentBreaks** (None): A list consisting of (measure number, offset start)
    tuples indicating where the music should be broken into segments.

    .. warning::
        Not currently implemented

* **showClefSigns** (False): If True, then clef signs are displayed.
    Since braille does not use clefs or staves to represent music, they would
    instead be shown for referential or historical purposes.
* **showFirstMeasureNumber** (True): If True, then a measure number is shown
    following the heading (if applicable) and preceding the music.
* **showHand** (None): If set to "right" or "left", the corresponding
    hand sign is shown before the music. In keyboard music,
    the hand signs are shown automatically.
* **showHeading** (True): If True, then a braille heading is created above
    the initial segment. A heading consists
    of an initial :class:`~music21.key.KeySignature`, :class:`~music21.meter.TimeSignature`,
    :class:`~music21.tempo.TempoText`, and :class:`~music21.tempo.MetronomeMark`,
    or any subset thereof. The heading
    is centered above the music automatically.
* **showLongSlursAndTiesTogether** (None), **showShortSlursAndTiesTogether** (False):
    If False, then the slur on either side of the phrase is reduced by the amount
    that ties are present. If True, then slurs and ties are shown together
    (i.e. the note can have both a slur and a tie). If `showLongSlursAndTiesTogether`
    is `None` (default), its value is programmatically set to be the value of
    ``slurLongPhraseWithBrackets``, described next.
* **slurLongPhraseWithBrackets** (True): If True, then the slur of a
    long phrase (4+ consecutive notes) is brailled using the bracket slur.
    If False, the double slur is used instead.
* **suppressOctaveMarks** (False): If True, then all octave marks are suppressed.
    Designed for test purposes, as octave marks were not presented in BMTM until Chapter 7.
* **upperFirstInNoteFingering** (True): If True, then whenever
    there is a choice fingering (i.e. 5|4), the upper
    number is transcribed before the lower number. If False, the reverse is the case.
é    )ÚannotationsN)Úbase)Úexceptions21)Úmetadata)Ústream)ÚwordToBraille)Úalphabet)ÚsegmentFTé(   )ÚinPlaceÚdebugÚcancelOutgoingKeySigÚdescendingChordsÚdummyRestLengthÚmaxLineLengthÚsegmentBreaksÚshowClefSignsÚshowFirstMeasureNumberÚshowHandÚshowHeadingÚshowLongSlursAndTiesTogetherÚshowShortSlursAndTiesTogetherÚslurLongPhraseWithBracketsÚsuppressOctaveMarksÚupperFirstInNoteFingeringÚ
music21Objúbase.Music21Objectr   úbool | Nonec               ó  — t          | t          j        t          j        t          j        t          j        f¦  «        r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS t          | t          j        ¦  «        rt          d¦  «        ‚t          j        ¦   «         }| 	                    | ¦  «         t          |fi dd“d|“d|“d|“d|“d|“d|“d|“d	d“d
|
“dd“d|“d|“d|“d|“d|“ŽS )u±  
    Translates an arbitrary object to braille.

    >>> from music21.braille import translate
    >>> samplePart = converter.parse('tinynotation: 3/4 C4 D16 E F G# r4 e2.')
    >>> #_DOCS_SHOW samplePart.show()

        .. image:: images/objectToBraille.*
            :width: 700

    >>> print(translate.objectToBraille(samplePart))
    â €â €â €â €â €â €â €â ¼â ‰â ²â €â €â €â €â €â €â €
    â ¼â �â €â ¸â ¹â µâ ‹â ›â ©â “â §â €â �â �â „â £â …

    For normal users, you'll just call this, which starts a text editor:

    >>> #_DOCS_SHOW samplePart.show('braille')
    â €â €â €â €â €â €â €â ¼â ‰â ²â €â €â €â €â €â €â €
    â ¼â �â €â ¸â ¹â µâ ‹â ›â ©â “â §â €â �â �â „â £â …

    Other examples:

    >>> sampleNote = note.Note('C3')
    >>> print(translate.objectToBraille(sampleNote))
    â ¸â ¹

    >>> sampleDynamic = dynamics.Dynamic('fff')
    >>> print(translate.objectToBraille(sampleDynamic))
    â œâ ‹â ‹â ‹

    >>> sample_voice = stream.Voice([note.Note()])
    >>> sample_measure = stream.Measure([sample_voice])
    >>> print(translate.objectToBraille(sample_measure))
    â €â ¼â �â ²â €
    â ¼â šâ €â �â ¹

    >>> empty_measure = stream.Measure()
    >>> print(translate.objectToBraille(empty_measure))
    â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â ¼â ™â ²â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €â €
    â ¼â š

    Not currently supported: generic `stream.Stream` objects or `stream.Voice` objects:

    >>> sample_generic_stream = stream.Stream([note.Note()])
    >>> translate.objectToBraille(sample_generic_stream)
    Traceback (most recent call last):
    music21.braille.translate.BrailleTranslateException: Stream cannot be translated to Braille.
    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ú'Stream cannot be translated to Braille.TF)Ú
isinstancer   ÚOpusÚScoreÚPartÚMeasureÚstreamToBrailleÚStreamÚBrailleTranslateExceptionÚappendÚmeasureToBraille)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úmusic21Measures                     úŽ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/braille/translate.pyÚobjectToBrailler-   g   s7  € õF �*�vœ{­F¬L½&¼+ÅvÄ~ÐVÑWÔWð )"Ý˜zð !ð !ð !Ø'. wð!à%* Uð!ð 5IÐ4Hð!ð 1AÐ0@ð	!ð
 0?¨ð!ð .;¨]ð!ð .;¨]ð!ð .;¨]ð!ð 7MÐ6Lð!ð )1¨ð!ð ,7¨;ð!ð =YÐ<Xð!ð >[Ð=Zð!ð ;UÐ:Tð!ð 4GÐ3Fð!ð  :SÐ9Rð!!ð 	!õ$ 
�J¥¤Ñ	.Ô	.ð "Ý'Ð(QÑRÔRÐRåœÑ)Ô)ˆØ×Ò˜jÑ)Ô)Ð)Ý ð "ð "ð "Ø(,¨ð"à&+ eð"ð 6JÐ5Ið"ð 2BÐ1Að	"ð
 1@°ð"ð /<¨mð"ð /<¨mð"ð /<¨mð"ð 8=°uð"ð *2¨ð"ð -2¨Eð"ð >ZÐ=Yð"ð ?\Ð>[ð"ð <VÐ;Uð"ð 5HÐ4Gð"ð  ;TÐ:Sð!"ð 	"ó    Úmusic21Streamú9stream.Measure | stream.Part | stream.Score | stream.Opusc               ó¢  — t          | t          j        ¦  «        r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS t          | t          j        ¦  «        r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS t          | t          j        ¦  «        r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS t          | t          j        ¦  «        r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS |  
                    t          j        ¦  «        }t          |¦  «        dk    r;t          | fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“ŽS t          d¦  «        ‚)aÝ  
    Translates a :class:`~music21.stream.Measure`.
    :class:`~music21.stream.Part`,
    :class:`~music21.stream.Score`, or
    :class:`~music21.stream.Opus` to braille.

    Note: generic :class:`~music21.stream.Stream` instances are not supported.

    >>> s = stream.Stream(note.Note())
    >>> braille.translate.streamToBraille(s)
    Traceback (most recent call last):
    music21.braille.translate.BrailleTranslateException: Stream cannot be translated to Braille.
    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r    )r!   r   r$   ÚpartToBrailler%   r*   r#   ÚscoreToBrailler"   ÚopusToBrailleÚgetElementsByClassÚ	PartStaffÚlenr(   )r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚkeyboardPartss                     r,   r&   r&   Õ   s  € õ@ �-¥¤Ñ-Ô-ð KÝ˜]ð ð ð Ø$+ Gðà"' %ðð 2FÐ1Eðð .>Ð-=ð	ð
 -<¨Oðð +8¨-ðð +8¨-ðð +8¨-ðð 4JÐ3Iðð &. Xðð )4¨ðð :VÐ9Uðð ;XÐ:Wðð 8RÐ7Qðð 1DÐ0Cðð  7PÐ6Oð!ð 	õ$ 
�M¥6¤>Ñ	2Ô	2ð 8Ý ð "ð "ð "Ø(/¨ð"à&+ eð"ð 6JÐ5Ið"ð 2BÐ1Að	"ð
 1@°ð"ð /<¨mð"ð /<¨mð"ð /<¨mð"ð 8NÐ7Mð"ð *2¨ð"ð -8¨Kð"ð >ZÐ=Yð"ð ?\Ð>[ð"ð <VÐ;Uð"ð 5HÐ4Gð"ð  ;TÐ:Sð!"ð 	"õ$ 
�M¥6¤<Ñ	0Ô	0ð %Ý˜mð  ð  ð  Ø&- gð à$) Eð ð 4HÐ3Gð ð 0@Ð/?ð	 ð
 />¨oð ð -:¨Mð ð -:¨Mð ð -:¨Mð ð 6LÐ5Kð ð (0 xð ð +6¨+ð ð <XÐ;Wð ð =ZÐ<Yð ð :TÐ9Sð ð 3FÐ2Eð ð  9RÐ8Qð! ð 	 õ$ 
�M¥6¤;Ñ	/Ô	/ð Ý˜]ð ð ð Ø%, Wðà#( 5ðð 3GÐ2Fðð /?Ð.>ð	ð
 .=¨_ðð ,9¨=ðð ,9¨=ðð ,9¨=ðð 5KÐ4Jðð '/ hðð *5¨ðð ;WÐ:Vðð <YÐ;Xðð 9SÐ8Rðð 2EÐ1Dðð  8QÐ7Pð!ð 	ð, "×4Ò4µVÔ5EÑFÔF€MÝ
ˆ=ÑÔ˜QÒÐÝ˜mð  ð  ð  Ø&- gð à$) Eð ð 4HÐ3Gð ð 0@Ð/?ð	 ð
 />¨oð ð -:¨Mð ð -:¨Mð ð -:¨Mð ð 6LÐ5Kð ð (0 xð ð +6¨+ð ð <XÐ;Wð ð =ZÐ<Yð ð :TÐ9Sð ð 3FÐ2Eð ð  9RÐ8Qð! ð 	 õ$ $Ð$MÑ
NÔ
NÐNr.   c               ó*  ‡‡‡‡‡‡‡‡‡	‡
‡‡‡‡‡‡‡‡— g Š|                       t          j        ¦  «        D ]'}‰                     t	          |‰ ¬¦  «        ¦  «         Œ(dŠˆˆˆˆˆˆˆˆˆˆ	ˆ
ˆˆˆˆˆˆˆfd„}|                       t
          j        ¦  «        D ]â}t          |t
          j        ¦  «        rl‰�gt          t          j
        ‰|g¦  «        fi d‰“d‰“d‰“d‰“d‰“d	‰“d
‰“d‰“d‰	“d‰
“d‰“d‰“d‰“d‰“d‰“d‰“Ž}‰                     |¦  «         dŠŒ…|ŠŒˆ |¦   «          t          |fi d‰“d‰“d‰“d‰“d‰“d	‰“d
‰“d‰“d‰	“d‰
“d‰“d‰“d‰“d‰“d‰“d‰“Ž}‰                     |¦  «         Œã |¦   «          d                     ‰¦  «        S )zA
    Translates a :class:`~music21.stream.Score` to braille.
    )ÚreturnBrailleUnicodeNc                 ó´   •— ‰€d S t          ‰fi d‰“d‰“d‰“d‰“d‰“d‰“d‰“d‰	“d	‰
“d
‰“d‰“d‰“d‰“d‰“d‰“d‰“Ž} ‰                     | ¦  «         d Šd S )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r3   r)   )ÚbraillePrt2ÚallBrailleLinesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úunprocessed_partStaffr   s    €€€€€€€€€€€€€€€€€€r,   Ú+process_unmatched_part_staff_as_single_partzCscoreToBraille.<locals>.process_unmatched_part_staff_as_single_partx  s  ø€ à Ð(ØˆFÝ#Ð$9ð &ð &ð &Ø,3¨Gð&à*/¨%ð&ð :NÐ9Mð&ð 6FÐ5Eð	&ð
 5D°Oð&ð 3@°-ð&ð 3@°-ð&ð 3@°-ð&ð <RÐ;Qð&ð .6¨Xð&ð 1<°ð&ð B^ÐA]ð&ð C`ÐB_ð&ð @ZÐ?Yð&ð 9LÐ8Kð&ð  ?XÐ>Wð!&ˆð$ 	×Ò˜{Ñ+Ô+Ð+Ø $ÐÐÐr.   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ú
)r6   r   ÚMetadatar)   ÚmetadataToStringr   r$   r!   r7   ÚkeyboardPartsToBrailler#   r3   Újoin)Úmusic21Scorer   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úmusic21Metadatar@   ÚpÚkeyboard_partsÚbraillePartr>   r?   s    ````````````````     @@r,   r4   r4   \  se  øøøøøøøøøøøøøøøøøø€ ð, €OØ'×:Ò:½8Ô;LÑMÔMð bð bˆØ×ÒÕ/°ÐZ_ÐV_Ð`Ñ`Ô`ÑaÔaÐaÐaà37Ðð%ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %ð2 ×,Ò,­V¬[Ñ9Ô9ð /0ð /0ˆÝ�a�Ô)Ñ*Ô*ð .	0Ø$Ð0Ý!7Ý”LÐ"7¸Ð!;Ñ<Ô<ð"ð "ð "à#˜Gð"ð  ˜%ð"ð *>Ð)=ð	"ð
 &6Ð%5ð"ð %4 Oð"ð #0 -ð"ð #0 -ð"ð #0 -ð"ð ,BÐ+Að"ð &˜Xð"ð !, ð"ð 2NÐ1Mð"ð 3PÐ2Oð"ð 0JÐ/Ið"ð  )<Ð(;ð!"ð" /HÐ.Gð#"�ð&  ×&Ò& ~Ñ6Ô6Ð6Ø(,Ð%Ð%à()Ð%Øà7Ð7Ñ9Ô9Ð9Ý'¨ð *ð *ð *Ø07°ð*à.3¨eð*ð >RÐ=Qð*ð :JÐ9Ið	*ð
 9H¸ð*ð 7D°mð*ð 7D°mð*ð 7D°mð*ð @VÐ?Uð*ð 2:°ð*ð 5@°Kð*ð FbÐEað*ð GdÐFcð*ð D^ÐC]ð*ð =PÐ<Oð*ð  C\ÐB[ð!*ˆKð$ ×"Ò" ;Ñ/Ô/Ð/Ð/à/Ð/Ñ1Ô1Ð1à�9Š9�_Ñ%Ô%Ð%r.   rG   úmetadata.MetadataÚreturnÚstrc                óZ  — g }|                       dd¬¦  «        D ]ð\  }}|€Œ|dk    rŒ|                      |¦  «        }|sŒ'|                     d¦  «        rŒ=d                     t	          j        d|¦  «        ¦  «        }|                     ¦   «         › d	|› �}|r[g }|                     ¦   «         D ]$}	|                     t          |	¦  «        ¦  «         Œ%t          d                              |¦  «        }|                     |¦  «         Œñd
                     t          |¦  «        ¦  «        S )už  
    Convert a Metadata format to a format for BRF.

    >>> from music21.braille import translate
    >>> corelli = corpus.parse('monteverdi/madrigal.3.1.rntxt')
    >>> mdObject = corelli.getElementsByClass(metadata.Metadata).first()
    >>> mdObject.__class__
    <class 'music21.metadata.Metadata'>

    The default is very close to ascii.

    >>> print(translate.metadataToString(mdObject))
    Alternative Title: 3.1
    Composer: Claudio Monteverdi
    Title: La Giovinetta Pianta

    And in Braille Unicode.

    >>> unicodeVersion = translate.metadataToString(mdObject, returnBrailleUnicode=True)
    >>> print(unicodeVersion)
    â  â �â ‡â žâ ‘â —â �â �â žâ Šâ §â ‘â €â  â žâ Šâ žâ ‡â ‘â ’â €â ¼â ‰â ²â �
    â  â ‰â •â �â �â •â Žâ ‘â —â ’â €â  â ‰â ‡â �â ¥â ™â Šâ •â €â  â �â •â �â žâ ‘â §â ‘â —â ™â Š
    â  â žâ Šâ žâ ‡â ‘â ’â €â  â ‡â �â €â  â ›â Šâ •â §â Šâ �â ‘â žâ žâ �â €â  â �â Šâ �â �â žâ �

    Note the difference between the first and then translating back to ASCII Braille:

    >>> print(braille.basic.brailleUnicodeToBrailleAscii(unicodeVersion))
    ,ALTERNATIVE ,TITLE3 #C4A
    ,COMPOSER3 ,CLAUDIO ,MONTEVERDI
    ,TITLE3 ,LA ,GIOVINETTA ,PIANTA
    TF)ÚreturnPrimitivesÚreturnSortedNÚsoftwarezm21FileInfo:ú z([A-Z]*[a-z]+)z: rA   )ÚallÚuniqueNameToNamespaceNameÚ
startswithrE   ÚreÚfindallÚtitleÚsplitr)   r   r	   Úsorted)
rG   r;   r>   Ú
uniqueNameÚvalueÚnamespaceNameÚnÚ	outStringÚoutTempÚwords
             r,   rC   rC   Ç  sC  € ð@ €OØ,×0Ò0À$ÐUZÐ0Ñ[Ô[ð *ð *Ñˆ
�EØˆ=àà˜Ò#Ð#àà"1×"KÒ"KÈJÑ"WÔ"WˆØð 	àà×#Ò# NÑ3Ô3ð 	àà�HŠH•R”ZÐ 1°:Ñ>Ô>Ñ?Ô?ˆØ—w’w‘y”yÐ+Ð+ EÐ+Ð+ˆ	Øð 	4ØˆGØ!ŸšÑ)Ô)ð 4ð 4�Ø—’�}¨TÑ2Ô2Ñ3Ô3Ð3Ð3Ý  œ×*Ò*¨7Ñ3Ô3ˆIØ×Ò˜yÑ)Ô)Ð)Ð)Ø�9Š9•V˜OÑ,Ô,Ñ-Ô-Ð-r.   c          	     ó  — g }|                       t          j        ¦  «        D ]P}|                     t	          |fi d|“d|“d|“d|“d|“d|“d|“d|“d	|	“d
|
“d|“d|“d|“d|“d|“d|“Ž¦  «         ŒQd                     |¦  «        S )zA
    Translates an :class:`~music21.stream.Opus` to braille.
    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   z

)r6   r   r#   r)   r4   rE   )Úmusic21Opusr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r>   Úscores                      r,   r5   r5     s8  € ð, €OØ×/Ò/µ´Ñ=Ô=ð 
ð 
ˆØ×ÒÝ˜5ð ð ð Ø#* 7ðà!& ðð 1EÐ0Dðð -=Ð,<ð	ð
 ,;¨?ðð *7¨ðð *7¨ðð *7¨ðð 3IÐ2Hðð %- Hðð (3 {ðð 9UÐ8Tðð :WÐ9Vðð 7QÐ6Pðð 0CÐ/Bðð  6OÐ5Nð!ñ	
ô 	
ð 	
ð 	
ð( �;Š;�Ñ'Ô'Ð'r.   c               óü   — | }|s|                       d¬¦  «        }t          j        ¦   «         }|                     |¦  «         t	          |fi dd“d|“d|“d|“d|“d	|“d
|“d|“d|	“d|
“d|“d|“d|“d|“d|“d|“ŽS )uh  
    Translates a :class:`~music21.stream.Measure` to braille.

    >>> p = stream.Part()
    >>> p.append(note.Note('C4', type='whole'))
    >>> p.makeMeasures(inPlace=True)
    >>> p.show('t')
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.meter.TimeSignature 4/4>
        {0.0} <music21.note.Note C>
        {4.0} <music21.bar.Barline type=final>
    >>> print(braille.translate.objectToBraille(p))
    â €â €â ¼â ™â ²â €â €
    â ¼â �â €â �â ½â £â …
    >>> print(braille.translate.measureToBraille(p.measure(1)))
    â ¼â ™â ²â €â �â ½â £â …

    F©ÚcautionaryNotImmediateRepeatr   Tr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )ÚmakeNotationr   r$   r)   r3   )r+   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚmeasureToTranscribeÚmusic21Parts                      r,   r*   r*   4  s0  € ðL )ÐØð ^Ø,×9Ò9ÐW\Ð9Ñ]Ô]ÐÝ”+‘-”-€KØ×ÒÐ*Ñ+Ô+Ð+Ý˜ð ð ð Ø!% ðà$˜uðð /CÐ.Bðð +;Ð*:ð	ð
 *9¨ðð (5 }ðð (5 }ðð (5 }ðð 1GÐ0Fðð #+ (ðð &1 [ðð 7SÐ6Rðð 8UÐ7Tðð 5OÐ4Nðð .AÐ-@ðð  4MÐ3Lð!ð r.   c               óš  — | }|s|                       d¬¦  «        }t          j        ||||||||	|
||||||¬¦  «        }g }|D ]P}|                     ¦   «         }|s|                     |¦  «         Œ.|                     t          |¦  «        ¦  «         ŒQddlm} t          |¦  «        D ]}||= Œd 	                    d„ |D ¦   «         ¦  «        S )zÓ
    Translates a :class:`~music21.stream.Part` to braille.

    This is one of two (w/ keyboardPartsToBraille) main routines.  Runs segment.findSegments
    and then for each segment runs transcribe on it.
    Frf   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )Ú
beamStatusrA   c                ó,   — g | ]}t          |¦  «        ‘ŒS © ©rM   ©Ú.0Úbts     r,   ú
<listcomp>z!partToBraille.<locals>.<listcomp>«  ó   € Ð7Ð7Ð7 "•c˜"‘g”gÐ7Ð7Ð7r.   )
rh   r
   ÚfindSegmentsÚ
transcriber)   rM   Úmusic21.braille.basicrl   ÚlistrE   )rj   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚpartToTranscribeÚallSegmentsÚallBrailleTextÚbrailleSegmentÚtranscriptionrl   Úxs                           r,   r3   r3   r  s'  € ð2 #ÐØð XØ&×3Ò3ÐQVÐ3ÑWÔWÐÝÔ&Ð'7Ø<PØ8HØ7FØ5BØ5BØ5BØ>TØ08Ø3>ØD`ØEbØB\Ø;NØAZð)ñ )ô )€Kð  €NØ%ð 7ð 7ˆØ&×1Ò1Ñ3Ô3ˆàð 	7Ø×!Ò! -Ñ0Ô0Ð0Ð0à×!Ò!¥# nÑ"5Ô"5Ñ6Ô6Ð6Ð6à0Ð0Ð0Ð0Ð0Ð0Ý�*ÑÔð ð ˆØ�qˆMˆMà�9Š9Ð7Ð7¨Ð7Ñ7Ô7Ñ8Ô8Ð8r.   c               óú  — |                       ddg¦  «        }t          |¦  «        dk    rt          d¦  «        ‚|d         }|d         }|}|s|                     d¬¦  «        }|}|s|                     d¬¦  «        }t	          j        |fd	|||||||	|
||||||d
œŽ}t	          j        |fd|||||||	|
||||||d
œŽ}g }t          ||¦  «        D ]�\  }}t	          j        |¬¦  «        }|D ]}||         ||<   Œ|D ]}||         ||<   Œ|                     ¦   «          |s| 	                    |j
        ¦  «         Œk| 	                    t          |¦  «        ¦  «         ŒŽd                     d„ |D ¦   «         ¦  «        S )zè
    Translates a Score object containing two :class:`~music21.stream.Part` instances to braille,
    an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    r$   r7   r2   z/Can only translate two keyboard parts at a timer   é   Frf   Úright)ÚsetHandr   r   r   r   r   r   r   r   r   r   r   r   r   r   Úleft)Ú
lineLengthrA   c                ó,   — g | ]}t          |¦  «        ‘ŒS rn   ro   rp   s     r,   rs   z*keyboardPartsToBraille.<locals>.<listcomp>  rt   r.   )r6   r8   r(   rh   r
   ru   ÚzipÚBrailleGrandSegmentrv   r)   ÚbrailleTextrM   rE   )ÚkeyboardScorer   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚpartsÚ
staffUpperÚ
staffLowerÚupperPartToTranscribeÚlowerPartToTranscribeÚ
rhSegmentsÚ
lhSegmentsr{   Ú	rhSegmentÚ	lhSegmentÚbgÚrhGroupingKeyÚlhGroupingKeys                                 r,   rD   rD   ®  s  € ð0 ×,Ò,¨f°kÐ-BÑCÔC€EÝ
ˆ5�z„z�Q‚€Ý'Ð(YÑZÔZÐZØ�q”€JØ�q”€JØ&ÐØð \Ø *× 7Ò 7ÐUZÐ 7Ñ [Ô [ÐØ&ÐØð \Ø *× 7Ò 7ÐUZÐ 7Ñ [Ô [ÐÝÔ%Ð&;ð (Ø.5Ø;OØ7GØ6EØ4AØ4AØ4AØ=SØ/7Ø2=ØC_ØDaØA[Ø:MØ@Yð(ð (ð (€Jõ" Ô%Ð&;ð (Ø.4Ø;OØ7GØ6EØ4AØ4AØ4AØ=SØ/7Ø2=ØC_ØDaØA[Ø:MØ@Yð(ð (ð (€Jð$ €NÝ"% j°*Ñ"=Ô"=ð +ð +Ñˆ�IÝÔ(°MÐBÑBÔBˆØ&ð 	9ð 	9ˆMð !*¨-Ô 8ˆBˆ}ÑÐà&ð 	9ð 	9ˆMØ )¨-Ô 8ˆBˆ}ÑÐà
�Š‰ŒˆØð 	+Ø×!Ò! "¤.Ñ1Ô1Ð1Ð1à×!Ò!¥# b¡'¤'Ñ*Ô*Ð*Ð*à�9Š9Ð7Ð7¨Ð7Ñ7Ô7Ñ8Ô8Ð8r.   c                  ó   — e Zd ZdS )r(   N)Ú__name__Ú
__module__Ú__qualname__rn   r.   r,   r(   r(     s   € € € € € Ø€Dr.   r(   c                  ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚTestc                óÆ   — ddl m} |                     d¦  «        }t          |d¬¦  «        }|                      d„ |                     ¦   «         D ¦   «         g d¢¦  «         d S )Nr   ©Ú	converterú-tinyNotation: 2/4 c4 d e f8 g a2 B2 c4. d8 e2é   ©r   c                ó,   — g | ]}t          |¦  «        ‘ŒS rn   ©r8   ©rq   Úlines     r,   rs   z8Test.testTranslateRespectsLineLength.<locals>.<listcomp>  ó   € Ð?Ð?Ð?¨�#˜d™)œ)Ð?Ð?Ð?r.   )r    r    r    ©Úmusic21rž   Úparser-   ÚassertEqualÚ
splitlines©Úselfrž   Úsr~   s       r,   ÚtestTranslateRespectsLineLengthz$Test.testTranslateRespectsLineLength  so   € Ø%Ð%Ð%Ð%Ð%Ð%Ø�OŠOÐKÑLÔLˆÝ˜A¨RÐ0Ñ0Ô0ˆØ×ÒÐ?Ð?°·²±´Ð?Ñ?Ô?ÀÀÀÑNÔNÐNÐNÐNr.   c                óÆ   — ddl m} |                     d¦  «        }t          |d¬¦  «        }|                      d„ |                     ¦   «         D ¦   «         g d¢¦  «         dS )	zl
        Tests loosening the constraint on trailing spaces when there is
        no other solution.
        r   r�   rŸ   é
   r¡   c                ó,   — g | ]}t          |¦  «        ‘ŒS rn   r£   r¤   s     r,   rs   z8Test.testSplitNoteGroupingLineLength.<locals>.<listcomp>$  r¦   r.   )r±   r±   é   r±   Nr§   r¬   s       r,   ÚtestSplitNoteGroupingLineLengthz$Test.testSplitNoteGroupingLineLength  sq   € ð
 	&Ð%Ð%Ð%Ð%Ð%Ø�OŠOÐKÑLÔLˆÝ˜A¨RÐ0Ñ0Ô0ˆØ×ÒÐ?Ð?°·²±´Ð?Ñ?Ô?ÀÀÀÑQÔQÐQÐQÐQr.   c                ó„   — ddl m} |                     d¦  «        }|                     d¦  «        }t	          |¦  «        }d S )Nr   )ÚcorpusÚbeachr€   )r¨   r¶   r©   Úmeasurer-   )r­   r¶   r®   Úfull_score_measure_1Ú_s        r,   ÚtestFullScoreWithPianozTest.testFullScoreWithPiano&  sG   € Ø"Ð"Ð"Ð"Ð"Ð"Ø�LŠL˜Ñ!Ô!ˆØ Ÿyšy¨™|œ|ÐÝÐ0Ñ1Ô1ˆˆˆr.   N)r—   r˜   r™   r¯   r´   r»   rn   r.   r,   r›   r›     sG   € € € € € ðOð Oð OðRð Rð Rð2ð 2ð 2ð 2ð 2r.   r›   Ú__main__)r   r   r   r   )r/   r0   r   r   )r   r   )F)rG   rK   rL   rM   )Ú__doc__Ú
__future__r   rV   Úunittestr¨   r   r   r   r   rw   r   Úmusic21.braille.lookupr	   Úmusic21.brailler
   r-   r&   r4   rC   r5   r*   r3   rD   Ú
_DOC_ORDERÚMusic21Exceptionr(   ÚTestCaser›   r—   ÚmainTestrn   r.   r,   ú<module>rÆ      sÀ  ððMð Mð\ #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€à Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à /Ð /Ð /Ð /Ð /Ð /Ø +Ð +Ð +Ð +Ð +Ð +Ø #Ð #Ð #Ð #Ð #Ð #ð "ØØ)-Ø%)Ø$(Ø"$Ø"&Ø"'Ø+/Ø!Ø $Ø>BØ27Ø/3Ø(-Ø.2ð#l"ð l"ð l"ð l"ð l"ð l"ð` "ØØ)-Ø%)Ø$(Ø"$Ø"&Ø"'Ø+/Ø!Ø $Ø>BØ27Ø/3Ø(-Ø.2ð#DOð DOð DOð DOð DOð DOðR !ØØ(,Ø$(Ø#'Ø!#Ø!%Ø!&Ø*.Ø Ø#Ø=AØ16Ø.2Ø',Ø-1ð#h&ð h&ð h&ð h&ð h&ð h&ðV;.ð ;.ð ;.ð ;.ð ;.ð@  ØØ'+Ø#'Ø"&Ø "Ø $Ø %Ø)-ØØ"Ø<@Ø05Ø-1Ø&+Ø,0ð#,(ð ,(ð ,(ð ,(ð ,(ð ,(ðb #Ø Ø*.Ø&*Ø%)Ø#%Ø#'Ø#(Ø,1Ø"Ø!&Ø?CØ38Ø04Ø).Ø/3ð#<ð <ð <ð <ð <ð <ð@  ØØ'+Ø#'Ø"&Ø "Ø $Ø %Ø)-ØØ"Ø<@Ø05Ø-1Ø&+Ø,0ð#99ð 99ð 99ð 99ð 99ð 99ð| $)Ø!&Ø04Ø,0Ø+/Ø)+Ø)-Ø).Ø26Ø$(Ø'+ØEIØ9>Ø6:Ø/4Ø59ð#W9ð W9ð W9ð W9ð W9ð W9ðt Ð€
ð
	ð 	ð 	ð 	ð 	 Ô =ñ 	ô 	ð 	ð2ð 2ð 2ð 2ð 2ˆ8Ôñ 2ô 2ð 2ð2 ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr.   