Skip to main content

Harm

Struct Harm 

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

A **harm annotation read: music21’s HarmParser.parse, whose answer is a dictionary of these same parts.

Implementations§

Source§

impl Harm

Source

pub fn parse(token: &str) -> Option<Self>

Reads a **harm token, or nothing where it is not one: music21’s HarmParser.parse, which answers an empty dictionary there.

use music21_rs::humdrum::harm::Harm;

let read = Harm::parse("#IV7b").expect("a harm token");
assert_eq!(read.accidental(), "#");
assert_eq!(read.root(), "IV");
assert_eq!(read.intervals(), Some("7"));
assert_eq!(read.inversion(), Some('b'));
assert_eq!(read.roman_figure(), "#IV65");
assert_eq!(Harm::parse("VIII"), None);
Source

pub fn accidental(&self) -> &str

The accidental written in front of the degree: #, --, or nothing.

Source

pub fn root(&self) -> &str

The degree or special chord: V, ii, Gn, N.

Source

pub fn attribute(&self) -> Option<char>

o for a diminished reading, + for an augmented one.

Source

pub fn intervals(&self) -> Option<&str>

The last of the intervals written over the degree, as music21 keeps them: 7 of V7, AA6 of VAA6, 9 of V79.

Source

pub fn inversion(&self) -> Option<char>

The inversion letter: b for the first inversion, c for the second, d for the third.

Source

pub fn alternative(&self) -> Option<&Harm>

The reading written in brackets beside this one, which the figure says nothing of.

Source

pub fn secondary(&self) -> Option<&Harm>

The degree this one is read in, written after a slash.

Source

pub fn implied(&self) -> bool

Whether the annotator wrote the token in parentheses, meaning the harmony is implied rather than sounded.

Source

pub fn roman_figure(&self) -> String

The figure a RomanNumeral is built from: music21’s convertHarmToRoman.

The inversion letter becomes the figured bass it stands for – a seventh chord’s b is 65 and a triad’s is 6 – a German or French sixth is read as a seventh chord whatever intervals were written, and only the degrees of the secondary functions are carried across, as music21 carries them.

Trait Implementations§

Source§

impl Clone for Harm

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 Harm

Source§

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

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

impl Default for Harm

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Harm

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 Harm

Source§

impl PartialEq for Harm

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 Harm

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 Harm

Auto Trait Implementations§

§

impl Freeze for Harm

§

impl RefUnwindSafe for Harm

§

impl Send for Harm

§

impl Sync for Harm

§

impl Unpin for Harm

§

impl UnsafeUnpin for Harm

§

impl UnwindSafe for Harm

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.