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.
Create a WindowedAnalysis object.
The provided analysisProcessor must provide a process() method that, when given a windowed Stream (a Measure) returns two element tuple containing (a) a data value (implementation dependent) and (b) a color code.
- 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 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.>>> from music21 import * >>> s = corpus.parse('bach/bwv324') >>> p = analysis.discrete.KrumhanslSchmuckler() >>> # placing one part into analysis >>> wa = analysis.windowed.WindowedAnalysis(s.parts, p) >>> x, y, z = wa.process(1, 1, includeTotalWindow=False) >>> len(x) # we only have one series of windows 1>>> y.startswith('#') # for each window, we get a solution and a color True >>> x <music21.pitch.Pitch B>>>> x, y, z = wa.process(1, 2, includeTotalWindow=False) >>> len(x) # we have two series of windows 2>>> x # the data returned is processor dependent; here we get (<music21.pitch.Pitch B>, 'major', 0.6868258874056411) >>> y.startswith('#') # a color is returned for each matching data position True