pub struct CtSong { /* private fields */ }Expand description
A song as its text says: music21’s CTSong.
Implementations§
Source§impl CtSong
impl CtSong
Sourcepub fn parse(text: &str) -> Self
pub fn parse(text: &str) -> Self
A song read from its text: music21’s parse, which keeps the lines
that carry anything, each trimmed.
music21 takes a path as readily as a text, reading the file where
the string holds no | and no S:; the library reads no files, so
this takes the text alone.
Sourcepub fn title(&self) -> String
pub fn title(&self) -> String
The title, which is the first line with its % taken off.
music21 takes every % out of that line rather than the one in
front of it, so a title with a per cent in it loses the sign.
Sourcepub fn comments(&self) -> Vec<Vec<String>>
pub fn comments(&self) -> Vec<Vec<String>>
Every comment of the song but the title, each as music21 lists it: a comment on a rule’s line is that rule’s name and the comment, and one on a line of its own is the comment alone.
Sourcepub fn rules(&self) -> &[CtRule]
pub fn rules(&self) -> &[CtRule]
The rules of the song, in the order the text names them, the S:
rule among them.
Sourcepub fn rule(&self, name: &str) -> Option<&CtRule>
pub fn rule(&self, name: &str) -> Option<&CtRule>
The rule of a name, as music21 keys its rules by the left-hand side.
Sourcepub fn home_time_signature(&self) -> Result<Option<TimeSignature>>
pub fn home_time_signature(&self) -> Result<Option<TimeSignature>>
The meter the song opens in: music21’s homeTimeSig, which reads
the first two atoms of the S: rule – four-four where the first
says no meter and no key, the meter where one says a meter, and
nothing at all where both say a key.
§Errors
A meter the crate cannot read.
Sourcepub fn home_key(&self) -> Result<Option<Key>>
pub fn home_key(&self) -> Result<Option<Key>>
The key the song opens in: music21’s homeKey, read the same way –
C major where the first atom says neither, the key where one says a
key, and nothing where both say a meter.
§Errors
A key the crate cannot read.
Sourcepub fn to_part(&self) -> Result<Stream>
pub fn to_part(&self) -> Result<Stream>
The song as a part: music21’s toPart, which expands the S: rule,
numbers the measures from one and signs the part with the title.
§Errors
Sourcepub fn to_part_with(&self, labels: CtLabels) -> Result<Stream>
pub fn to_part_with(&self, labels: CtLabels) -> Result<Stream>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CtSong
Available on crate feature serde only.
impl<'de> Deserialize<'de> for CtSong
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 CtSong
impl StructuralPartialEq for CtSong
Auto Trait Implementations§
impl Freeze for CtSong
impl RefUnwindSafe for CtSong
impl Send for CtSong
impl Sync for CtSong
impl Unpin for CtSong
impl UnsafeUnpin for CtSong
impl UnwindSafe for CtSong
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