Skip to main content

StreamElement

Enum StreamElement 

Source
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

Source

pub fn music21_classes(&self) -> Vec<&'static str>

music21’s class names of the element, the most particular first, ending with Music21Object.

Source

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

Source

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.

Source

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.

Source

pub fn pitches(&self) -> Vec<Pitch>

Returns all pitches contained by this element, a nested stream’s included.

Source

pub fn as_stream(&self) -> Option<&Stream>

The stream this element is, when it is one.

Source

pub fn is_note_or_chord(&self) -> bool

Whether this element sounds — music21’s .notes, which is notes and chords but not rests.

Source

pub fn transpose(&self, interval: &Interval) -> Result<Self>

Returns a transposed copy.

A key signature moves with the music, as music21’s does; a metre and a tempo do not depend on pitch and are left alone.

Trait Implementations§

Source§

impl Clone for StreamElement

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamElement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for StreamElement

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Barline> for StreamElement

Source§

fn from(value: Barline) -> Self

Converts to this type from the input type.
Source§

impl From<Chord> for StreamElement

Source§

fn from(value: Chord) -> Self

Converts to this type from the input type.
Source§

impl From<ChordSymbol> for StreamElement

Source§

fn from(value: ChordSymbol) -> Self

Converts to this type from the input type.
Source§

impl From<Clef> for StreamElement

Source§

fn from(value: Clef) -> Self

Converts to this type from the input type.
Source§

impl From<Dynamic> for StreamElement

Source§

fn from(value: Dynamic) -> Self

Converts to this type from the input type.
Source§

impl From<Instrument> for StreamElement

Source§

fn from(value: Instrument) -> Self

Converts to this type from the input type.
Source§

impl From<Key> for StreamElement

Source§

fn from(value: Key) -> Self

Converts to this type from the input type.
Source§

impl From<KeySignature> for StreamElement

Source§

fn from(value: KeySignature) -> Self

Converts to this type from the input type.
Source§

impl From<MetricModulation> for StreamElement

Source§

fn from(value: MetricModulation) -> Self

Converts to this type from the input type.
Source§

impl From<MetronomeMark> for StreamElement

Source§

fn from(value: MetronomeMark) -> Self

Converts to this type from the input type.
Source§

impl From<Note> for StreamElement

Source§

fn from(value: Note) -> Self

Converts to this type from the input type.
Source§

impl From<PedalObject> for StreamElement

Source§

fn from(value: PedalObject) -> Self

Converts to this type from the input type.
Source§

impl From<PercussionChord> for StreamElement

Source§

fn from(value: PercussionChord) -> Self

Converts to this type from the input type.
Source§

impl From<RehearsalMark> for StreamElement

Source§

fn from(value: RehearsalMark) -> Self

Converts to this type from the input type.
Source§

impl From<RepeatExpression> for StreamElement

Source§

fn from(value: RepeatExpression) -> Self

Converts to this type from the input type.
Source§

impl From<Rest> for StreamElement

Source§

fn from(value: Rest) -> Self

Converts to this type from the input type.
Source§

impl From<Stream> for StreamElement

Source§

fn from(value: Stream) -> Self

Converts to this type from the input type.
Source§

impl From<StreamElement> for SearchTerm

Source§

fn from(element: StreamElement) -> Self

Converts to this type from the input type.
Source§

impl From<TempoText> for StreamElement

Source§

fn from(value: TempoText) -> Self

Converts to this type from the input type.
Source§

impl From<TextExpression> for StreamElement

Source§

fn from(value: TextExpression) -> Self

Converts to this type from the input type.
Source§

impl From<TimeSignature> for StreamElement

Source§

fn from(value: TimeSignature) -> Self

Converts to this type from the input type.
Source§

impl From<Unpitched> for StreamElement

Source§

fn from(value: Unpitched) -> Self

Converts to this type from the input type.
Source§

impl From<Variant> for StreamElement

Source§

fn from(variant: Variant) -> Self

Converts to this type from the input type.
Source§

impl Serialize for StreamElement

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.