.. _moduleConverter:

music21.converter
=================

.. WARNING: DO NOT EDIT THIS FILE: AUTOMATICALLY GENERATED

.. module:: music21.converter

Public interface for importing various file formats into music21. The most powerful and easy to use tool is the :func:`~music21.converter.parse` function. Simply provide a URL and, if the format is supported, a :class:`~music21.stream.Stream` will be returned. 




.. function:: parse(value, *args, **keywords)

    Given a file path, encoded data in a Python string, or a URL, attempt to parse the item into a Stream. Note: URL downloading will not happen automatically unless the user has set their Environment "autoDownload" preference to "allow". 

    >>> s = parse(["E4 r f# g=lastG trip{b-8 a g} c", "3/4"])
    >>> s = parse("E8 f# g#' G f g# g G#", "2/4")

    

.. function:: parseFile(fp, forceSource=False)

    Given a file path, attempt to parse the file into a Stream. 

.. function:: parseData(dataStr)

    Given musical data represented within a Python string, attempt to parse the data into a Stream. 

.. function:: parseURL(url, forceSource=False)

    Given a URL, attempt to download and parse the file into a Stream. Note: URL downloading will not happen automatically unless the user has set their Environment "autoDownload" preference to "allow". 

.. function:: freeze(streamObj, fp=None)

    Given a file path, attempt to parse the file into a Stream. 

.. function:: unfreeze(fp)

    Given a file path, attempt to parse the file into a Stream. 

Converter
---------



.. class:: Converter()

    A class used for converting all supported data formats into music21 objects. Not a subclass, but a wrapper for different converter objects based on format. 

    **Converter** **properties**

        .. attribute:: stream

            All converters have to have a stream property or attribute. 

    **Converter** **methods**

        .. method:: parseData(dataStr)

            Given raw data, determine format and parse into a music21 Stream. 

        .. method:: parseFile(fp, forceSource=False)

            Given a file path, parse and store a music21 Stream. 

        .. method:: parseURL(url)

            Given a url, download and parse the file into a music21 Stream. Note that this checks the user Environment `autoDownlaad` setting before downloading. 


ConverterMusicXML
-----------------



.. class:: ConverterMusicXML(forceSource)

    Converter for MusicXML 

    **ConverterMusicXML** **properties**

        .. attribute:: stream

            No documentation. 

    **ConverterMusicXML** **methods**

        .. method:: getPartNames()

            No documentation. 

        .. method:: load()

            Load all parts from a MusicXML object representation. This determines the order parts are found in the stream 

        .. method:: parseData(xmlString)

            Open MusicXML data from a string. 

        .. method:: parseFile(fp)

            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. 


ConverterHumdrum
----------------



.. class:: ConverterHumdrum()

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

    **ConverterHumdrum** **attributes**

        Attributes without Documentation: `stream`

    **ConverterHumdrum** **methods**

        .. method:: parseData(humdrumString)

            Open Humdrum data from a string 

            >>> humdata = '**kern\n*M2/4\n=1\n24r\n24g#\n24f#\n24e\n24c#\n24f\n24r\n24dn\n24e-\n24gn\n24e-\n24dn\n*-'
            >>> c = ConverterHumdrum()
            >>> s = c.parseData(humdata)

        .. method:: parseFile(filepath)

            Open Humdram data from a file path. 


ArchiveFilter
-------------



.. class:: ArchiveFilter(fp, format=zip)

    Before opening a file path, this class can check if this is an archived file collection, such as a .zip or or .mxl file. This will return the data from the archive. 

    **ArchiveFilter** **methods**

        .. method:: getData(name=None)

            Return data from the archive by name. If no name is given, a default may be available. 

        .. method:: isArchive()

            Return True or False if the filepath is an archive of the supplied format. 


ConverterMidi
-------------



.. class:: ConverterMidi()

    Simple class wrapper for parsing MIDI. 

    **ConverterMidi** **properties**

        .. attribute:: stream

            No documentation. 

    **ConverterMidi** **methods**

        .. method:: parseData(strData)

            Get MIDI data from a binary string representation. 

        .. method:: parseFile(fp)

            Get MIDI data from a file path. 


ConverterTinyNotation
---------------------



.. class:: ConverterTinyNotation()

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

    **ConverterTinyNotation** **attributes**

        Attributes without Documentation: `stream`

    **ConverterTinyNotation** **methods**

        .. method:: parseData(tnData)

            Open TinyNotation data from a string or list 

            >>> tnData = ["E4 r f# g=lastG trip{b-8 a g} c", "3/4"]
            >>> c = ConverterTinyNotation()
            >>> s = c.parseData(tnData)

        .. method:: parseFile(fp)

            Open TinyNotation data from a file path. 


PickleFilter
------------



.. class:: PickleFilter(fp, forceSource=False)

    Before opening a file path, this class can check if there is an up to date version pickled and stored in the scratch directory. If the user has not specified a scratch directory, a pickle path will not be created. 

    Provide a file path to check if there is pickled version. If forceSource is True, pickled files, if available, will not be returned. 

    **PickleFilter** **methods**

        .. method:: status()

            Given a file path specified with __init__, look for an up to date pickled version of this file path. If it exists, return its fp, other wise return the original file path. Return arguments are file path to load, boolean whether to write a pickle, and the file path of the pickle. 


StreamFreezer
-------------



.. class:: StreamFreezer(streamObj=None)

    This class is used to freeze a Stream, preparing it for pickling. 

    **StreamFreezer** **attributes**

        Attributes without Documentation: `stream`

    **StreamFreezer** **methods**

        .. method:: openPickle(fp)

            For a supplied file path to a pickled stream, unpickle 

        .. method:: writePickle(fp=None)

            For a supplied Stream, write a pickled version. 


