Table Of Contents

Previous topic

vis

Next topic

experimenters Package

This Page

analyzers Package

analyzers Package

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.

experimenter Module

This module outlines the Experimenter base class, which helps with transforming time-attached analytic information to other types.

class vis.analyzers.experimenter.Experimenter(index, settings=None)[source]

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.

default_settings = None
possible_settings = []
run()[source]

Run an experiment on a piece.

Returns:The result of the experiment. Data is stored uniquely depending on the Experiment.
Return type:pandas.Series or pandas.DataFrame

indexer Module

The controllers that deal with indexing data from music21 Score objects.

class vis.analyzers.indexer.Indexer(score, settings=None)[source]

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.

default_settings = {}
possible_settings = {}
required_score_type = None
run()[source]

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
vis.analyzers.indexer.mpi_unique_offsets(streams)[source]

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
vis.analyzers.indexer.mpi_vert_aligner(events)[source]

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]]

vis.analyzers.indexer.series_indexer(pipe_index, parts, indexer_func)[source]

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:
  • pipe_index (any) – An identifier value for use by the caller.
  • parts (list of pandas.Series) – A list of at least one Series object. Every new event, or change of simlutaneity, will appear in the outputted index. Therefore, the new index will contain at least as many events as the inputted Part or Series with the most events. This is not a DataFrame, since each part will likely have different offsets.
  • indexer_func (function) – This function transforms found events into a unicode object.
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.

vis.analyzers.indexer.stream_indexer(pipe_index, parts, indexer_func, types=None)[source]

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:
  • pipe_index (any) – An identifier value for use by the caller.
  • parts (list of music21.stream.Stream) – A list of at least one Stream object. Every new event, or change of simlutaneity, will appear in the outputted index. Therefore, the new index will contain at least as many events as the inputted Part or Series with the most events.
  • indexer_func (function) – This function transforms found events into a unicode object.
  • types (list of types) – Only objects of a type in this list will be passed to the indexer_func for inclusion in the resulting index.
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