Previous topic

music21.analysis.search

Next topic

music21.articulations

Table Of Contents

Table Of Contents

This Page

music21.analysis.windowed

This module describes classes for performing windowed and overlapping windowed analysis. The music21.analysis.windowed.WindowedAnalysis provides a reusable framework for systematic overlapping window analysis at the starting at the level of the quarter note and moving to the size of an entire music21.stream.Stream.

Modular analysis procedures inherit from music21.analysis.discrete.DiscreteAnalysis. The music21.analysis.discrete.KrumhanslSchmuckler (for algorithmic key detection) and music21.analysis.discrete.Ambitus (for pitch range analysis) classes provide examples.

WindowedAnalysis

class music21.analysis.windowed.WindowedAnalysis(streamObj, analysisProcessor)

WindowedAnalysis methods

WindowedAnalysis.process(minWindow=1, maxWindow=1, windowStepSize=1, windowType='overlap', includeTotalWindow=True)

Main method for windowed analysis across one or more window size.

Calls _analyze() for the number of different window sizes to be analyzed.

The minWindow and maxWindow set the range of window sizes in quarter lengths. The windowStepSize parameter determines the increment between these window sizes, in quarter lengths.

If minWindow or maxWindow is None, the largest window size available will be set.

If includeTotalWindow is True, the largest window size will always be added.

>>> s = corpus.parse('bach/bwv324')
>>> p = analysis.discrete.KrumhanslSchmuckler()
>>> # placing one part into analysis
>>> wa = analysis.windowed.WindowedAnalysis(s.parts[0], p)
>>> x, y, z = wa.process(1, 1, includeTotalWindow=False)
>>> len(x) # we only have one series of windows
1
>>> y[0][0].startswith('#') # for each window, we get a solution and a color
True
>>> x[0][0][0] 
<music21.pitch.Pitch B>
>>> x, y, z = wa.process(1, 2, includeTotalWindow=False)
>>> len(x) # we have two series of windows
2
>>> x[0][0] # the data returned is processor dependent; here we get
(<music21.pitch.Pitch B>, 'major', 0.6868258874056411)
>>> y[0][0].startswith('#') # a color is returned for each matching data position
True

TestMockProcesor

class music21.analysis.windowed.TestMockProcesor

TestMockProcesor methods

TestMockProcesor.process(subStream)

Simply count the number of notes found