pub struct Note { /* private fields */ }Expand description
A pitched note.
Implementations§
Source§impl Note
impl Note
Sourcepub fn from_name(name: impl Into<String>) -> Result<Self>
pub fn from_name(name: impl Into<String>) -> 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 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 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 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 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 the next verse: music21’s addLyric. Hyphens in
the text say where the syllable falls in its word unless apply_raw
is set, which takes the text as written.
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.
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 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