Skip to main content

Module stream

Module stream 

Source
Expand description

Small ordered timeline container. Music on a timeline: music21’s stream.Stream and the subclasses it nests inside one another.

A Stream is a list of things at quarter-length offsets, and one of those things may be another stream: a score holds parts, a part holds measures, a measure holds voices and notes. Stream::flatten dissolves that nesting into one timeline the way music21’s does, adding each stream’s own offset to its contents’.

What is deliberately not here is music21’s sites. There an object can sit in several streams at once and carry a different offset in each, which is why it needs a back-reference to every stream holding it and why getContextByClass has a graph to walk. A stream here owns what it holds, so the nesting is a tree; asking what key or metre is in force at an offset is then a backwards look through the flattened timeline rather than a search through a graph. That is the same answer for music that is written once, which is all a stream built here can be.

Structs§

Stream
An ordered stream of music, which may hold other streams.
StreamEvent
A timestamped stream item.

Enums§

StreamElement
A musical object that can live on a timeline.
StreamKind
Which of music21’s Stream subclasses a stream stands for.