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

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.


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')
>>> ksAnalyzer = analysis.discrete.KrumhanslSchmuckler()

placing one part into analysis

>>> sopr =[0]
>>> wa = analysis.windowed.WindowedAnalysis(sopr, ksAnalyzer)
>>> solutions, colors, meta = wa.process(1, 1, includeTotalWindow=False)
>>> len(solutions) # we only have one series of windows
>>> solutions, colors, meta = wa.process(1, 2, includeTotalWindow=False)
>>> len(solutions) # we have two series of windows
>>> solutions[1]
[(<music21.pitch.Pitch B>, 'major', 0.6868...), 
 (<music21.pitch.Pitch B>, 'minor', 0.8308...), 
 (<music21.pitch.Pitch D>, 'major', 0.6868...), 
 (<music21.pitch.Pitch B>, 'minor', 0.8308...),...]
>>> colors[1]
['#ffb5ff', '#9b519b', '#ffd752', '#9b519b', ...]
>>> meta
[{'windowSize': 1}, {'windowSize': 2}]


class music21.analysis.windowed.TestMockProcesor

TestMockProcesor methods


Simply count the number of notes found