Manual¶
This page is a detailed guide for using ms3 for different tasks. It supposes you are working in an interactive Python interpreter such as IPython, Jupyter, Google Colab, or just the console.
Parsing a single score¶
Locate the MuseScore 3 score you want to parse.
Make sure it is uncompressed. i.e. it has the extension
.mscxand not.mscz.Tip
MSCZ files are ZIP files containing the uncompressed MSCX. A later version of ms3 will be able to deal with MSCZ, too.
In the examples, we parse the annotated first page of Giovanni Battista Pergolesi’s influential Stabat Mater. The file is called
stabat.mscxand can be downloaded from here (open link and keyCtrl + Sto save the file or right-click on the link toSave link as...).Import the library.
To parse a single score, we will use the class
ms3.Score. We could import the whole library:>>> import ms3 >>> s = ms3.Score()
or simply import the class:
>>> from ms3 import Score >>> s = Score()
Create a
ms3.Scoreobject.In the example, the MuseScore 3 file is located at
~/ms3/docs/stabat.mscxso we can simply create the object and bind it to the variableslike so:>>> from ms3 import Score >>> s = Score('~/ms3/docs/stabat.mscx')
Inspect the object.
To have a look at the created object we can simply evoke its variable:
>>> s MuseScore file -------------- ~/ms3/docs/stabat.mscx Attached annotations -------------------- 48 labels: staff voice label_type 3 2 dcml 48
Parsing options¶
-
Score.__init__(mscx_src=None, infer_label_types=['dcml'], read_only=False, logger_name='Score', level=None, parser='bs4')[source] - Parameters
mscx_src (
str, optional) – Path to the MuseScore file to be parsed.infer_label_types (
listordict, optional) – Determine which label types are determined automatically. Defaults to [‘dcml’]. Pass[]to infer only main types 0 - 3. Pass ``{‘type_name’: r”^(regular)(Expression)$”} to callms3.Score.new_type().read_only (
bool, optional) – Defaults toFalse, meaning that the parsing is slower and uses more memory in order to allow for manipulations of the score, such as adding and deleting labels. Set toTrueif you’re only extracting information.logger_name (
str, optional) – If you have defined a logger, pass its name. Otherwise, the MSCX filename is used.level ({'W', 'D', 'I', 'E', 'C', 'WARNING', 'DEBUG', 'INFO', 'ERROR', 'CRITICAL'}, optional) – Pass a level name for which (and above which) you want to see log records.
parser ({'bs4'}, optional) – The only XML parser currently implemented is BeautifulSoup 4.