The workflow module holds the WorkflowManager, which automates several common music analysis patterns for counterpoint. The TemplateWorkflow class is a template for writing new WorkflowManager classes.
Bases: object
Parameters: | pathnames (list of basestring) – A list of pathnames. |
---|
The WorkflowManager automates several common music analysis patterns for counterpoint. Use the WorkflowManager with these four tasks:
Before you analyze, you may wish to use these methods:
You may also treat a WorkflowManager as a container:
>>> wm = WorkflowManager('piece1.mxl', 'piece2.krn')
>>> len(wm)
2
>>> ip = wm[1]
>>> type(ip)
<class 'vis.models.indexed_piece.IndexedPiece'>
Save data from the most recent result of run() to a file.
Parameters: |
|
---|
Returns: | The pathname of the outputted file. |
---|---|
Return type: | unicode |
Raises: | RuntimeError for unrecognized instructions. |
---|---|
Raises: | RuntimeError if run() has never been called. |
Formats:
Import analysis data from long-term storage on a filesystem. This should primarily be used for the u'pieces' instruction, to control when the initial music21 import happens.
Use load() with an instruction other than u'pieces' to load results from a previous analysis run by run().
Note
If one of the files imports as a music21.stream.Opus, the number of pieces and their order will change.
Parameters: |
|
---|---|
Raises: | RuntimeError if the instruction is not recognized. |
Instructions
Note
only u'pieces' is implemented at this time.
Get or set a metadata field. The valid field names are determined by IndexedPiece (refer to the documentation for metadata()).
A metadatum is a salient musical characteristic of a particular piece, and does not change across analyses.
Parameters: |
|
---|---|
Returns: | The value of the requested field or None, if assigning, or if accessing a non-existant field or a field that has not yet been initialized. |
Return type: | |
Raises: | TypeError if field is not a basestring. |
Raises: | AttributeError if accessing an invalid field. |
Raises: | IndexError if index is invalid for this WorkflowManager. |
Create a visualization from the most recent result of run() and save it to a file.
Parameters: |
|
---|---|
Returns: | The pathname of the outputted visualization. |
Return type: | unicode |
Raises: | NotImplementedError if you use the u'LilyPond' instruction. |
Raises: | RuntimeError for unrecognized instructions. |
Raises: | RuntimeError if run() has never been called. |
Raises: | RuntiemError if a call to R encounters a problem. |
Instructions:
Run an experiment’s workflow. Remember to call load() before this method.
Parameters: | instruction (basestring) – The experiment to run (refer to “List of Experiments” below). |
---|---|
Returns: | The result of the experiment. |
Return type: | pandas.Series or pandas.DataFrame |
Raises: | RuntimeError if the instruction is not valid for this WorkflowManager. |
Raises: | RuntimeError if you have not called load(). |
Raises: | ValueError if the voice-pair selection is invalid or unset. |
List of Experiments
Get or set a value related to analysis. The valid values are listed below.
A setting is related to this particular analysis, and is not a salient musical feature of the work itself.
Refer to run() for a list of settings required or used by each experiment.
Parameters: |
|
---|---|
Returns: | The value of the requested field or None, if assigning, or if accessing a non-existant field or a field that has not yet been initialized. |
Return type: | object or None |
Raises: | AttributeError if accessing an invalid field (see valid fields below). |
Raises: | IndexError if index is invalid for this WorkflowManager. |
Raises: | ValueError if index and value are both None. |
Piece-Specific Settings
Pieces do not share these settings.
setting. To avoid running the FilterByOffsetIndexer, set this to 0. setting that will become the quarterLength duration between observed offsets.
filter repeats: If you want to run the FilterByRepeatIndexer, set this setting to True.
voice combinations: If you want to consider certain specific voice combinations, set this setting to a list of a list of iterables. The following value would analyze the highest three voices with each other: '[[0,1,2]]' while this would analyze the every part with the lowest for a four-part piece: '[[0, 3], [1, 3], [2, 3]]'. This should always be a basestring that nominally represents a list (except the special values for 'all' parts at once or 'all pairs').
Shared Settings
All pieces share these settings. The value of index is ignored for shared settings, so it can be anything.