pub struct Note { /* private fields */ }Expand description
A pitched note.
Implementations§
Source§impl Note
impl Note
Sourcepub fn from_name(name: impl AsRef<str>) -> Result<Self>
pub fn from_name(name: impl AsRef<str>) -> Result<Self>
Builds a note from a pitch name such as "C#4" or "E-".
Sourcepub fn from_number(number: FloatType) -> Result<Self>
pub fn from_number(number: FloatType) -> Result<Self>
Builds a note from a pitch-space number, where 60 is middle C.
Sourcepub fn from_pitch(pitch: Pitch) -> Self
pub fn from_pitch(pitch: Pitch) -> Self
Builds a note from an existing Pitch.
Sourcepub fn set_pitch(&mut self, pitch: Pitch)
pub fn set_pitch(&mut self, pitch: Pitch)
Sets the note’s pitch, keeping its duration and notation: music21’s
Note.pitch setter.
Sourcepub fn pitch_name(&self) -> String
pub fn pitch_name(&self) -> String
Returns the pitch name without an octave, such as "C#" or "E-".
Sourcepub fn pitch_name_with_octave(&self) -> String
pub fn pitch_name_with_octave(&self) -> String
Returns the pitch name with an octave when one is set.
Sourcepub fn pitches(&self) -> Vec<Pitch>
pub fn pitches(&self) -> Vec<Pitch>
The note’s one pitch as a list, the shape a chord’s pitches has.
Sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
music21’s fullName: E-flat in octave 4 Quarter Note, with the
duration’s name left out when the note has none.
Sourcepub fn duration(&self) -> Option<&Duration>
pub fn duration(&self) -> Option<&Duration>
Returns the note duration when one has been assigned.
Sourcepub fn set_duration(&mut self, duration: Duration)
pub fn set_duration(&mut self, duration: Duration)
Assigns a duration to the note.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
Returns a copy of this note with the supplied duration.
Sourcepub fn grace_note(&self, appoggiatura: bool) -> Self
pub fn grace_note(&self, appoggiatura: bool) -> Self
This note as a grace note: written as it is, sounding for no time,
music21’s getGrace. A grace note is slashed and takes no time, and
an appoggiatura is unslashed and takes its time from the note it
leans on.
use music21_rs::{Duration, DurationType, Note};
let note = Note::from_name("G4")?.with_duration(Duration::half());
let grace = note.grace_note(false);
let duration = grace.duration().unwrap();
assert_eq!(duration.quarter_length(), 0.0);
assert_eq!(duration.components(), [(DurationType::Half, 0)]);
assert!(duration.grace().unwrap().slash());
assert!(!note.grace_note(true).duration().unwrap().grace().unwrap().slash());Sourcepub fn transpose(&self, interval: &Interval) -> Result<Self>
pub fn transpose(&self, interval: &Interval) -> Result<Self>
Returns this note transposed by the interval, keeping everything but its pitch.
Sourcepub fn beams(&self) -> &Beams
pub fn beams(&self) -> &Beams
The beams joining this note’s flags to its neighbours’: music21’s
beams.
Sourcepub fn set_notehead(&mut self, notehead: Notehead)
pub fn set_notehead(&mut self, notehead: Notehead)
Sets the shape the note head is drawn with.
Sourcepub fn notehead_fill(&self) -> Option<bool>
pub fn notehead_fill(&self) -> Option<bool>
Whether the note head is filled in: Some(true) filled,
Some(false) hollow, None to let the duration decide, which is
music21’s default.
Sourcepub fn set_notehead_fill(&mut self, fill: Option<bool>)
pub fn set_notehead_fill(&mut self, fill: Option<bool>)
Sets whether the note head is filled in.
Sourcepub fn notehead_parenthesis(&self) -> bool
pub fn notehead_parenthesis(&self) -> bool
Whether the note head is written in parentheses.
Sourcepub fn set_notehead_parenthesis(&mut self, parenthesis: bool)
pub fn set_notehead_parenthesis(&mut self, parenthesis: bool)
Sets whether the note head is written in parentheses.
Sourcepub fn stem_direction(&self) -> StemDirection
pub fn stem_direction(&self) -> StemDirection
Which way the stem points.
Sourcepub fn set_stem_direction(&mut self, direction: StemDirection)
pub fn set_stem_direction(&mut self, direction: StemDirection)
Sets which way the stem points.
Sourcepub fn color(&self) -> Option<&str>
pub fn color(&self) -> Option<&str>
The colour the note is written in, if one was said: music21 keeps this on the note’s style.
Sourcepub fn size(&self) -> Option<NoteSize>
pub fn size(&self) -> Option<NoteSize>
How large the note is drawn, where a score says: music21 keeps this
on the note’s style as noteSize.
Sourcepub fn volume(&self) -> Volume
pub fn volume(&self) -> Volume
How loud the note is. music21 makes a volume on first access, so this
answers a default one for a note nobody has marked; see
Self::has_volume_information to tell the two apart.
Sourcepub fn set_volume(&mut self, volume: Option<Volume>)
pub fn set_volume(&mut self, volume: Option<Volume>)
Sets how loud the note is, or clears it.
Sourcepub fn stored_instrument(&self) -> Option<&Instrument>
pub fn stored_instrument(&self) -> Option<&Instrument>
The instrument this one note is played on, over whichever is in force
where it stands: music21’s storedInstrument.
Sourcepub fn set_stored_instrument(&mut self, instrument: Option<Instrument>)
pub fn set_stored_instrument(&mut self, instrument: Option<Instrument>)
Sets the instrument this one note is played on, or clears it.
Sourcepub fn instrument(&self) -> Option<&Instrument>
pub fn instrument(&self) -> Option<&Instrument>
The instrument that plays this note, as far as the note itself can
say: music21’s getInstrument, whose search of the streams around a
note is a question for whoever holds the stream.
Sourcepub fn has_volume_information(&self) -> bool
pub fn has_volume_information(&self) -> bool
Whether a volume was ever set on this note: music21’s
hasVolumeInformation, which asks only whether the object is there
and not whether a velocity was written on it, so a bare
Volume::new() set on a note counts.
Sourcepub fn expressions(&self) -> &[Expression]
pub fn expressions(&self) -> &[Expression]
The fermatas, ornaments and other marks written on the note:
music21’s expressions.
Sourcepub fn expressions_mut(&mut self) -> &mut Vec<Expression>
pub fn expressions_mut(&mut self) -> &mut Vec<Expression>
The same, to be changed.
Whether it is left off the printed page, keeping its place and its
time: music21’s style.hideObjectOnPrint, which a score uses for a
rest that only fills out a voice.
Says whether it is left off the printed page.
Sourcepub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
The name the note is known by, where it has been given one:
music21’s id, when that is a name and not a number of its own
making.
Sourcepub fn articulations(&self) -> &[Articulation]
pub fn articulations(&self) -> &[Articulation]
How the note is played: its accents, staccatos, bowings and
fingerings, music21’s articulations.
Sourcepub fn articulations_mut(&mut self) -> &mut Vec<Articulation>
pub fn articulations_mut(&mut self) -> &mut Vec<Articulation>
The same, to be changed.
Sourcepub fn lyrics_mut(&mut self) -> &mut Vec<Lyric>
pub fn lyrics_mut(&mut self) -> &mut Vec<Lyric>
The syllables sung on this note, for editing in place.
Sourcepub fn lyric(&self) -> Option<String>
pub fn lyric(&self) -> Option<String>
The text of the first verse, with the hyphens of every further verse
joined by newlines: music21’s lyric.
Sourcepub fn set_lyric(&mut self, lyric: Option<&str>) -> Result<()>
pub fn set_lyric(&mut self, lyric: Option<&str>) -> Result<()>
Replaces every lyric with one verse of text, or clears them with
None. Newlines start further verses, and hyphens say where each
syllable falls in its word: music21’s lyric setter.
Sourcepub fn add_lyric(
&mut self,
text: &str,
number: Option<IntegerType>,
apply_raw: bool,
) -> Result<()>
pub fn add_lyric( &mut self, text: &str, number: Option<IntegerType>, apply_raw: bool, ) -> Result<()>
Adds a syllable as a verse: music21’s addLyric.
With no number it becomes the next verse. With one, it replaces
the text of the verse already carrying that number — leaving where
that syllable falls in its word alone, as music21’s plain text
assignment does — and only becomes a new verse when no verse has it.
Hyphens in the text say where the syllable falls in its word unless
apply_raw is set, which takes the text as written.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Note
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Note
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<Note> for PercussionNote
impl From<Note> for PercussionNote
Source§impl From<Note> for StreamElement
impl From<Note> for StreamElement
Source§impl IntoNote for Note
impl IntoNote for Note
Source§fn try_into_note(self) -> Result<Note>
fn try_into_note(self) -> Result<Note>
Source§const FROM_INTEGER_PITCH: bool = false
const FROM_INTEGER_PITCH: bool = false
Source§impl IntoNote for &Note
impl IntoNote for &Note
Source§fn try_into_note(self) -> Result<Note>
fn try_into_note(self) -> Result<Note>
Source§const FROM_INTEGER_PITCH: bool = false
const FROM_INTEGER_PITCH: bool = false
Auto Trait Implementations§
impl Freeze for Note
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnsafeUnpin for Note
impl UnwindSafe for Note
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