Indexers produce an “index” of a symbolic musical score. Each index provides one type of data, and each event in can be attached to a particular moment in the original score. Some indexers produce their index directly from the score, like the NoteRestIndexer, which describes pitches. Others create new information by analyzing another index, like the IntervalIndexer, which describes harmonic intervals between two-part combinations in the score, or the FilterByRepeatIndexer, which removes consecutive identical events, leaving only the first.
Analysis modules that subclass Experimenter, by contrast, produce results that cannot be attached to a moment in a score.
Indexers work only on single IndexedPiece instances. To analyze many IndexedPiece objects together, use an experimenter with an AggregatedPieces object.
This module outlines the Experimenter base class, which helps with transforming time-attached analytic information to other types.
Bases: object
Run an experiment on an IndexedPiece.
Use the “Experimenter.required_indices” attribute to know which Indexer subclasses should be provided to this Experimenter’s constructor. If the list is None or [], use the “Experimenter.required_experiments” attribute to know which Experimenter should be provided to the constructor.
The controllers that deal with indexing data from music21 Score objects.
Bases: object
Create an index of a music21 stream.
Use the requires_score attribute to know whether __init__() requires a list of Part objects. If False, read the documentation to know which indexers’ results it requires.
The name of the indexer, as stored in an IndexedPiece, is the unicode-format version of the class name.
Make a new index of the piece.
Returns: | A list of the new indices. The index of each Series corresponds to the index of the Part or Series used to generate it, as given to the constructor. Each element in each Series is a basestring (unless specified otherwise in a subclass). |
---|---|
Return type: | list of pandas.Series |
For a set of streams, find the offsets at which events begin. Used by mp_indexer.
Parameters: | streams (list of music21.stream.Stream) – A list of Streams in which to find the offsets at which events begin. |
---|---|
Returns: | A list of floating-point numbers representing offsets at which a new event begins in any of the streams. Offsets are sorted from lowest to highest (start to end). |
Return type: | list of float |
When there is more than one event at an offset, call this method to ensure parsing simultaneities.
Example: Transforms this... [[1, 2, 3], [1, 2, 3], [1, 2]] ... into this... [[1, 1, 1], [2, 2, 2], [3, 3]]
Perform the indexation of a part or part combination. This is a module-level function designed to ease implementation of multiprocessing with the MPController module.
If your Indexer has settings, use the indexer_func() to adjust for them.
Parameters: |
|
---|---|
Returns: | The new index where each element is a unicode object and the “index” of the pandas object corresponds to the offset at which each event begins. Index 0 is the argument “pipe_index” unchanged. |
Return type: | 2-tuple with “pipe_index” and pandas.Series or pandas.DataFrame |
Raises: | ValueError, if there are multiple events at an offset in any of the inputted Series. |
Perform the indexation of a part or part combination. This is a module-level function designed to ease implementation of multiprocessing.
If your Indexer has settings, use the indexer_func() to adjust for them.
If an offset has multiple events of the correct type, only the “first” discovered results will be included in the output. This may produce misleading results when, for example, a double-stop was imported as two Note objects in the same Part, rather than as a Chord.
Parameters: |
|
---|---|
Returns: | The “pipe_index” argument and the new index. The new index is a pandas.Series where every element is a unicode object. The Series’ index corresponds to the quarterLength offset of the event in the input Stream. |
Return type: | 2-tuple of any and pandas.Series |