pub struct Lyric { /* private fields */ }Expand description
A syllable of text sung on a note: music21’s note.Lyric.
The hyphens in the written text say where the syllable falls in its word,
which is why Self::from_raw_text reads "-ci-" as a middle syllable
and Self::raw_text writes the hyphens back.
Implementations§
Source§impl Lyric
impl Lyric
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
A lyric on the first verse, spelled as a whole word.
Sourcepub fn unsung() -> Self
pub fn unsung() -> Self
A lyric with nothing sung to it yet, which is music21’s bare
Lyric(): it says nothing about where it falls in a word, and
writing its text does not make it say so.
Sourcepub fn from_raw_text(raw_text: &str) -> Self
pub fn from_raw_text(raw_text: &str) -> Self
Reads a lyric from text whose hyphens say where it falls in its word:
"-ci-" is a middle syllable, "ci-" a beginning, "-us" an end.
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
The syllable without its hyphens.
A composite lyric has no text of its own: it reads as its components
run together, each joined on by its own Self::elision_before.
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Replaces the syllable text, leaving its position in the word alone.
Setting the text of a composite lyric drops its components, which is what music21 does: the text you gave it is now the whole of it.
Sourcepub fn explicit_text(&self) -> Option<String>
pub fn explicit_text(&self) -> Option<String>
The syllable as music21’s text reads it, which may be nothing at
all: music21 starts a lyric off sung to the empty string, and setting
its text to nothing is how a score says the syllable was taken away.
Sourcepub fn clear_text(&mut self)
pub fn clear_text(&mut self)
Takes the text away, leaving a lyric with nothing sung to it at all — which music21 tells apart from one sung to the empty string, and writes out as neither.
Sourcepub fn is_composite(&self) -> bool
pub fn is_composite(&self) -> bool
Whether this lyric is several lyrics sung together rather than one
syllable: music21’s isComposite.
Sourcepub fn components(&self) -> &[Lyric]
pub fn components(&self) -> &[Lyric]
The lyrics this one is made of, empty unless it is composite.
Sourcepub fn set_components(&mut self, components: Vec<Lyric>)
pub fn set_components(&mut self, components: Vec<Lyric>)
Makes this lyric the several lyrics given, run together. An empty list makes it an ordinary one again, keeping the text it had.
Sourcepub fn elision_before(&self) -> &str
pub fn elision_before(&self) -> &str
What joins this syllable to the one before it inside a composite lyric — a space by default, an underscore for an elision.
Sourcepub fn set_elision_before(&mut self, elision: impl Into<String>)
pub fn set_elision_before(&mut self, elision: impl Into<String>)
Sets what joins this syllable to the one before it.
Sourcepub fn number(&self) -> IntegerType
pub fn number(&self) -> IntegerType
The verse number, counting from one.
Sourcepub fn set_number(&mut self, number: IntegerType)
pub fn set_number(&mut self, number: IntegerType)
Sets the verse number, which must be positive as music21 requires. Sets which verse this lyric belongs to.
Any whole number will do, as music21’s own setter allows: its
MusicXML reader numbers a verse 0 when the score named it with
something that is not a number at all, and keeps the name as the
identifier.
Sourcepub fn syllabic(&self) -> Syllabic
pub fn syllabic(&self) -> Syllabic
Where the syllable falls in its word. A composite lyric reads as
Syllabic::Composite whatever it was set to.
Sourcepub fn explicit_syllabic(&self) -> Option<Syllabic>
pub fn explicit_syllabic(&self) -> Option<Syllabic>
The same, where something has actually said it: music21 leaves it unset on a lyric nobody has sung anything to.
Sourcepub fn set_syllabic(&mut self, syllabic: Syllabic)
pub fn set_syllabic(&mut self, syllabic: Syllabic)
Sets where the syllable falls in its word.
Sourcepub fn identifier(&self) -> String
pub fn identifier(&self) -> String
The name this verse goes by, which music21 falls back to the number for when none was given.
Sourcepub fn explicit_identifier(&self) -> Option<&str>
pub fn explicit_identifier(&self) -> Option<&str>
The name this verse was given, and nothing when it goes by its
number. music21’s identifier answers the number itself in that
case, which is a different type, so a caller that cares asks here.
Sourcepub fn set_identifier(&mut self, identifier: Option<String>)
pub fn set_identifier(&mut self, identifier: Option<String>)
Names this verse, or clears the name so the number stands in.
Sourcepub fn raw_text(&self) -> String
pub fn raw_text(&self) -> String
The syllable written with the hyphens its position implies.
A composite lyric takes its hyphens from the ends of the run: the first component decides whether one leads, the last whether one trails.
Sourcepub fn set_raw_text(&mut self, raw_text: &str)
pub fn set_raw_text(&mut self, raw_text: &str)
Reads the syllable and its position out of hyphenated text. Like
Self::set_text, this drops any components.
Sourcepub fn set_text_and_syllabic(&mut self, raw_text: &str, apply_raw: bool)
pub fn set_text_and_syllabic(&mut self, raw_text: &str, apply_raw: bool)
music21’s setTextAndSyllabic: Self::set_raw_text, unless
apply_raw says the hyphens are the text itself. Then nothing about
the word is read out of them and the position stands as it was,
except that a lyric that had said nothing about where it falls is now
a whole word. Either way drops any components.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Lyric
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Lyric
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>,
impl Eq for Lyric
impl StructuralPartialEq for Lyric
Auto Trait Implementations§
impl Freeze for Lyric
impl RefUnwindSafe for Lyric
impl Send for Lyric
impl Sync for Lyric
impl Unpin for Lyric
impl UnsafeUnpin for Lyric
impl UnwindSafe for Lyric
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