.. _moduleAnalysis.windowed:

music21.analysis.windowed
=========================

.. WARNING: DO NOT EDIT THIS FILE: AUTOMATICALLY GENERATED.  Edit the .py file directly

.. module:: music21.analysis.windowed

This module describes classes for performing windowed and overlapping windowed analysis. The :class:`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 :class:`music21.stream.Stream`. Modular analysis procedures inherit from :class:`music21.analysis.discrete.DiscreteAnalysis`. The :class:`music21.analysis.discrete.KrumhanslSchmuckler` (for algorithmic key detection) and :class:`music21.analysis.discrete.Ambitus` (for pitch range analysis) classes provide examples. 


WindowedAnalysis
----------------



.. class:: WindowedAnalysis(streamObj, analysisProcessor)


    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. 

    **WindowedAnalysis** **methods**

        .. method:: process(minWindow=1, maxWindow=1, windowStepSize=1, windowType=overlap, includeTotalWindow=True)

            Main method for windowed analysis across one or more window size. Calls :meth:`~music21.analysis.WindowedAnalysis._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 = 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]
            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
            (B, 'major', 0.6868258874056411) 
            >>> y[0][0].startswith('#') # a color is returned for each matching data position
            True 


