pub struct Stream { /* private fields */ }Expand description
An ordered stream of music, which may hold other streams.
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn with_kind(kind: StreamKind) -> Self
pub fn with_kind(kind: StreamKind) -> Self
Creates an empty stream standing for one of music21’s subclasses.
Sourcepub fn kind(&self) -> StreamKind
pub fn kind(&self) -> StreamKind
Which of music21’s Stream subclasses this stands for.
Sourcepub fn set_kind(&mut self, kind: StreamKind)
pub fn set_kind(&mut self, kind: StreamKind)
Sets which subclass this stands for.
Sourcepub fn from_events(events: impl IntoIterator<Item = StreamEvent>) -> Self
pub fn from_events(events: impl IntoIterator<Item = StreamEvent>) -> Self
Creates a stream from events, sorted by offset.
Sourcepub fn insert(&mut self, offset: FloatType, element: impl Into<StreamElement>)
pub fn insert(&mut self, offset: FloatType, element: impl Into<StreamElement>)
Inserts an element at a quarter-length offset.
Sourcepub fn push(&mut self, element: impl Into<StreamElement>)
pub fn push(&mut self, element: impl Into<StreamElement>)
Appends an element after the current end of the stream.
Sourcepub fn events_mut(&mut self) -> &mut [StreamEvent]
pub fn events_mut(&mut self) -> &mut [StreamEvent]
Returns immutable events in offset order.
Sourcepub fn events(&self) -> &[StreamEvent]
pub fn events(&self) -> &[StreamEvent]
The events in offset order.
Sourcepub fn iter(&self) -> impl Iterator<Item = &StreamEvent>
pub fn iter(&self) -> impl Iterator<Item = &StreamEvent>
Iterates over events in offset order.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many events this stream holds directly, not counting what any nested stream holds.
Sourcepub fn flatten(&self) -> Self
pub fn flatten(&self) -> Self
One timeline with the nesting dissolved: music21’s flatten.
Each nested stream’s offset is added to its contents’, and the streams themselves are gone; everything else comes through in offset order.
Sourcepub fn recurse(&self) -> Vec<(FloatType, &StreamElement)>
pub fn recurse(&self) -> Vec<(FloatType, &StreamElement)>
Every element at its offset from this stream’s start, nested streams
themselves included: music21’s recurse.
Sourcepub fn streams_of_kind(&self, kind: StreamKind) -> Vec<&Stream>
pub fn streams_of_kind(&self, kind: StreamKind) -> Vec<&Stream>
The streams of one kind held directly by this one: music21’s .parts
on a score, .measures on a part, .voices on a measure.
Sourcepub fn notes(&self) -> Vec<(FloatType, StreamElement)>
pub fn notes(&self) -> Vec<(FloatType, StreamElement)>
Every note and chord on the flattened timeline: music21’s
flatten().notes, which leaves rests out.
Sourcepub fn end_offset(&self) -> FloatType
pub fn end_offset(&self) -> FloatType
Returns the maximum event end offset, a nested stream’s own length included.
Sourcepub fn pitches(&self) -> Vec<Pitch>
pub fn pitches(&self) -> Vec<Pitch>
Returns all pitches in timeline order, from nested streams too.
Sourcepub fn key_signature_at(&self, offset: FloatType) -> Option<KeySignature>
pub fn key_signature_at(&self, offset: FloatType) -> Option<KeySignature>
The key signature in force at an offset: the last one written at or before it, anywhere in the nesting.
This is what music21 answers with getContextByClass(KeySignature),
found by looking back along the flattened timeline rather than by
walking the sites an object belongs to.
Sourcepub fn time_signature_at(&self, offset: FloatType) -> Option<TimeSignature>
pub fn time_signature_at(&self, offset: FloatType) -> Option<TimeSignature>
The metre in force at an offset, found the same way.
Sourcepub fn metronome_mark_at(&self, offset: FloatType) -> Option<MetronomeMark>
pub fn metronome_mark_at(&self, offset: FloatType) -> Option<MetronomeMark>
The tempo in force at an offset, found the same way.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Stream
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Stream
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Stream> for StreamElement
impl From<Stream> for StreamElement
Source§impl<'a> IntoIterator for &'a Stream
impl<'a> IntoIterator for &'a Stream
Auto Trait Implementations§
impl Freeze for Stream
impl RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnsafeUnpin for Stream
impl UnwindSafe for Stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more