Skip to main content

CtSong

Struct CtSong 

Source
pub struct CtSong { /* private fields */ }
Expand description

A song as its text says: music21’s CTSong.

Implementations§

Source§

impl CtSong

Source

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.

Source

pub fn text(&self) -> &str

The text as it was read, its blank lines gone.

Source

pub fn lines(&self) -> &[String]

The lines the text was read as.

Source

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.

Source

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.

Source

pub fn rules(&self) -> &[CtRule]

The rules of the song, in the order the text names them, the S: rule among them.

Source

pub fn rule(&self, name: &str) -> Option<&CtRule>

The rule of a name, as music21 keys its rules by the left-hand side.

Source

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.

Source

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.

Source

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

As from_clercq_temperley.

Source

pub fn to_part_with(&self, labels: CtLabels) -> Result<Stream>

The same, saying what to write under the chords.

§Errors

As from_clercq_temperley.

Trait Implementations§

Source§

impl Clone for CtSong

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 CtSong

Source§

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

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

impl Default for CtSong

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CtSong

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 Eq for CtSong

Source§

impl PartialEq for CtSong

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CtSong

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

impl StructuralPartialEq for CtSong

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.