pub enum StreamElement {
Show 25 variants
Note(Note),
Chord(Chord),
Rest(Rest),
Stream(Box<Stream>),
Clef(Clef),
Instrument(Box<Instrument>),
KeySignature(KeySignature),
Key(Key),
TimeSignature(TimeSignature),
MetronomeMark(MetronomeMark),
TempoText(TempoText),
TextExpression(TextExpression),
RepeatExpression(RepeatExpression),
Dynamic(Dynamic),
ChordSymbol(ChordSymbol),
Unpitched(Unpitched),
PercussionChord(PercussionChord),
Barline(Barline),
PedalObject(PedalObject),
RehearsalMark(RehearsalMark),
MetricModulation(Box<MetricModulation>),
Break(Break),
Layout(Layout),
TextBox(Box<TextBox>),
Variant(Box<Variant>),
}Expand description
A musical object that can live on a timeline.
Variants§
Note(Note)
A single pitched note.
Chord(Chord)
A chord containing one or more notes.
Rest(Rest)
A silent rest.
Stream(Box<Stream>)
A stream nested inside this one: a part in a score, a measure in a part. Boxed, since a stream holds these by value.
Clef(Clef)
The clef in force from here on.
Instrument(Box<Instrument>)
The instrument playing from here on. Boxed: an instrument is large.
KeySignature(KeySignature)
The key signature in force from here on.
Key(Key)
The key in force from here on: a key signature that also says its
tonic and mode, as music21’s Key is a KeySignature.
TimeSignature(TimeSignature)
The metre in force from here on.
MetronomeMark(MetronomeMark)
The tempo in force from here on.
TempoText(TempoText)
A tempo said in words, Grave or Allegro.
TextExpression(TextExpression)
Words written over or under the staff.
RepeatExpression(RepeatExpression)
A sign or words saying where to go next, Fine or D.C.
Dynamic(Dynamic)
The dynamic in force from here on.
ChordSymbol(ChordSymbol)
A chord named over the music. It holds for the time it has been given and takes none until then.
Unpitched(Unpitched)
A stroke with no pitch.
PercussionChord(PercussionChord)
Several strokes at once.
Barline(Barline)
A barline standing inside a measure rather than at either end of it, where a measure’s own barlines are kept.
PedalObject(PedalObject)
A bounce or a gap in the line of a held pedal, joined by the pedal mark it belongs to.
RehearsalMark(RehearsalMark)
A letter or number marking a place to rehearse from.
MetricModulation(Box<MetricModulation>)
A change of tempo written as one note value becoming another. Boxed: it holds two tempo marks.
Break(Break)
Where a manuscript’s line, page or column breaks.
Layout(Layout)
How the page, a system or a staff is laid out from here on.
TextBox(Box<TextBox>)
Text standing anywhere on a page. Boxed: it carries its style.
Variant(Box<Variant>)
Another reading of the passage starting here, which takes no time itself. Boxed: it holds a stream.
Implementations§
Source§impl StreamElement
impl StreamElement
Sourcepub fn music21_classes(&self) -> Vec<&'static str>
pub fn music21_classes(&self) -> Vec<&'static str>
music21’s class names of the element, the most particular first,
ending with Music21Object.
Sourcepub fn is_instance(&self, class: &str) -> bool
pub fn is_instance(&self, class: &str) -> bool
Whether the element is of a class, by music21’s name for it:
music21’s isinstance by class name.
use music21_rs::{Note, StreamElement};
let note: StreamElement = Note::from_name("C4")?.into();
assert!(note.is_instance("NotRest"));
assert!(note.is_instance("GeneralNote"));
assert!(!note.is_instance("Rest"));Source§impl StreamElement
impl StreamElement
Sourcepub fn duration(&self) -> Option<&Duration>
pub fn duration(&self) -> Option<&Duration>
Returns the assigned duration, if present.
The marks that only say what is in force from a point — a key, a metre, a tempo, a dynamic — have none, as they take no time in music21 either. A chord symbol has one, of no length until it is given the time it holds.
Sourcepub fn quarter_length(&self) -> FloatType
pub fn quarter_length(&self) -> FloatType
Returns the duration in quarter lengths.
A nested stream is as long as its own contents; a mark takes no time; anything else with no duration of its own defaults to a quarter, as music21’s does.
Sourcepub fn pitches(&self) -> Vec<Pitch>
pub fn pitches(&self) -> Vec<Pitch>
Returns all pitches contained by this element, a nested stream’s included.
Sourcepub fn is_note_or_chord(&self) -> bool
pub fn is_note_or_chord(&self) -> bool
Whether this element sounds — music21’s .notes, which is notes and
chords but not rests.
Trait Implementations§
Source§impl Clone for StreamElement
impl Clone for StreamElement
Source§impl Debug for StreamElement
impl Debug for StreamElement
Source§impl<'de> Deserialize<'de> for StreamElement
Available on crate feature serde only.
impl<'de> Deserialize<'de> for StreamElement
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<Barline> for StreamElement
impl From<Barline> for StreamElement
Source§impl From<Chord> for StreamElement
impl From<Chord> for StreamElement
Source§impl From<ChordSymbol> for StreamElement
impl From<ChordSymbol> for StreamElement
Source§fn from(value: ChordSymbol) -> Self
fn from(value: ChordSymbol) -> Self
Source§impl From<Clef> for StreamElement
impl From<Clef> for StreamElement
Source§impl From<Dynamic> for StreamElement
impl From<Dynamic> for StreamElement
Source§impl From<Instrument> for StreamElement
impl From<Instrument> for StreamElement
Source§fn from(value: Instrument) -> Self
fn from(value: Instrument) -> Self
Source§impl From<Key> for StreamElement
impl From<Key> for StreamElement
Source§impl From<KeySignature> for StreamElement
impl From<KeySignature> for StreamElement
Source§fn from(value: KeySignature) -> Self
fn from(value: KeySignature) -> Self
Source§impl From<MetricModulation> for StreamElement
impl From<MetricModulation> for StreamElement
Source§fn from(value: MetricModulation) -> Self
fn from(value: MetricModulation) -> Self
Source§impl From<MetronomeMark> for StreamElement
impl From<MetronomeMark> for StreamElement
Source§fn from(value: MetronomeMark) -> Self
fn from(value: MetronomeMark) -> Self
Source§impl From<Note> for StreamElement
impl From<Note> for StreamElement
Source§impl From<PedalObject> for StreamElement
impl From<PedalObject> for StreamElement
Source§fn from(value: PedalObject) -> Self
fn from(value: PedalObject) -> Self
Source§impl From<PercussionChord> for StreamElement
impl From<PercussionChord> for StreamElement
Source§fn from(value: PercussionChord) -> Self
fn from(value: PercussionChord) -> Self
Source§impl From<RehearsalMark> for StreamElement
impl From<RehearsalMark> for StreamElement
Source§fn from(value: RehearsalMark) -> Self
fn from(value: RehearsalMark) -> Self
Source§impl From<RepeatExpression> for StreamElement
impl From<RepeatExpression> for StreamElement
Source§fn from(value: RepeatExpression) -> Self
fn from(value: RepeatExpression) -> Self
Source§impl From<Rest> for StreamElement
impl From<Rest> for StreamElement
Source§impl From<Stream> for StreamElement
impl From<Stream> for StreamElement
Source§impl From<StreamElement> for SearchTerm
impl From<StreamElement> for SearchTerm
Source§fn from(element: StreamElement) -> Self
fn from(element: StreamElement) -> Self
Source§impl From<TempoText> for StreamElement
impl From<TempoText> for StreamElement
Source§impl From<TextExpression> for StreamElement
impl From<TextExpression> for StreamElement
Source§fn from(value: TextExpression) -> Self
fn from(value: TextExpression) -> Self
Source§impl From<TimeSignature> for StreamElement
impl From<TimeSignature> for StreamElement
Source§fn from(value: TimeSignature) -> Self
fn from(value: TimeSignature) -> Self
Source§impl From<Unpitched> for StreamElement
impl From<Unpitched> for StreamElement
Source§impl From<Variant> for StreamElement
impl From<Variant> for StreamElement
Auto Trait Implementations§
impl Freeze for StreamElement
impl RefUnwindSafe for StreamElement
impl Send for StreamElement
impl Sync for StreamElement
impl Unpin for StreamElement
impl UnsafeUnpin for StreamElement
impl UnwindSafe for StreamElement
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