.. _moduleStreamTimespanNode:

music21.stream.timespanNode
===========================

.. WARNING: DO NOT EDIT THIS FILE:
   AUTOMATICALLY GENERATED.
   PLEASE EDIT THE .py FILE DIRECTLY.

.. automodule:: music21.stream.timespanNode

TimespanCollectionNode
----------------------

.. autoclass:: music21.stream.timespanNode.TimespanCollectionNode

.. rubric:: :class:`~music21.stream.timespanNode.TimespanCollectionNode` read/write properties

.. autoattribute:: music21.stream.timespanNode.TimespanCollectionNode.leftChild

.. autoattribute:: music21.stream.timespanNode.TimespanCollectionNode.rightChild

.. rubric:: :class:`~music21.stream.timespanNode.TimespanCollectionNode` methods

.. automethod:: music21.stream.timespanNode.TimespanCollectionNode.debug

.. automethod:: music21.stream.timespanNode.TimespanCollectionNode.getDebugPieces

.. automethod:: music21.stream.timespanNode.TimespanCollectionNode.update

.. rubric:: :class:`~music21.stream.timespanNode.TimespanCollectionNode` instance variables

.. attribute:: TimespanCollectionNode.balance

	
	Gets the difference in heights of the two subtrees rooted on this node.
	
	This attribute is used to help balance the AVL tree.
	
	>>> score = stream.timespans.makeExampleScore()
	>>> tree = stream.timespans.streamToTimespanCollection(score, flatten=True, classList=(note.Note, chord.Chord))
	>>> print(tree._debug())
	<Node: Start:3.0 Indices:(0:5:6:12) Length:{1}>
	L: <Node: Start:1.0 Indices:(0:2:3:5) Length:{1}>
	L: <Node: Start:0.0 Indices:(0:0:2:2) Length:{2}>
	R: <Node: Start:2.0 Indices:(3:3:5:5) Length:{2}>
	R: <Node: Start:5.0 Indices:(6:8:9:12) Length:{1}>
	L: <Node: Start:4.0 Indices:(6:6:8:8) Length:{2}>
	R: <Node: Start:6.0 Indices:(9:9:11:12) Length:{2}>
	R: <Node: Start:7.0 Indices:(11:11:12:12) Length:{1}>
	
	
	This tree has one more depth on the right than on the left
	
	>>> tree._rootNode.balance
	1
	
	
	The leftChild of the rootNote is perfectly balanced, while the rightChild is off by
	one (acceptable).
	
	
	>>> tree._rootNode.leftChild.balance
	0
	
	>>> tree._rootNode.rightChild.balance
	1
	
	
	The rightChild's children are also (acceptably) unbalanced:
	
	
	>>> tree._rootNode.rightChild.leftChild.balance
	0
	
	>>> tree._rootNode.rightChild.rightChild.balance
	1

.. attribute:: TimespanCollectionNode.height

	
	The height of the subtree rooted on this node.
	
	This property is used to help balance the AVL tree.
	
	>>> score = stream.timespans.makeExampleScore()
	>>> tree = stream.timespans.streamToTimespanCollection(score, flatten=True, classList=(note.Note, chord.Chord))
	>>> print(tree._debug())
	<Node: Start:3.0 Indices:(0:5:6:12) Length:{1}>
	L: <Node: Start:1.0 Indices:(0:2:3:5) Length:{1}>
	L: <Node: Start:0.0 Indices:(0:0:2:2) Length:{2}>
	R: <Node: Start:2.0 Indices:(3:3:5:5) Length:{2}>
	R: <Node: Start:5.0 Indices:(6:8:9:12) Length:{1}>
	L: <Node: Start:4.0 Indices:(6:6:8:8) Length:{2}>
	R: <Node: Start:6.0 Indices:(9:9:11:12) Length:{2}>
	R: <Node: Start:7.0 Indices:(11:11:12:12) Length:{1}>
	
	>>> tree._rootNode.height
	3
	
	>>> tree._rootNode.rightChild.height
	2
	
	>>> tree._rootNode.rightChild.rightChild.height
	1
	
	>>> tree._rootNode.rightChild.rightChild.rightChild.height
	0
	

.. attribute:: TimespanCollectionNode.nodeStartIndex

	
	The timespan start index of only those timespans stored in this
	node.
	

.. attribute:: TimespanCollectionNode.nodeStopIndex

	
	The timespan stop index of only those timespans stored in this
	node.
	

.. attribute:: TimespanCollectionNode.payload

	
	A list of Timespans starting at this node's start offset.
	
	Timespans are sorted by their _SortTuple, if they contain an element,
	and otherwise by their stop offset.
	
	::
	
	>>> score = stream.timespans.makeExampleScore()
	>>> tree = stream.timespans.streamToTimespanCollection(score, flatten=True, classList=(note.Note, chord.Chord))
	>>> print(tree._rootNode.debug())
	<Node: Start:3.0 Indices:(0:5:6:12) Length:{1}>
	L: <Node: Start:1.0 Indices:(0:2:3:5) Length:{1}>
	L: <Node: Start:0.0 Indices:(0:0:2:2) Length:{2}>
	R: <Node: Start:2.0 Indices:(3:3:5:5) Length:{2}>
	R: <Node: Start:5.0 Indices:(6:8:9:12) Length:{1}>
	L: <Node: Start:4.0 Indices:(6:6:8:8) Length:{2}>
	R: <Node: Start:6.0 Indices:(9:9:11:12) Length:{2}>
	R: <Node: Start:7.0 Indices:(11:11:12:12) Length:{1}>
	
	::
	
	>>> tree._rootNode.payload
	[<ElementTimespan (3.0 to 4.0) <music21.note.Note F>>]
	
	::
	
	>>> tree._rootNode.leftChild.payload
	[<ElementTimespan (1.0 to 2.0) <music21.note.Note D>>]
	
	::
	
	>>> for x in tree._rootNode.leftChild.rightChild.payload:
	...     x
	...
	<ElementTimespan (2.0 to 3.0) <music21.note.Note E>>
	<ElementTimespan (2.0 to 4.0) <music21.note.Note G>>
	
	::
	
	>>> tree._rootNode.rightChild.payload
	[<ElementTimespan (5.0 to 6.0) <music21.note.Note A>>]
	
	

.. attribute:: TimespanCollectionNode.startOffset

	
	The start offset of this node.
	
	>>> score = stream.timespans.makeExampleScore()
	>>> tree = stream.timespans.streamToTimespanCollection(score, flatten=True, classList=(note.Note, chord.Chord))
	>>> print(tree._rootNode.debug())
	<Node: Start:3.0 Indices:(0:5:6:12) Length:{1}>
	L: <Node: Start:1.0 Indices:(0:2:3:5) Length:{1}>
	L: <Node: Start:0.0 Indices:(0:0:2:2) Length:{2}>
	R: <Node: Start:2.0 Indices:(3:3:5:5) Length:{2}>
	R: <Node: Start:5.0 Indices:(6:8:9:12) Length:{1}>
	L: <Node: Start:4.0 Indices:(6:6:8:8) Length:{2}>
	R: <Node: Start:6.0 Indices:(9:9:11:12) Length:{2}>
	R: <Node: Start:7.0 Indices:(11:11:12:12) Length:{1}>
	
	>>> tree._rootNode.startOffset
	3.0
	
	>>> tree._rootNode.leftChild.startOffset
	1.0
	
	>>> tree._rootNode.rightChild.startOffset
	5.0
	
	

.. attribute:: TimespanCollectionNode.stopOffsetHigh

	
	The highest stop offset of any timespan in any node nof the subtree
	rooted on this node.
	

.. attribute:: TimespanCollectionNode.stopOffsetLow

	
	The lowest stop offset of any timespan in any node of the subtree
	rooted on this node.
	

.. attribute:: TimespanCollectionNode.subTreeStartIndex

	
	The lowest timespan start index of any timespan in any node of the
	subtree rooted on this node.
	

.. attribute:: TimespanCollectionNode.subtreeStopIndex

	
	The highest timespan stop index of any timespan in any node of the
	subtree rooted on this node.
	
