Previous topic

music21.converter

Next topic

music21.corpus

Table Of Contents

Table Of Contents

This Page

music21.converter.subConverters

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

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 Opus object will be returned; otherwise, a Score is returned.

ConverterABC.parseFile(fp, number=None)

Get MIDI data from a file path. If more than one work is defined in the ABC data, a Opus object will be returned; otherwise, a Score is 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

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

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:

ConverterHumdrum

class music21.converter.subConverters.ConverterHumdrum

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#\n24f\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

ConverterIPython bases

ConverterIPython read/write properties

Read/write properties inherited from SubConverter:

ConverterIPython methods

ConverterIPython.show(obj, fmt, app=None, subformats=None, **keywords)
ConverterIPython.vfshow(s)

Methods inherited from SubConverter:

ConverterLilypond

class music21.converter.subConverters.ConverterLilypond

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:

ConverterMidi

class music21.converter.subConverters.ConverterMidi

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

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)

Methods inherited from SubConverter:

ConverterMusicXML

class music21.converter.subConverters.ConverterMusicXML

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.partIdToNameDict()
ConverterMusicXML.runThroughMusescore(fp, **keywords)
ConverterMusicXML.write(obj, fmt, fp=None, subformats=None, **keywords)

Methods inherited from SubConverter:

ConverterNoteworthy

class music21.converter.subConverters.ConverterNoteworthy

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() and parseFile() 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.

>>> nwcTranslatePath = common.getSourceFilePath() + os.path.sep + 'noteworthy'
>>> 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

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

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

ConverterScala bases

ConverterScala read/write properties

Read/write properties inherited from SubConverter:

ConverterScala methods

Methods inherited from SubConverter:

ConverterText

class music21.converter.subConverters.ConverterText

standard text presentation has line breaks, is printed.

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

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')
u'{0.0} <music21.stream.Part Soprano> / {0.0} <music21.instrument.Instrument P1: Soprano: 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

Simple class wrapper for parsing TinyNotation data provided in a file or in a string.

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 or list

>>> tnData = ["E4 r f# g=lastG trip{b-8 a g} c", "3/4"]
>>> c = converter.subConverters.ConverterTinyNotation()
>>> s = c.parseData(tnData)
>>> c.stream.show('text')
{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.note.Note G>
{4.0} <music21.note.Note B->
{4.3333} <music21.note.Note A>
{4.6667} <music21.note.Note G>
{5.0} <music21.note.Note C>        

Methods inherited from SubConverter:

ConverterVexflow

class music21.converter.subConverters.ConverterVexflow

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

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 codecs need to be used to write stringEncoding = string (default ‘utf-8’) if codecWrite is True, 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)
SubConverter.parseData(dataString, number=None)

Called when a string (or binary) data is encountered.

This method MUST be implemented to do anything.

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)