The model representing data from multiple IndexedPiece instances.
Bases: object
Hold data from multiple IndexedPiece instances.
Parameters: | pieces (list of IndexedPiece) – The IndexedPieces to collect. |
---|
Bases: object
Used internally by AggregatedPieces ... at least for now.
Hold aggregated metadata about the IndexedPieces in an AggregatedPiece. Every list has no duplicate entries.
Get the results of an Experimenter run on all the IndexedPiece objects. You must specify all indexers and experimenters to be run to get the results you want.
The same settings dict will be given to all experiments and indexers.
If you want the results from all IndexedPiece objects separately, provide an empty list as the aggregated_experiments argument.
Either the first analyzer in independent_analyzers should use a music21.stream.Score or you must provide an argument for data that is the output from a previous call to this instance’s get_data() method.
Examples
Run analyzer C then D on each piece individually, then provide a list of those results to Experimenter A then B.
>>> pieces.get_data([A, B], [C, D])
Run analyzer C then D on each piece individually, then return a list of those results.
>>> pieces.get_data([], [C, D])
Run analyzer A then B on the results of a previous get_data() call.
>>> piece.get_data([A, B], [], data=previous_results)
Parameters: |
|
---|
Returns: | Either one DataFrame with all experimental results or a list of DataFrame objects, each with the experimental results for one piece. |
---|---|
Return type: | pandas.DataFrame or list of pandas.Series or pandas.DataFrame |
Raises: | TypeError if the analyzer_cls is invalid or cannot be found. |
---|
Get a metadatum about the IndexedPieces stored in this AggregatedPieces.
If only some of the stored IndexedPieces have had their metadata initialized, this method returns incompelete metadata. Missing data will be represented as None in the list, but it will not appear in date_range unless there are no dates. If you need full metadata, we recommend running an Indexer that requires a Score object on all the IndexedPieces (like vis.analyzers.indexers.noterest.NoteRestIndexer).
Valid fields are:
Parameters: | field (basestring) – The name of the field to be accessed or modified. |
---|
Returns: | The value of the requested field or None, if accessing a non-existant field or a field that has not yet been initialized in the IndexedPieces. |
---|---|
Return type: | object or None |
Raises: | TypeError if field is not a basestring. |
---|
This model represents an indexed and analyzed piece of music.
Bases: object
Hold indexed data from a musical score.
Parameters: |
|
---|---|
Returns: | A new IndexedPiece. |
Return type: |
Get the results of an Experimenter or Indexer run on this IndexedPiece.
Parameters: |
|
---|
Returns: | Results of the analyzer. |
---|---|
Return type: | pandas.DataFrame or list of pandas.Series |
Raises: | TypeError if the analyzer_cls is invalid or cannot be found. |
---|---|
Raises: | RuntimeError if the first analyzer class in analyzer_cls does not use Score objects, and data is None. |
Raises: | OpusWarning if the file imports as a music21.stream.Opus object and known_opus is False. |
Raises: | OpusWarning if known_opus is True but the file does not import as an Opus. |
Note about Opus Objects
Correctly importing Opus objects is a little awkward because we only know a file imports to an Opus after we import it, but an Opus should be treated as multiple IndexedPiece objects.
We recommend you handle Opus objects like this:
Refer to the source code for vis.workflow.WorkflowManager.load() for an example implementation.
Get or set metadata about the piece.
Note
Some metadata fields may not be available for all pieces. The available metadata fields depend on the specific file imported. Unavailable fields return None. We guarantee real values for pathname, title, and parts.
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 (usually a basestring) |
Raises: | TypeError if field is not a basestring. |
Raises: | AttributeError if accessing an invalid field (see valid fields below). |
Metadata Field Descriptions
All fields are taken directly from music21 unless otherwise noted.
Metadata Field | Description |
---|---|
alternativeTitle | A possible alternate title for the piece; e.g. Bruckner’s Symphony No. 8 in C minor is known as “The German Michael.” |
anacrusis | The length of the pick-up measure, if there is one. This is not determined by music21. |
composer | The author of the piece. |
composers | If the piece has multiple authors. |
date | The date that the piece was composed or published. |
localeOfComposition | Where the piece was composed. |
movementName | If the piece is part of a larger work, the name of this subsection. |
movementNumber | If the piece is part of a larger work, the number of this subsection. |
number | Taken from music21. |
opusNumber | Number assigned by the composer to the piece or a group containing it, to help with identification or cataloguing. |
parts | A list of the parts in a multi-voice work. This is determined partially by music21. |
pathname | The filesystem path to the music file encoding the piece. This is not determined by music21. |
title | The title of the piece. This is determined partially by music21. |
Examples
>>> piece = IndexedPiece('a_sibelius_symphony.mei')
>>> piece.metadata('composer')
u'Jean Sibelius'
>>> piece.metadata('date', 1919)
>>> piece.metadata('date')
1919
>>> piece.metadata('parts')
[u'Flute 1', u'Flute 2', u'Oboe 1', u'Oboe 2', u'Clarinet 1', u'Clarinet 2', ... ]
Bases: exceptions.RuntimeWarning
The OpusWarning is raised by IndexedPiece.get_data() when known_opus is False but the file imports as a music21.stream.Opus object, and when known_opus is True but the file does not import as a music21.stream.Opus object.
Internally, the warning is actually raised by IndexedPiece._import_score().