music21.converter.subConverters¶
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.
ConverterABC¶
-
class
music21.converter.subConverters.ConverterABC(**keywords)¶ Simple class wrapper for parsing ABC.
Input only
ConverterABC bases
ConverterABC read/write properties
Read/write properties inherited from SubConverter:
ConverterABC methods
-
ConverterABC.parseData(strData, number=None)¶ Get ABC data, as token list, from a string representation. If more than one work is defined in the ABC data, a
Opusobject will be returned; otherwise, aScoreis returned.
-
ConverterABC.parseFile(fp, number=None)¶ Get ABC data from a file path. If more than one work is defined in the ABC data, a
Opusobject will be returned; otherwise, aScoreis returned.If number is provided, and this ABC file defines multiple works with a X: tag, just the specified work will be returned.
Methods inherited from SubConverter:
ConverterBraille¶
-
class
music21.converter.subConverters.ConverterBraille(**keywords)¶
ConverterBraille bases
ConverterBraille read/write properties
Read/write properties inherited from SubConverter:
ConverterBraille methods
-
ConverterBraille.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterCapella¶
-
class
music21.converter.subConverters.ConverterCapella(**keywords)¶ Simple class wrapper for parsing Capella .capx XML files. See capella/fromCapellaXML.
ConverterCapella bases
ConverterCapella read/write properties
Read/write properties inherited from SubConverter:
ConverterCapella methods
-
ConverterCapella.parseData(strData, number=None)¶ parse a data stream of uncompessed capella xml
N.B. for web parsing, it gets more complex.
-
ConverterCapella.parseFile(fp, number=None)¶ Read a file
Methods inherited from SubConverter:
ConverterClercqTemperley¶
-
class
music21.converter.subConverters.ConverterClercqTemperley(**keywords)¶ Simple class wrapper for parsing roman text harmonic definitions.
ConverterClercqTemperley bases
ConverterClercqTemperley read/write properties
Read/write properties inherited from SubConverter:
ConverterClercqTemperley methods
-
ConverterClercqTemperley.parseData(strData, number=None)¶
-
ConverterClercqTemperley.parseFile(fp, number=None)¶
Methods inherited from SubConverter:
ConverterHumdrum¶
-
class
music21.converter.subConverters.ConverterHumdrum(**keywords)¶ Simple class wrapper for parsing Humdrum data provided in a file or in a string.
ConverterHumdrum bases
ConverterHumdrum read/write properties
Read/write properties inherited from SubConverter:
ConverterHumdrum methods
-
ConverterHumdrum.parseData(humdrumString, number=None)¶ Open Humdrum data from a string – calls humdrum.parseData()
>>> 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.stream.Part spine_0> {0.0} <music21.humdrum.spineParser.MiscTandem **kern humdrum control> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.meter.TimeSignature 2/4> {0.0} <music21.note.Rest rest> {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 rest> {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>
-
ConverterHumdrum.parseFile(filepath, number=None)¶ Open Humdram data from a file path.
Calls humdrum.parseFile on filepath.
Number is ignored here.
Methods inherited from SubConverter:
ConverterIPython¶
-
class
music21.converter.subConverters.ConverterIPython(**keywords)¶ Meta-subconverter for displaying image data etc. in iPython using either png (via MuseScore or LilyPond) or directly via Vexflow/music21j
ConverterIPython bases
ConverterIPython read/write properties
Read/write properties inherited from SubConverter:
ConverterIPython methods
-
ConverterIPython.show(obj, fmt, app=None, subformats=None, **keywords)¶ show using the appropriate subformat.
Methods inherited from SubConverter:
ConverterLilypond¶
-
class
music21.converter.subConverters.ConverterLilypond(**keywords)¶
ConverterLilypond bases
ConverterLilypond read/write properties
Read/write properties inherited from SubConverter:
ConverterLilypond methods
-
ConverterLilypond.show(obj, fmt, app=None, subformats=None, **keywords)¶
-
ConverterLilypond.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterMEI¶
-
class
music21.converter.subConverters.ConverterMEI(**keywords)¶ Converter for MEI. You must use an ”.mei” file extension for MEI files because music21 will parse ”.xml” files as MusicXML.
ConverterMEI bases
ConverterMEI read/write properties
Read/write properties inherited from SubConverter:
ConverterMEI methods
-
ConverterMEI.checkShowAbility(**keywords)¶ MEI export is not yet implemented.
-
ConverterMEI.getTemporaryFile(fmt=None, subformats=None)¶
-
ConverterMEI.launch(filePath, fmt=None, options='', app=None, key=None)¶
-
ConverterMEI.parseData(dataString, number=None)¶ Convert a string with an MEI document into its corresponding music21 elements.
Parameters: - dataString (str) – The string with XML to convert.
- number (NoneType) – Unused in this class. Default is
None.
Returns: The music21 objects corresponding to the MEI file.
Return type: Streamor subclass
-
ConverterMEI.parseFile(filePath, number=None)¶ Convert a file with an MEI document into its corresponding music21 elements.
Parameters: - filePath (str) – Full pathname to the file containing MEI data.
- number (NoneType) – Unused in this calss. Default is
None.
Returns: The music21 objects corresponding to the MEI file.
Return type: Streamor subclass
-
ConverterMEI.show(obj, fmt, app=None, subformats=None, **keywords)¶
-
ConverterMEI.write(obj, fmt, fp=None, subformats=None, **keywords)¶
-
ConverterMEI.writeDataStream(fp, dataStr)¶
Methods inherited from SubConverter:
ConverterMidi¶
-
class
music21.converter.subConverters.ConverterMidi(**keywords)¶ Simple class wrapper for parsing MIDI and sending MIDI data out.
ConverterMidi bases
ConverterMidi read/write properties
Read/write properties inherited from SubConverter:
ConverterMidi methods
-
ConverterMidi.parseData(strData, number=None)¶ Get MIDI data from a binary string representation.
Calls midi.translate.midiStringToStream.
-
ConverterMidi.parseFile(fp, number=None)¶ Get MIDI data from a file path.
Calls midi.translate.midiFilePathToStream.
-
ConverterMidi.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterMuseData¶
-
class
music21.converter.subConverters.ConverterMuseData(**keywords)¶ Simple class wrapper for parsing MuseData.
ConverterMuseData bases
ConverterMuseData read/write properties
Read/write properties inherited from SubConverter:
ConverterMuseData methods
-
ConverterMuseData.parseData(strData, number=None)¶ Get musedata from a string representation.
-
ConverterMuseData.parseFile(fp, number=None)¶ parse fp and number
Methods inherited from SubConverter:
ConverterMusicXML¶
-
class
music21.converter.subConverters.ConverterMusicXML(**keywords)¶ Converter for MusicXML
ConverterMusicXML bases
ConverterMusicXML read/write properties
Read/write properties inherited from SubConverter:
ConverterMusicXML methods
-
ConverterMusicXML.load()¶ Load all parts from a MusicXML object representation. This determines the order parts are found in the stream
-
ConverterMusicXML.parseData(xmlString, number=None)¶ Open MusicXML data from a string.
-
ConverterMusicXML.parseFile(fp, number=None)¶ 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.
-
ConverterMusicXML.runThroughMusescore(fp, **keywords)¶
-
ConverterMusicXML.show(obj, fmt, app=None, subformats=None, **keywords)¶ Override to do something with png...
-
ConverterMusicXML.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterMusicXMLET¶
-
class
music21.converter.subConverters.ConverterMusicXMLET(**keywords)¶ Converter for MusicXML using the new ElementTree system
ConverterMusicXMLET bases
ConverterMusicXMLET read/write properties
Read/write properties inherited from SubConverter:
ConverterMusicXMLET methods
-
ConverterMusicXMLET.parseData(xmlString, number=None)¶ Open MusicXML data from a string.
-
ConverterMusicXMLET.parseFile(fp, number=None)¶ 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.
-
ConverterMusicXMLET.runThroughMusescore(fp, **keywords)¶
-
ConverterMusicXMLET.show(obj, fmt, app=None, subformats=None, **keywords)¶ Override to do something with png...
-
ConverterMusicXMLET.write(obj, fmt, fp=None, subformats=None, **keywords)¶
-
ConverterMusicXMLET.writeDataStream(fp, dataBytes)¶
Methods inherited from SubConverter:
ConverterNoteworthy¶
-
class
music21.converter.subConverters.ConverterNoteworthy(**keywords)¶ 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() + os.path.sep + 'noteworthy' >>> 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
parseData()andparseFile()to see the low-level usage.
ConverterNoteworthy bases
ConverterNoteworthy read/write properties
Read/write properties inherited from SubConverter:
ConverterNoteworthy methods
-
ConverterNoteworthy.parseData(nwcData)¶ 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>
-
ConverterNoteworthy.parseFile(fp, number=None)¶ Open Noteworthy data (as nwctxt) from a file path.
>>> paertPath = converter.parse('d:/desktop/arvo_part_o_weisheit.nwctxt') >>> c = converter.subConverters.ConverterNoteworthy() >>> c.parseFile(filePath) >>> c.stream.show()
Methods inherited from SubConverter:
ConverterNoteworthyBinary¶
-
class
music21.converter.subConverters.ConverterNoteworthyBinary(**keywords)¶ 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
ConverterNoteworthyBinary bases
ConverterNoteworthyBinary read/write properties
Read/write properties inherited from SubConverter:
ConverterNoteworthyBinary methods
-
ConverterNoteworthyBinary.parseData(nwcData)¶
-
ConverterNoteworthyBinary.parseFile(fp, number=None)¶
Methods inherited from SubConverter:
ConverterRomanText¶
-
class
music21.converter.subConverters.ConverterRomanText(**keywords)¶ Simple class wrapper for parsing roman text harmonic definitions.
ConverterRomanText bases
ConverterRomanText read/write properties
Read/write properties inherited from SubConverter:
ConverterRomanText methods
-
ConverterRomanText.parseData(strData, number=None)¶
-
ConverterRomanText.parseFile(fp, number=None)¶
Methods inherited from SubConverter:
ConverterScala¶
-
class
music21.converter.subConverters.ConverterScala(**keywords)¶
ConverterScala bases
ConverterScala read/write properties
Read/write properties inherited from SubConverter:
ConverterScala methods
Methods inherited from SubConverter:
ConverterText¶
-
class
music21.converter.subConverters.ConverterText(**keywords)¶ standard text presentation has line breaks, is printed.
Two keyword options are allowed: addEndTimes=Boolean and useMixedNumerals=Boolean
ConverterText bases
ConverterText read/write properties
Read/write properties inherited from SubConverter:
ConverterText methods
-
ConverterText.show(obj, *args, **keywords)¶
-
ConverterText.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterTextLine¶
-
class
music21.converter.subConverters.ConverterTextLine(**keywords)¶ 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>...'
ConverterTextLine bases
ConverterTextLine read/write properties
Read/write properties inherited from SubConverter:
ConverterTextLine methods
-
ConverterTextLine.show(obj, *args, **keywords)¶
-
ConverterTextLine.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
ConverterTinyNotation¶
-
class
music21.converter.subConverters.ConverterTinyNotation(**keywords)¶ Simple class wrapper for parsing TinyNotation data provided in a file or in a string.
Input only for now.
ConverterTinyNotation bases
ConverterTinyNotation read/write properties
Read/write properties inherited from SubConverter:
ConverterTinyNotation methods
-
ConverterTinyNotation.parseData(tnData, number=None)¶ 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 rest> {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 style=final>
Methods inherited from SubConverter:
ConverterVexflow¶
-
class
music21.converter.subConverters.ConverterVexflow(**keywords)¶
ConverterVexflow bases
ConverterVexflow read/write properties
Read/write properties inherited from SubConverter:
ConverterVexflow methods
-
ConverterVexflow.write(obj, fmt, fp=None, subformats=None, **keywords)¶
Methods inherited from SubConverter:
SubConverter¶
-
class
music21.converter.subConverters.SubConverter(**keywords)¶ 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
SubConverter read/write properties
-
SubConverter.stream¶ Returns or sets the stream in the converter. Must be defined for subconverter to work.
SubConverter methods
-
SubConverter.checkShowAbility(**keywords)¶ 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.
-
SubConverter.getExtensionForFormatOrSubformats(fmt=None, subformats=None)¶
-
SubConverter.getTemporaryFile(fmt=None, subformats=None)¶
-
SubConverter.launch(filePath, fmt=None, options='', app=None, key=None)¶ Opens the appropriate viewer for the file generated by .write()
-
SubConverter.parseData(dataString, number=None)¶ Called when a string (or binary) data is encountered.
This method MUST be implemented to do anything in parsing.
-
SubConverter.parseFile(filePath, number=None)¶ 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 do anything except set self.readBinary (True|False).
-
SubConverter.show(obj, fmt, app=None, subformats=None, **keywords)¶
-
SubConverter.write(obj, fmt, fp=None, subformats=None, **keywords)¶
-
SubConverter.writeDataStream(fp, dataStr)¶