
    rh                    0   S r SSKJr  SSKJr  SSKrSSKrSSKrSSKr	SSK
r
SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  \	R$                  (       a  SS
KJr  \R*                  " S5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S  S!\5      r! " S" S#\5      r" " S$ S%\5      r# " S& S'\5      r$ " S( S)\5      r% " S* S+\5      r& " S, S-\5      r' " S. S/\5      r( " S0 S1\5      r) " S2 S3\5      r* " S4 S5\5      r+ " S6 S7\
RX                  5      r- " S8 S9\
RX                  5      r.\/S::X  a  SSKr\R`                  " \-5        gg);z
SubConverters parse or display a single format.

Each subConverter should inherit from the base SubConverter object and have at least a
parseData method that sets self.stream.
    )annotations)IOBaseN)common)defaults)environment)SubConverterExceptionstream)Iterablezconverter.subConvertersc                     \ rS rSr% SrSrS\S'   SrS\S'   SrS	\S
'   Sr	S	\S'   Sr
S	\S'   SrS	\S'   0 rS\S'   SrS\S'   SrS\S'   SrS\S'   S'S jrS(S)S jjr S(   S*S jjrS rS r\" \\SS9rS+S jr    S,     S-S jjr  S.   S/S  jjrS0S1S! jjrS0S2S" jjr  S.       S3S# jjr      S4S$ jr S0     S5S% jjrS&rg)6SubConverter.   a  
Class wrapper for parsing data or outputting data.

All other Converter types should inherit from this and
have ways of dealing with various data formats.

Attributes that should be set::

    readBinary = True or False (default False)
    registerFormats = tuple of formats that can be handled; eg: ('musicxml',)
    registerShowFormats = tuple of format calls that can be handled in .show() and .write()
    registerInputExtensions = tuple of input extensions that should be handled in converter
    registerOutputExtensions = tuple of output extensions that can be written. Order matters:
        the first will be used in calls to .write()
    canBePickled = True or False (default True; does not do anything yet)
    codecWrite = True or False (default False) if encodings need to be used to write
    stringEncoding = string (default 'utf-8'). If codecWrite is True, this specifies what
        encoding to use


Fbool
readBinaryTcanBePickled ztuple[str, ...]registerFormatsregisterShowFormatsregisterInputExtensionsregisterOutputExtensionszdict[str, str]!registerOutputSubformatExtensionsNzstr | pathlib.Path | None	launchKey
codecWriteutf-8strstringEncodingc                D    [         R                  " 5       U l        Xl        g N)r
   Score_streamkeywordsselfr!   s     Y/home/james-whalen/.local/lib/python3.13/site-packages/music21/converter/subConverters.py__init__SubConverter.__init__P   s    =C\\^*2    c                    [         e)z
Called when a string (or binary) data is encountered.

This method MUST be implemented to do anything in parsing.

Return self.stream in the end
NotImplementedError)r#   
dataStringnumbers      r$   	parseDataSubConverter.parseDataU   s
     "!r'   c                T   U R                   SL a5  SSKn[        XR                  5       S9 nUR	                  5       nSSS5        O%[        US5       nUR	                  5       nSSS5        U R                  WU5        U R                  $ ! , (       d  f       N,= f! , (       d  f       N== f)z
Called when a file is encountered. If all that needs to be done is
loading the file and putting the data into parseData then there is no need
to implement this method.  Just set self.readBinary to True | False.
Fr   Nencodingrb)r   localeopengetpreferredencodingreadr-   r
   )r#   filePathr,   r!   r3   f
dataStreams          r$   	parseFileSubConverter.parseFile`   s     ??e#h)D)D)FG1VVX
 HG h%VVX
 & 	z6*{{ HG &%s   BB
B
B'c                    U R                   $ r   r    r#   s    r$   
_getStreamSubConverter._getStreamv   s    ||r'   c                    Xl         g r   r=   )r#   	newStreams     r$   
_setStreamSubConverter._setStreamy   s     r'   zi
        Returns or sets the stream in the converter.  Must be defined for subConverter to work.
        )docc                    g)z
return bool on whether the *system* is
equipped to show in this format.

Default True. Might be False if, say
a Lilypond converter is used and Lilypond
is not installed.
Tr   r"   s     r$   checkShowAbilitySubConverter.checkShowAbility   s     r'   c                b   Uc!  U R                   (       a  U R                   S   nOUc  [        S5      eUcZ  Ub
  [        U   nOMU R                  b  U R                  n[        U   nO*[        R	                  U5      n[        R                  U5      n[        R                  " 5       nSnUcZ  US:X  a  S[        U5      4nSnOUS:X  a$  U(       a  S	U[        U5      4nOS	[        U5      4nO[        S
U S3S-   SU< S3-   5      eUS;   a#  U(       a  XC[        U5      4nO\U[        U5      4nONUS:X  a:  U(       a  S	S[        U5      U[        U5      4nO'S	S[        U5      [        U5      4nO[        SU 35      e [        R                  " USUS9  g! [         a  n	[        S5      U	eSn	A	ff = f)a  
Opens the appropriate viewer for the file generated by .write()

app is the path to an application to launch.  Specify it and/or a launchKey.
launchKey is the specific key in .music21rc (such as graphicsPath), etc.
to search for the application.  If it's not specified then there might be
a default one for the converter in self.launchKey.  If it can't find it
there then environLocal.formatToApp(fmt) will be used.

Not needed for formats for which .show() just prints to the console.
Nr   zBlaunch: fmt can only be None if there is a registered show format.FwinstartTdarwinr4   z0Cannot find a valid application path for format z. z,Specify this in your Environment by calling zenvironment.set(z, '/path/to/application'))rJ   nixz-azCannot launch files on )checkshellzBMost issues with show() can be resolved by calling configure.run())r   
ValueErrorenvironLocalr   formatToKeyformatToAppr   getPlatformr   r   
subprocessrunFileNotFoundError)
r#   r7   fmtoptionsappr   platformrO   cmdes
             r$   launchSubConverter.launch   s   " ;433**1-C[abb;$"9-+ NN	"9-(44S9	"..s3 **,;5  H.X%!7CM:C!3x=1C+Fse2NDE(5NOP 
 'S]3CM*!tSXwHFtSXs8}='*A((LMM	NN3e59  	'T	s   <F 
F.F))F.c                N    U R                   " X4SU0UD6nU R                  XbUS9  g)z
Write the data, then show the generated data, using `.launch()` or printing
to a console.

Some simple formats that do not need launching, may skip .launch() and
simply return the output.

subformatsrX   rZ   Nwriter^   r#   objrX   rZ   ra   r!   returnedFilePaths          r$   showSubConverter.show   s.      ::cR:RR$37r'   c                    U R                   nU(       d  [        S5      eUS   nU R                  (       a6  U(       a/  SR                  U5      nX@R                  ;   a  U R                  U   nSU-   $ )z
Given a default format or subformats, give the file extension it should have:

>>> c = converter.subConverters.ConverterMidi()
>>> c.getExtensionForSubformats()
'.mid'
zRThis subConverter cannot show or write: no output extensions are registered for itr   .)r   r   r   join)r#   ra   
extensionsextjoinedSubformatss        r$   getExtensionForSubformats&SubConverter.getExtensionForSubformats   sr     22
'?@ @ m11j"xx
3#I#II<<=MNSyr'   c                P    U R                  U5      n[        R                  USS9nU$ )ac  
Return a temporary file with an extension appropriate for the format.

>>> c = corpus.parse('bwv66.6')
>>> lpConverter = converter.subConverters.ConverterLilypond()
>>> tf = str(lpConverter.getTemporaryFile(subformats=['png']))
>>> tf.endswith('.png')
True
>>> import os  #_DOCS_HIDE
>>> os.remove(tf)  #_DOCS_HIDE

* Changed in v6: returns pathlib.Path
TreturnPathlib)rp   rQ   getTempFile)r#   ra   rn   fps       r$   getTemporaryFileSubConverter.getTemporaryFile   s.     ,,Z8%%c%>	r'   c                B    [        U5      nU R                  " X640 UD6nU$ )zO
Calls .writeDataStream on the repr of obj, and returns the fp returned by it.
)reprwriteDataStreamr#   rf   rX   rv   ra   r!   dataStrs          r$   rd   SubConverter.write  s'     s)!!"::	r'   c                   Uc  U R                  5       nU R                  SL a  SnOSnU R                  SL a'  [        U[        5      (       a   UR                  S5      n[        U[        [        R                  45      (       aY  [        R                  " USS9n[        UUU R                  (       a  U R                  OSS9 nUR!                  U5        SSS5        U$ UR!                  U5        UR                  5         [        R                  " S	5      $ ! [         a/    SU l        [        U[        5      (       a  UR                  5          Nf = f! , (       d  f       U$ = f)
zl
Writes the data stream to `fp` or to a temporary file and returns the
Path object of the filename written.
NFwwbr   Trs   moder1    )rw   r   r   
isinstancebytesdecodeUnicodeDecodeErrorr   closer   pathlibPathr   	cleanpathr4   r   rd   )r#   rv   r}   r!   
writeFlagsr8   s         r$   r{   SubConverter.writeDataStream  s$    :&&(B??e#JJ??e#
7E(B(B!..1 b3-..!!"D9Bb%6:oot224  	
 I HHWHHJ<<##' & "&b&))HHJ 
 Is   D  E6EE
Ec                   U R                   " U4X#S.UD6nU R                  SL a  SnOSn[        UUU R                  (       a  U R                  OSS9 nUR                  5       nSSS5        UR                  SS9  W$ ! , (       d  f       N= f)	zr
Write the object out in the given format and then read it back in
and return the object (str or bytes) returned.
)rX   ra   Frr2   Nr   T)
missing_ok)rd   r   r4   r   r   r6   unlink)	r#   rf   rX   ra   r!   rv   	readFlagsr8   outs	            r$   toDataSubConverter.toDataC  s     ZZHHxH??e#II" 26//4..t &&(C	
 			T	"
 s   A<<
B
)r    r   r!   )returnNoner   )r,   
int | Noner7   str | pathlib.Pathr,   r   )r   r   )Nr   NN)r7   pathlib.PathrY   r   rZ   
str | NoneNr   )rX   r   r   r   )r   )ra   Iterable[str]r   r   )ra   r   r   r   )rf   zmusic21.base.Music21ObjectrX   r   rv   "str | pathlib.Path | IOBase | Nonera   r   )rv   r   r}   str | bytesr   r   )rX   r   ra   r   r   r   ) __name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r   r   r   r   r   r   r   r%   r-   r:   r?   rC   propertyr
   rG   r^   rh   rp   rw   rd   r{   r   __static_attributes__r   r'   r$   r   r   .   s   * JL$')O_)+--/1_102o28:%~:'+I$+J!NC!3
" &*,",! j* 3 F	  #H%H H 	H\ 8 8 
8$** 26*,	- / (	&$8&$!*&$ (4&$X %'	  "	 
 r'   r   c                  2    \ rS rSrSrSrSrSS0rS	S jrSr	g)
ConverterIPythoni\  z
Meta-subConverter for displaying image data in a Notebook
using either png (via MuseScore or LilyPond) or directly via
Vexflow/music21j, or MIDI using music21j.
)ipythonjupyterr   lilypondlyNc                N   SSK Jn  SSKJn  U(       a  US   nUSS n	OSn/ n	U	(       d  S/n	UR	                  U5      n
US;   a  UR
                  " U4U
UU	S	.UD6  gUS
:X  aD  [        R                  (       a  [        U
[        5      (       d   eUR                  " U4U
UU	S	.UD6  gg)a  
show a specialized for Jupyter Notebook using the appropriate subformat.

For MusicXML runs it through MuseScore and returns the PNG data.
(use multipageWidget to get an experimental interactive page display).

For MIDI: loads a music21j-powered MIDI player in to the Notebook.
r   )	Converter)
converters   Nmusicxmlpng)r   xmlr   lily)subConverterrX   ra   midi)music21.converterr   music21.ipython21r   getSubConverterFromFormatshowImageThroughMuseScoretTYPE_CHECKINGr   ConverterMididisplayMusic21jMIDI)r#   rf   rX   rZ   ra   r!   r   ip21_convertershelperFormathelperSubformatshelperSubConverters              r$   rh   ConverterIPython.showf  s     	0C%a=L)!"~%L! %w&@@NBB55/ +	
  V#!"4mDDDD/// +	
  $r'   r   )
r   r   r   r   r   r   r   r   rh   r   r   r'   r$   r   r   \  s$    
 -O!)3T(:%*r'   r   c                  V    \ rS rSrSrSrSrSSSS.rS	r  SSS. SS jjjr	SS jr
Srg
)ConverterLilypondi  z
Convert to Lilypond and from there usually to png, pdf, or svg.

Note: that the proper format for displaying Lilypond in Jupyter
notebook in v9 is ipython.lily.png and not lily.ipython.png
)r   r   )r   r   pdfsvgr   r   r   )r   r   r   TNr   F)coloredVariantsc               *   SSK Jn  UR                  R                  5       nXXl        UR                  U5        SU;   a  UR                  U5      n	U	$ SU;   a  UR                  U5      n	U	$ SU;   a  UR                  U5      n	U	$ UR                  SUS9n	U	$ )Nr   )r   r   r   r   z.ly)rn   rv   )
music21r   	translateLilypondConverterr   loadFromMusic21Object	createPDF	createPNG	createSVGwriteLyFile)
r#   rf   rX   rv   ra   r   r!   r   convconvertedFilePaths
             r$   rd   ConverterLilypond.write  s     	!~~//1.""3'J $r 2 !  j  $r 2
 ! 	 j  $r 2 !  !% 0 0Ur 0 B  r'   c                    U(       d  S/nU R                   " X4SU0UD6nUb  U(       a  US   nOSn[        R                  U5      nU R                  XgX8S9  g)z
Call .write (write out the lilypond (.ly) file; convert to .png/.pdf, etc.)
then launch the appropriate viewer for .png/.pdf (graphicsPath) or .svg
(vectorPath)
r   ra   Nr   )rX   rZ   r   )rd   rQ   rR   r^   )	r#   rf   rX   rZ   ra   r!   rg   	outFormatr   s	            r$   rh   ConverterLilypond.show  s`     J::cR:RR!j"1II !,,Y7	$Rr'   r   )r   r   )r   r   r   r   r   r   r   r   r   rd   rh   r   r   r'   r$   r   r     sS     +O:050502)4% J
 	! ',!  $!.Sr'   r   c                  J   ^  \ rS rSrSrSrSr  SU 4S jjr  SS jrSr	U =r
$ )	ConverterBraillei  brailletxtTr   c                   > [         R                  " 5       (       d  [        TU ]  " X4S US.UD6  g SSKJn  UR                  R                  U5      n[        U5        g )N)rZ   ra   r   r   )	r   runningInNotebooksuperrh   r   r   r   objectToBrailleprint)	r#   rf   rX   rZ   ra   r!   r   r}   	__class__s	           r$   rh   ConverterBraille.show  sL     ''))GLOt
OhO'''77<G'Nr'   c                    SSK Jn  UR                  R                  " U40 UD6nSU;   a  UR                  R                  U5      nU R                  X75      nU$ )Nr   r   ascii)r   r   r   r   basicbrailleUnicodeToBrailleAsciir{   )r#   rf   rX   rv   ra   r!   r   r}   s           r$   rd   ConverterBraille.write  sS     	$##33CD8Dj mm@@IG!!".	r'   r   )r   r   r   r   r   r   r   rh   rd   r   __classcell__r   s   @r$   r   r     s2    "O'J &  r'   r   c                  8    \ rS rSrSrSr  S	SS. S
S jjjrSrg)ConverterVexflowi  )vexflow)htmlNr   F)localc               V    SSK Jn  UR                  USUS9nU R                  X85      nU$ )Nr   )
toMusic21jr   )r   r   )music21.vexflowr   
fromObjectr{   )	r#   rf   rX   rv   ra   r   r!   r   r}   s	            r$   rd   ConverterVexflow.write  s3     	:$$SvU$C!!".	r'   r   )r   r   )r   r   r   r   r   r   rd   r   r   r'   r$   r   r     s3    "O(
 	 "  r'   r   c                  4    \ rS rSrSrSrSrS	S jrS	S jrSr	g)
ConverterTexti  z
standard text presentation has line breaks, is printed.

Two keyword options are allowed: addEndTimes=Boolean and useMixedNumerals=Boolean
)textr   r   r   Nr   c                L    UR                   " S0 UD6nU R                  X65        U$ r   )	_reprTextr{   r|   s          r$   rd   ConverterText.write  s&    --+(+R)	r'   c                :    [        UR                  " S0 UD65        g r   )r   r   r#   rf   rX   rZ   ra   r!   s         r$   rh   ConverterText.show  s    cmm'h'(r'   r   
r   r   r   r   r   r   r   rd   rh   r   r   r'   r$   r   r     s     +O'
)r'   r   c                  4    \ rS rSrSrSrSrS	S jrS	S jrSr	g)
ConverterTextLinei  a"  
a text line compacts the complete recursive representation into a
single line of text; most for debugging. returned, not printed

>>> s = corpus.parse('bwv66.6')
>>> s.measures(1, 4).show('textline')
"{0.0} <music21.stream.Part Soprano> / {0.0} <music21.instrument.Instrument '... 1'>..."
)textliner   Nr   c                H    UR                  5       nU R                  X65        U$ r   )_reprTextLiner{   r|   s          r$   rd   ConverterTextLine.write!  s#    ##%R)	r'   c                "    UR                  5       $ r   )r  r   s         r$   rh   ConverterTextLine.show&  s      ""r'   r   r  r   r'   r$   r  r    s     $O'
#r'   r  c                  \    \ rS rSrSrSrSrSr SSS.   SS	 jjjrS
 r	SS jr
SS jrSrg)ConverterVolpianoi*  a  
Reads or writes volpiano (Chant encoding).

Normally, just use 'converter' and .show()/.write()

>>> p = converter.parse('volpiano: 1---c-d-ef----4')
>>> p.show('text')
{0.0} <music21.stream.Measure 0 offset=0.0>
    {0.0} <music21.clef.TrebleClef>
    {0.0} <music21.note.Note C>
    {1.0} <music21.note.Note D>
    {2.0} <music21.note.Note E>
    {3.0} <music21.note.Note F>
    {4.0} <music21.volpiano.Neume <music21.note.Note E><music21.note.Note F>>
    {4.0} <music21.bar.Barline type=double>
>>> p.show('volpiano')
1---c-d-ef----4
volpiano)r  vp)r   r  NFbreaksToLayoutc               8    SSK Jn  UR                  XS9U l        g )Nr   r  r  )r   r  toPartr
   )r#   r+   r,   r  r!   r  s         r$   r-   ConverterVolpiano.parseDataA  s     	%oojoPr'   c                    SSK Jn  UR                  (       a  UnO&[        R                  " 5       nUR                  U5        UR                  U5      $ )z.
Get the raw data, for storing as a variable.
r   r  )r   r  isStreamr
   Streamappend
fromStream)r#   rf   r!   r  ss        r$   
getDataStrConverterVolpiano.getDataStrL  s:     	%<<AAHHSM""1%%r'   c                N    U R                   " U40 UD6nU R                  X65        U$ r   )r  r{   r|   s          r$   rd   ConverterVolpiano.writeY  s(    //#22R)	r'   c                <    [        U R                  " U40 UD65        g r   )r   r  r   s         r$   rh   ConverterVolpiano.show^  s    dooc.X./r'   r	   r   )r,   r   r  r   r   )r   r   r   r   r   r   r   r   r-   r  rd   rh   r   r   r'   r$   r  r  *  sU    $ $O0,
  	Q
  %	Q 	Q
 	Q&
0r'   r  c                       \ rS rSrSrSrSrSrg)ConverterScalaib  )scala)sclr   N)r   r   r   r   r   r   r   r   r   r'   r$   r"  r"  b  s     O&'r'   r"  c                  T   ^  \ rS rSrSrSrSrU 4S jrS	S jr S	   S
S jjr	Sr
U =r$ )ConverterHumdrumii  zR
Simple class wrapper for parsing Humdrum data provided in a file or in a string.
)humdrum)krnc                4   > [         TU ]  " S0 UD6  S U l        g r   r   r%   datar#   r!   r   s     r$   r%   ConverterHumdrum.__init__p      $8$	r'   c                    SSK Jn  U" U5      nUR                  5         X@l        U R                  R                  U l        U R                  $ )a   
Open Humdrum data from a string -- calls
:meth:`~music21.humdrum.spineParser.HumdrumDataCollection.parse()`.

>>> humData = ('**kern\n*M2/4\n=1\n24r\n24g#\n24f#\n24e\n24c#\n' +
...     '24f\n24r\n24dn\n24e-\n24gn\n24e-\n24dn\n*-')
>>> c = converter.subConverters.ConverterHumdrum()
>>> s = c.parseData(humData)
>>> c.stream.show('text')
{0.0} <music21.metadata.Metadata object at 0x7f33545027b8>
{0.0} <music21.stream.Part spine_0>
    {0.0} <music21.humdrum.spineParser.MiscTandem **kern>
    {0.0} <music21.stream.Measure 1 offset=0.0>
        {0.0} <music21.meter.TimeSignature 2/4>
        {0.0} <music21.note.Rest 1/6ql>
        {0.1667} <music21.note.Note G#>
        {0.3333} <music21.note.Note F#>
        {0.5} <music21.note.Note E>
        {0.6667} <music21.note.Note C#>
        {0.8333} <music21.note.Note F>
        {1.0} <music21.note.Rest 1/6ql>
        {1.1667} <music21.note.Note D>
        {1.3333} <music21.note.Note E->
        {1.5} <music21.note.Note G>
        {1.6667} <music21.note.Note E->
        {1.8333} <music21.note.Note D>
r   )HumdrumDataCollection)music21.humdrum.spineParserr0  parser+  r
   )r#   humdrumStringr,   r0  hdfs        r$   r-   ConverterHumdrum.parseDatav  s;    8 	F#M2			ii&&yyr'   c                    SSK Jn  U" U5      nUR                  5         XPl        U R                  R                  U l        U R                  $ )zd
Open Humdrum data from a file path.

Calls humdrum.parseFile on filepath.

Number is ignored here.
r   )HumdrumFile)r1  r7  parseFilenamer+  r
   )r#   r7   r,   r!   r7  hfs         r$   r:   ConverterHumdrum.parseFile  s?     	<"
	 ii&&yyr'   r+  r
   r   r7   pathlib.Path | strr,   r   )r   r   r   r   r   r   r   r%   r-   r:   r   r   r   s   @r$   r&  r&  i  s?     #O&"L &*," r'   r&  c                  >   ^  \ rS rSrSrSrSrU 4S jrSS jrSr	U =r
$ )	ConverterTinyNotationi  zl
Simple class wrapper for parsing TinyNotation data provided in a file or
in a string.

Input only for now.
)tinynotation)tntxtr@  c                4   > [         TU ]  " S0 UD6  S U l        g r   r*  r,  s     r$   r%   ConverterTinyNotation.__init__  r.  r'   c                    [        U[        5      (       a  UnO[        S5      eSSKJn  UR
                  " U40 U R                  D6R                  5       R                  U l        g)a  
Open TinyNotation data from a string

>>> tnData = "3/4 E4 r f# g=lastG trip{b-8 a g} c"
>>> c = converter.subConverters.ConverterTinyNotation()
>>> s = c.parseData(tnData)
>>> c.stream.show('text')
{0.0} <music21.stream.Measure 1 offset=0.0>
    {0.0} <music21.clef.TrebleClef>
    {0.0} <music21.meter.TimeSignature 3/4>
    {0.0} <music21.note.Note E>
    {1.0} <music21.note.Rest quarter>
    {2.0} <music21.note.Note F#>
{3.0} <music21.stream.Measure 2 offset=3.0>
    {0.0} <music21.note.Note G>
    {1.0} <music21.note.Note B->
    {1.3333} <music21.note.Note A>
    {1.6667} <music21.note.Note G>
    {2.0} <music21.note.Note C>
    {2.5} <music21.bar.Barline type=final>
zWTinyNotation no longer supports two-element calls; put the time signature in the streamr   )tinyNotationN)	r   r   r   r   rE  r   r!   r2  r
   )r#   tnDatar,   tnStrrE  s        r$   r-   ConverterTinyNotation.parseData  sW    . fc""E'"# # 	)",,UDdmmDJJLSSr'   r;  r   )r   r   r   r   r   r   r   r%   r-   r   r   r   s   @r$   r?  r?    s&     (O7
T Tr'   r?  c                  <    \ rS rSrSrSrSrS r S	   S
S jjrSr	g)ConverterNoteworthyi  a  
Simple class wrapper for parsing NoteworthyComposer data provided in a
file or in a string.

Gets data with the file format .nwctxt

Users should not need this routine.  The basic format is converter.parse('file.nwctxt')


>>> nwcTranslatePath = common.getSourceFilePath() / 'noteworthy' #_DOCS_HIDE
>>> paertPath = nwcTranslatePath / 'Part_OWeisheit.nwctxt' #_DOCS_HIDE
>>> #_DOCS_SHOW paertPath = converter.parse(r'd:/desktop/arvo_part_o_weisheit.nwctxt')
>>> paertStream = converter.parse(paertPath)
>>> len(paertStream.parts)
4

For developers: see the documentation for :meth:`parseData` and :meth:`parseFile`
to see the low-level usage.
)noteworthytext)nwctxtc                X    SSK Jn  UR                  5       R                  U5      U l        g)a  
Open Noteworthy data from a string or list

>>> nwcData = ('!NoteWorthyComposer(2.0)\n|AddStaff\n|Clef|' +
...     'Type:Treble\n|Note|Dur:Whole|Pos:1^')
>>> c = converter.subConverters.ConverterNoteworthy()
>>> c.parseData(nwcData)
>>> c.stream.show('text')
{0.0} <music21.stream.Part ...>
    {0.0} <music21.stream.Measure 0 offset=0.0>
        {0.0} <music21.clef.TrebleClef>
        {0.0} <music21.note.Note C>
r   r   N)music21.noteworthyr   NoteworthyTranslatorparseStringr
   )r#   nwcDatanoteworthyTranslates      r$   r-   ConverterNoteworthy.parseData  s#     	H)>>@LLWUr'   Nc                X    SSK Jn  UR                  5       R                  U5      U l        g)a  
Open Noteworthy data (as nwctxt) from a file path.

>>> nwcTranslatePath = common.getSourceFilePath() / 'noteworthy' #_DOCS_HIDE
>>> filePath = nwcTranslatePath / 'Part_OWeisheit.nwctxt' #_DOCS_HIDE
>>> #_DOCS_SHOW paertPath = converter.parse('d:/desktop/arvo_part_o_weisheit.nwctxt')
>>> c = converter.subConverters.ConverterNoteworthy()
>>> c.parseFile(filePath)
>>> #_DOCS_SHOW c.stream.show()
r   rN  N)rO  r   rP  r:   r
   )r#   r7   r,   r!   rS  s        r$   r:   ConverterNoteworthy.parseFile  s#     	H)>>@JJ8Tr'   r	   r   r<  
r   r   r   r   r   r   r   r-   r:   r   r   r'   r$   rJ  rJ    s=    & *O)V( &*U,U"U Ur'   rJ  c                  @    \ rS rSrSrSrSrSrS r S
   SS jjr	S	r
g)ConverterNoteworthyBinaryi  z
Simple class wrapper for parsing NoteworthyComposer binary data
provided in a file or in a string.

Gets data with the file format .nwc

Users should not need this routine.  Call converter.parse directly
T)
noteworthy)nwcc                X    SSK Jn  UR                  5       R                  U5      U l        g Nr   )binaryTranslate)rO  r^  NWCConverterrQ  r
   )r#   rR  noteworthyBinarys      r$   r-   #ConverterNoteworthyBinary.parseData-  s     J&335AA'Jr'   Nc                X    SSK Jn  UR                  5       R                  U5      U l        g r]  )rO  r^  r_  r:   r
   )r#   r7   r,   r!   r`  s        r$   r:   #ConverterNoteworthyBinary.parseFile1  s#     	K&335??Ir'   r	   r   r<  )r   r   r   r   r   r   r   r   r-   r:   r   r   r'   r$   rY  rY    sB     J%O'K &*J,J"J Jr'   rY  c                      \ rS rSrSrSrSrSrSSS.rSSS
 jjr	 S   SS jjr
    SS jr  SSS	S.   SS jjjrSS jrSrg	)ConverterMusicXMLi:  z~
Converter for MusicXML using the 2015 ElementTree system.

Users should not need this Object.  Call converter.parse directly
)r   r   )r   mxlr   )r   r   rf  r   r   )r   r   Nc                ~    SSK Jn  UR                  5       nXl        UR	                  5         UR
                  U l        g)z#
Open MusicXML data from a string.
r   xmlToM21N)music21.musicxmlri  MusicXMLImporterxmlTextparseXMLTextr
   )r#   	xmlStringr,   ri  cs        r$   r-   ConverterMusicXML.parseDataG  s/     	.%%'		hhr'   c                   SSK Jn  SSKJn  UR	                  5       nUR                  U5      nUR                  5       (       a'  UR                  5       nXl        UR                  5         OUR                  U5        UR                  R                  R                  c;  [        R                  R!                  U5      u  pXR                  R                  l        UR                  U l        g)z
Open from a file path; check to see if there is a pickled
version available and up to date; if so, open that, otherwise
open source.
r   	converterrh  N)r   rs  rj  ri  rk  ArchiveManager	isArchivegetDatarl  rm  readFiler
   metadatamovementNameospathsplit)r#   r7   r,   r!   rs  ri  ro  archarchDatajunkfns              r$   r:   ConverterMusicXML.parseFileR  s     	&-%%' ''1>>||~H INNJJx  88))1ww}}X.HD-/HH*hhr'   c                x   [        U[        5      (       d  [        U S35      eUnUc  U R                  5       nO[        R
                  " USS9nUR                  (       a  UR                  S:X  a  UR                  S5      nSn[        XV5       nUR                  U5        SSS5        U$ ! , (       d  f       U$ = f)a  
Writes `dataStr` which must be bytes to `fp`.
Adds `.musicxml` suffix to `fp` if it does not already contain some suffix.

* Changed in v7: returns a pathlib.Path

OMIT_FROM_DOCS

>>> import os
>>> from music21.converter.subConverters import ConverterMusicXML
>>> fp = 'noSuffix'
>>> sub = ConverterMusicXML()
>>> outFp = sub.writeDataStream(fp, b'')
>>> str(outFp).endswith('.musicxml')
True

>>> os.remove(outFp)
>>> fp = 'other.suffix'
>>> outFp = sub.writeDataStream(fp, b'')
>>> str(outFp).endswith('.suffix')
True
>>> os.remove(outFp)
z& must be bytes to write to this formatNTrs   .mxl	.musicxmlr   )
r   r   rP   rw   r   r   suffixwith_suffixr4   rd   )r#   rv   r}   r!   	dataBytesfpPathr   r8   s           r$   r{   !ConverterMusicXML.writeDataStreams  s    8 '5))y(NOPP	 :**,F%%b=F}} 7''4F
&%GGI &  &% s   B**
B9T)makeNotationcompressc               d   SSK JnJn	  [        R                  n
[        R
                  nUcD  U(       a"  [        U5      R                  S5      (       a  SnOUR                  S5      (       a  SnOSnSU;   a  S[        l        S[        l        S	nU	R                  U5      nX]l
        UR                  5       nUnUb9  U(       a2  [        U5      n[        R                  R                  U5      S   nUS
-   nU R                  X5      nSU;   a  U
[        l        U[        l        SU;   d  SU;   a8  [        [         S   5      R                  S5      (       d  SSKJn  U" UU40 UD6nU$ U(       aC  UR'                  USSSS9  UR)                  S5      n[*        R,                  R/                  USS9nU$ UnU$ )aS  
Write to a .musicxml file.

Set `makeNotation=False` to prevent fixing up the notation, and where possible,
to prevent making additional deepcopies. (This option cannot be used if `obj` is not a
:class:`~music21.stream.Score`.) `makeNotation=True` generally solves common notation
issues, whereas `makeNotation=False` is intended for advanced users facing
special cases where speed is a priority or making notation reverses user choices.

Set `compress=True` to immediately compress the output to a .mxl file.  Set
to True automatically if format='mxl' or if `fp` is given and ends with `.mxl`
r   )archiveToolsm21ToXmlr  Trf  Fr   r   r'   r  r   musescoreDirectPNGPathz/skip)runThroughMuseScore)deleteOriginalsilentstrictMxlCheckrs   )rj  r  r  r   titleauthorr   endswith
startswithGeneralObjectExporterr  r2  rz  r{  splitextr{   rQ   music21.converter.museScorer  compressXMLr  r   	pathToolsr   )r#   rf   rX   rv   ra   r  r  r!   r  r  savedDefaultTitlesavedDefaultAuthorr  generalExporterwriteDataStreamFpfpStr
noExtFpStrxmlFpr  outFpfilenameOuts                        r$   rd   ConverterMusicXML.write  s   * 	<$NN%__c"g&&v..&&  JHN HO	"88='3$#))+	>jGE))%03J *[ 8"223DPJ.HN0HOj EZ$7L)ABCNNwWWG'zFXFE  $$U48,049 % ;  ++F3K$$..{$.OE  Er'   c                p    U R                   " X4SU0UD6nSU;   a  SnOSU;   a  SnU R                  XbUS9  g)z#
Override to do something with png
ra   r   r   rb   Nrc   re   s          r$   rh   ConverterMusicXML.show  sH      ::cR:RRJCj C$37r'   r	   r   )rn  r   r   )r}   r   r   r   r   )rf   zmusic21.Music21Objectr  zbool | None)r   r   r   r   r   r   r   r   r   r-   r:   r{   rd   rh   r   r   r'   r$   re  re  :  s    
 *O890505)+%	 &*,"B.!*. (4.f 	H  $(H(H "HT	8r'   re  c                      \ rS rSrSrSrSrSrSr\	SS j5       r
SS	S
.SS jjjr SS	S
.     SS jjjr  SSS	S.   SS jjjrSrg)r   i  zB
Simple class wrapper for parsing MIDI and sending MIDI data out.
T)r   )midr   )r  c                j    SU R                   ;   a#  U R                   S   (       a  U R                   S   $ g)Nr1   r   )r!   r>   s    r$   r1   ConverterMidi.encoding  s+    &4==+D==,,r'   Nr   r0   c                   SSK Jn  U R                  R                  5        VVs0 s H  u  pVUS;  d  M  XV_M     nnnUR                  " U4SU=(       d    U R
                  0UD6U l        gs  snnf )a  
Get MIDI data from a binary string representation.

Calls midi.translate.midiStringToStream.

Keywords to control quantization:
`quantizePost` controls whether to quantize the output. (Default: True)
`quarterLengthDivisors` allows for overriding the default quantization units
in defaults.quantizationQuarterLengthDivisors. (Default: (4, 3)).

If encoding is not provided use the encoding of the Converter
(default "utf-8")
r   rN  r0   r1   N)music21.midir   r!   itemsmidiStringToStreamr1   r
   )r#   strDatar,   r1   midiTranslatekvr!   s           r$   r-   ConverterMidi.parseData
  st     	<%)]]%8%8%: /%:TQ- AD%: /#66
.
 
/s
   A+A+c                   SSK Jn  U R                  R                  5        VVs0 s H  u  pgUS;  d  M  Xg_M     nnnUR                  " U4U R
                  U=(       d    U R                  S.UD6  gs  snnf )a  
Get MIDI data from a file path.

Calls midi.translate.midiFilePathToStream.

Keywords to control quantization:
`quantizePost` controls whether to quantize the output. (Default: True)
`quarterLengthDivisors` allows for overriding the default quantization units
in defaults.quantizationQuarterLengthDivisors. (Default: (4, 3)).

If encoding is not provided use the encoding of the Converter
(default "utf-8")
r   rN  r0   )inputM21r1   N)r  r   r!   r  midiFilePathToStreamr
   r1   )r#   r7   r,   r1   r!   r  r  r  s           r$   r:   ConverterMidi.parseFile!  sw    & 	<%)]]%8%8%: /%:TQ- AD%: /**	
[[.	
 		
/s
   A1A1FaddStartDelayr1   c                   SSK Jn  Uc  U R                  5       nUR                  XU=(       d    U R                  S9n	U	R                  US5        U	R                  5         U	R                  5         U$ )Nr   rN  r  r   )r  r   rw   music21ObjectToMidiFiler1   r4   rd   r   )
r#   rf   rX   rv   ra   r  r1   r!   r  mfs
             r$   rd   ConverterMidi.write>  sc     	<:&&(B223<D<U 3 W
D



	r'   r	   )r   r   r   )r1   r   )r7   r=  r,   r   r1   r   r   )r  r   r1   r   )r   r   r   r   r   r   r   r   r   r   r1   r-   r:   rd   r   r   r'   r$   r   r     s     JO-' 
 
 
2 &*
 #%	
,
"
  	
@ 	 %*  "  r'   r   c                  @    \ rS rSrSrSrSrSS jr S   S	S jjrSr	g)
ConverterABCiT  z3
Simple class wrapper for parsing ABC.

Input only
)abcNc                   SSK Jn  UR                  5       nUR                  XS9nUR	                  5       (       a   UR
                  R                  UUS9U l        gUR
                  R                  XPR                  5        g)z
Get ABC data, as token list, from a string representation.
If more than one work is defined in the ABC data, a
:class:`~music21.stream.Opus` object will be returned;
otherwise, a :class:`~music21.stream.Score` is returned.
r   	abcFormatr,   N)	r   r  ABCFilereadstrdefinesReferenceNumbersr   abcToStreamOpusr
   abcToStreamScore)r#   r  r,   r  af
abcHandlers         r$   r-   ConverterABC.parseData]  sq     	& ZZZ7
--//#--==jEK > MDK 00[[Ir'   c                D   SSK Jn  UR                  5       nUR                  U5        UR	                  US9nUR                  5         UR                  5       (       a   UR                  R                  UUS9U l	        gUR                  R                  X`R                  5        g)aB  
Get ABC data from a file path. If more than one work is defined in the ABC
data, a  :class:`~music21.stream.Opus` object will be returned;
otherwise, a :class:`~music21.stream.Score` is returned.

If `number` is provided, and this ABC file defines multiple works
with an X: tag, just the specified work will be returned.
r   r  r  N)r   r  r  r4   r6   r   r  r   r  r
   r  )r#   r7   r,   r!   r  r  r  s          r$   r:   ConverterABC.parseFilep  s     	& 
WWFW+


 --// $--==jEK > MDK 00[[Ir'   r	   r   r<  rW  r   r'   r$   r  r  T  s=    
 O&J* &*J,J"J Jr'   r  c                  N    \ rS rSrSrSrSrSrSS jr S   SS jjr	SS	 jr
S
rg)ConverterRomanTexti  zC
Simple class wrapper for parsing roman text harmonic definitions.
)	romantextrntext)rntxtr  r  rtxt)r  Nc                    SSK Jn  SSK Jn  UR                  5       nUR	                  U5      nUR                  5       (       a  UR                  U5      U l        g UR                  X`R                  5        g Nr   )	rtObjectsrN  )	music21.romanTextr  r   RTFiler  definesMovementsromanTextToStreamOpusr
   romanTextToStreamScore)r#   r  r,   r  romanTextTranslatertf	rtHandlers          r$   r-   ConverterRomanText.parseData  sW    /E KK(	%%'',BB9MDK55iMr'   c                    SSK Jn  SSK Jn  UR                  5       nUR	                  U5        UR                  5       nUR                  5         UR                  XpR                  5        g r  )	r  r  r   r  r4   r6   r   r  r
   )r#   r7   r,   r!   r  r  r  r  s           r$   r:   ConverterRomanText.parseFile  sJ     	0E HHJ			11)[[Ir'   c                   SSK Jn  Uc  U R                  5       n[        US5      (       dL  [	        USSS9 nUR                  U5      R                   H  nUR                  US-   5        M     SSS5        U$ UR                  U5      R                   H  nUR                  US-   5        M     U$ ! , (       d  f       U$ = f)	zN
Writes 'RomanText' files (using the extension .rntxt) from a music21.stream.
r   )
writeRomanNrd   r   r   r0   
)r  r  rw   hasattrr4   RnWritercombinedListrd   )	r#   rf   rX   rv   ra   r!   r  	text_fileentrys	            r$   rd   ConverterRomanText.write  s    
 	1:&&(Br7##b#0I'005BBEOOEDL1 C 1 	 $,,S1>>& ? 	 10 	s   7B//
B>r	   r   r<  r   )r   r   r   r   r   r   r   r   r-   r:   rd   r   r   r'   r$   r  r    sB     .OF)	N &*J,J"Jr'   r  c                  @    \ rS rSrSrSrSrSS	S jjr S S
S jjrSr	g)ConverterClercqTemperleyi  z\
Wrapper for parsing harmonic definitions in Trevor de Clercq and
David Temperley's format.
)cttxtharclercqTemperleyNc                \    SSK Jn  UR                  U5      nUR                  5       U l        g )Nr   )r  )r  r  CTSongr  r
   )r#   r  r,   r  ctSongs        r$   r-   "ConverterClercqTemperley.parseData  s"    5 ''0mmor'   c                &    U R                  U5        g r   )r-   )r#   r7   r,   r!   s       r$   r:   "ConverterClercqTemperley.parseFile  s     	x r'   r	   r   )r  r   )r7   r=  rW  r   r'   r$   r  r    s0     :OA& !,! !r'   r  c                  @    \ rS rSrSrSrSrS	S jr S	   S
S jjrSr	g)ConverterCapellai  zX
Simple class wrapper for parsing Capella .capx XML files.  See capella/fromCapellaXML.
)capella)capxNc                    SSK Jn  UR                  5       nUR                  U5        UR	                  UR
                  R                  5      nUR                  U5      nX`l        g)z^
parse a data stream of uncompressed capella xml

N.B. for web parsing, it gets more complex.
r   fromCapellaXMLN)	music21.capellar  CapellaImporterrm  systemScoreFromScoremainDomdocumentElementpartScoreFromSystemScorer
   )r#   r  r,   r  ciscoreObj	partScores          r$   r-   ConverterCapella.parseData  sP     	3++-
 **2::+E+EF//9	r'   c                \    SSK Jn  UR                  5       nUR                  U5      U l        g)z
Parse a Capella file
r   r  N)r   r  r  scoreFromFiler
   )r#   r7   r,   r!   r  r  s         r$   r:   ConverterCapella.parseFile  s'     	3++-&&x0r'   r	   r   r   rW  r   r'   r$   r  r    s8     #O'  &*	1,	1"	1 	1r'   r  c                  @    \ rS rSrSrSrSrS	S jr S	   S
S jjrSr	g)ConverterMuseDatai  z,
Simple class wrapper for parsing MuseData.
musedata)mdr  zipNc                    SSK Jn  SSKJn  [	        U[
        5      (       a  U/nOUnUR                  5       nU H  nUR                  U5        M     UR                  X`R                  5        g)z,
Get musedata from a string representation.
r   r  rN  N)
r   r  music21.musedatar   r   r   MuseDataWork	addStringmuseDataWorkToStreamScorer
   )r#   r  r,   musedataModulemusedataTranslatestrDataListmdwstrDataInners           r$   r-   ConverterMuseData.parseData  s[     	7Cgs##")K!K))+'LMM,' ( 	33CEr'   c                   [        U[        R                  5      (       d  [        R                  " U5      nOUnSSKJn  SSKJn  SSKJn  UR                  5       nUR                  U5      n	UR                  S:X  d  U	R                  5       (       a(  U	R                  SS9 H  n
UR                  U
5        M     OrUR                  5       (       a"  UR                  U5      nUR!                  5       nO!["        R$                  " U5      (       d  U/nOUnU H  nUR'                  U5        M     UR)                  XR*                  5        g)	z(
parse fp (a pathlib.Path()) and number
r   rr  r  rN  z.zipr  )
dataFormatN)r   r   r   r   rs  r  r  r   r  rt  r  ru  rv  r  is_dirMuseDataDirectorygetPathsr   
isListLikeaddFiler  r
   )r#   r7   r,   r!   rv   rs  r  r  r  r  partStrmddfpListfpInners                 r$   r:   ConverterMuseData.parseFile  s     (GLL11h'BB%6C))+%%b) 99",,.. :::<g& = yy{{$66r:&&r**!G$ "
 	33CEr'   r   r   r   rW  r   r'   r$   r  r    s=     $O7F* &*+F,+F"+F +Fr'   r  c                  b    \ rS rSrSrSrSrSSS jjr S     SS jjrS r	SS jr
SS	 jrS
rg)ConverterMEIiC  z}
Converter for MEI. You must use an ".mei" file extension for MEI files because music21 will
parse ".xml" files as MusicXML.
meiNc                    SSK Jn  UR                  S5      (       a  USS nUR                  U5      R	                  5       U l        U R
                  $ )z
Convert a string with an MEI document into its corresponding music21 elements.

* dataString: The string with XML to convert.

* number: Unused in this class. Default is ``None``.

Returns the music21 objects corresponding to the MEI file.
r   r,  zmei:   N)r   r-  r  MeiToM21ConverterrV   r
   )r#   r+   r,   r-  s       r$   r-   ConverterMEI.parseDataN  sH     	   ((#ABJ++J7;;={{r'   c                8    [        USSS9 nUR                  5       nSSS5        U R                  WU5        U R                  $ ! , (       d  f       N,= f! [         a:    [        USSS9 nUR                  5       nSSS5         M`  ! , (       d  f        No= ff = f)a  
Convert a file with an MEI document into its corresponding music21 elements.

* filePath: Full pathname to the file containing MEI data as a string or Path.

* number: Unused in this class. Default is ``None``.

Returns the music21 objects corresponding to the MEI file.
rtr   r0   Nzutf-16)r4   r6   r   r-   r
   )r#   r7   r,   r!   r8   r9   s         r$   r:   ConverterMEI.parseFile`  s~    "	&hw71VVX
 8 	z6*{{ 87! 	&hx8AVVX
 9888	&sE   A AA 
AA A B*B;B
B	BBc                    g)z$
MEI export is not yet implemented.
Fr   r"   s     r$   rG   ConverterMEI.checkShowAbility|  s     r'   c                    [        S5      eNz"MEI export is not yet implemented.r)   r   s         r$   rh   ConverterMEI.show      !"FGGr'   c                    [        S5      er8  r)   )r#   rf   rX   rv   ra   r!   s         r$   rd   ConverterMEI.write  r:  r'   r	   r   )r+   r   r   stream.Stream)r7   r   r,   r   r   r=  r   )r   r   r   r   r   r   r   r-   r:   rG   rh   rd   r   r   r'   r$   r+  r+  C  sP     O&
*  " 
 
8HHr'   r+  c                  J    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)Testi  c                    SSK Jn  UR                  5       n[        R                  " 5       nUR                  U5        UR                  S5      ng )Nr   notetextLine)r   rB  Noter
   r  r  rh   )r#   rB  nr  unused_xs        r$   testSimpleTextShowTest.testSimpleTextShow  s4     IIKMMO	66*%r'   c                    SSK Jn  UR                  S5       n[        5       nUR	                  S5        UR                  S5        SSS5        g! , (       d  f       g= f)z$
When the string starts with "mei:"
r   mockmusic21.mei.MeiToM21Converterzmei: <?xml><mei><note/></mei>z <?xml><mei><note/></mei>NunittestrK  patchr+  r-   assert_called_once_withr#   rK  mockConvtestConverters       r$   testImportMei1Test.testImportMei1  sG     	"ZZ78H(NM##$CD,,-HI 988   -A
Ac                    SSK Jn  UR                  S5       n[        5       nUR	                  S5        UR                  S5        SSS5        g! , (       d  f       g= f)z+
When the string doesn't start with "mei:"
r   rJ  rL  z<?xml><mei><note/></mei>NrM  rQ  s       r$   testImportMei2Test.testImportMei2  sG     	"ZZ78H(NM##$>?,,-GH 988rV  c                   SSK Jn  UR                  S5       n[        R                  " 5       S-  S-  S-  n[        5       nUR                  U5        U R                  SUR                  5        SSS5        g! , (       d  f       g= f)	z
When the file uses UTF-16 encoding rather than UTF-8 (which happens if
it was exported from
the "sibmei" plug-in for Sibelius).
r   rJ  rL  r-  testznotes_in_utf16.meir   N	rN  rK  rO  r   getSourceFilePathr+  r:   assertEqual
call_countr#   rK  rR  testPathrS  s        r$   testImportMei3Test.testImportMei3  sk     	"ZZ78H//1E9FBEYYH(NM##H-Q 3 34	 988   AA77
Bc                   SSK Jn  UR                  S5       n[        R                  " 5       S-  S-  S-  n[        5       nUR                  U5        U R                  SUR                  5        SSS5        g! , (       d  f       g= f)	z[
For the sake of completeness, this is the same as testImportMei3() but with a UTF-8 file.
r   rJ  rL  r-  r[  znotes_in_utf8.meir   Nr\  r`  s        r$   testImportMei4Test.testImportMei4  sk     	"ZZ78H//1E9FBEXXH(NM##H-Q 3 34	 988rd  c                   SSK Jn  SSKJn  UR	                  UR
                  5      nUR                  S5      nU R                  [        U5      R                  S5      U S35        UR                  US9  U R                  [        5         [        USS	S
9 nUR                  S5        S S S 5        S S S 5        [        5       nUR                  USS9nU R                  [        5         [        USS	S
9 nUR                  S5        S S S 5        S S S 5        [        R                   " U5        [        R                   " U5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Ne= f! , (       d  f       Nn= f)Nr   rr  )testPrimitiverf  r  z does not end with .mxl)rv   r   r   r0      )rf   rX   )r   rs  rj  ri  r-   multiDigitEndingrd   
assertTruer   r  assertRaisesr   r4   r6   re  rz  remove)r#   rs  ri  r  mxlPathr8   r   mxlPath2s           r$   testWriteMXLTest.testWriteMXL  s   %2 > >?''%.G--f5'BY7Z[ 	
712gsW5r
 6 3
 !"::!:/12hg6!r
 7 3 			'
		( 65 32 76 32sH   
EE(E'E53E$E5
E	E
E!$
E2	.E55
Fc                >   SSK Jn  SSK Jn  SSKJn  [
        R                  " UR                  SS95      n[
        R                  " 5       n[
        R                  " XE/5      n[
        R                  " U5      nU R                  [        UR                  5      S5        U R                  [        UR                  5      S5        UR                  5       nUR                  U5      n	U R                  [        U	R                  R!                  5       R#                  [
        R                  5      S   R                  5      S5        U R                  [        U	R                  R!                  5       R#                  [
        R                  5      S   R                  5      S5        U R%                  U5         UR                  SS	9  S S S 5        UR'                  S
S9S   nUR                  SS	9n
UR                  U
5      n	U R                  [        U	R                  R!                  5       R#                  [
        R                  5      S   R                  5      S5        U R                  [        U	R                  R!                  5       R#                  [
        R                  5      S   R                  5      S5        U R%                  U5         UR                  SS	9  S S S 5        X4 H  n[(        R*                  " U5        M     g ! , (       d  f       GNE= f! , (       d  f       NA= f)Nr   rr  rA  )MusicXMLExportExceptiong      @)quarterLengthr   F)r  T)recurse   )r   rs  rB  music21.musicxml.xmlObjectsrt  r
   MeasurerD  Partr   r^  lennotesrd   r2  partsfirstgetElementsByClassrm  splitAtDurationsrz  rn  )r#   rs  rB  rt  m1m2pr  out1round_trip_backout2r   s               r$   testWriteMusicXMLMakeNotation"Test.testWriteMusicXMLMakeNotation  sS   % G^^DIICI89^^KK!LLORXX*RXX*wwy#//$/%%++-@@PQRSYYZ\]	_%%++-@@PQRSYYZ\]	_ 67GGG' 8 t,Q/wwEw*#//$/ 	%%++-@@PQRSYYZ\]	_%%++-@@PQRSYYZ\]	_ 67GGG' 8 <CIIcN  ' 87  87s   .K<L<
L
Lc                   SSK Jn  UR                  S5      nUR                  SSS9n[	        USSS	9 nU R                  S
UR                  5       5        S S S 5        [        R                  " U5        g ! , (       d  f       N%= f)Nr   rr  ztinyNotation: c1 d1 e1 f1r   T)debugr   r   r0   z(<music21.braille.segment BrailleSegment>)	r   rs  r2  rd   r4   assertInr6   rz  rn  )r#   rs  r  r   r8   s        r$   testBrailleKeywordsTest.testBrailleKeywords  sb    %OO78ggitg,#sW-MMDaffhO .
		# .-s   !A33
Bc                    SS K nSSKJn  SSKJn  UR                  S5      nUR                  USS9nU" 5       nUR                  SU5        U R                  UR                  5       R                  U5      5        g )Nr   )StringIOrr  z=
            Time Signature: 3/4
            m1 C: I
        	romanText)format)textwrapior  r   rs  dedentr2  rd   rl  getvaluer  )r#   r  r  rs  r  r  text_streams          r$   testWriteRomanTextTest.testWriteRomanText  sg    % !  OOE+O6j	[),,.77>?r'   r   N)r   r   r   r   rG  rT  rX  rb  rf  rq  r  r  r  r   r   r'   r$   r?  r?    s3    &JI5	52)V@r'   r?  c                  *    \ rS rSrSrS rS rS rSrg)TestExternali"  Tc                v    SSK Jn  UR                  S5      nU R                  (       a  UR                  5         g g )Nr   )corpuszbwv66.6)r   r  r2  rh   )r#   r  ro  s      r$   testXMLShowTestExternal.testXMLShow%  s(    "LL#99FFH r'   c                   SSK Jn  UR                  5       nSUR                  l        [
        R                  " 5       nUR                  U5        U R                  (       a,  UR                  S5        [        UR                  S5      5        g g )Nr   rA  wholezlily.png)r   rB  rD  durationtyper
   r  r  rh   r   rd   )r#   rB  rE  r  s       r$   testWriteLilypondTestExternal.testWriteLilypond+  sZ     IIK!

MMO	99FF:!''*%& r'   c                    SSK Jn  SSK Jn  UR                  R                  nUR                  U5      nU R                  (       a,  UR                  S5        [        UR                  S5      5        gg)z?
tests whether show() works for music that is 10-99 pages long
r   )omrrr  zmusicxml.pngN)	r   r  rs  
correctorsK525groundTruthFilePathr2  rh   r   rd   )r#   r  rs  K525s       r$   testMultiPageXMlShow1"TestExternal.testMultiPageXMlShow15  sP     	 %~~55t$99IIn%$**^,- r'   r   N)	r   r   r   r   rh   r  r  r  r   r   r'   r$   r  r  "  s    D'
.r'   r  __main__)1r   
__future__r   r  r   rz  r   rU   typingr   rN  r   r   r   r   music21.exceptions21r   r
   r   collections.abcr   EnvironmentrQ   r   r   r   r   r   r   r  r  r"  r&  r?  rJ  rY  re  r   r  r  r  r  r  r+  TestCaser?  r  r   mainTestr   r'   r$   <module>r     s   #  	        6  ??(&&'@A
k k\	4| 4n5S 5Sp!| !H| &)L )&# #*50 50p(\ (C| CP-TL -T`;U, ;U|J J6|8 |8@VL Vt:J< :Jz2 2j!| !(1| 1BEF EFPIH< IH^N@8 N@`.8$$ .\ zT r'   