Skip to main content

RomanNumeral

Struct RomanNumeral 

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

A parsed Roman numeral in a key.

Implementations§

Source§

impl RomanNumeral

Source

pub fn analyze(chord: &Chord, key: Key) -> Result<Option<Self>>

Performs functional Roman-numeral analysis in a key.

Source

pub fn analyze_with_root( chord: &Chord, key: Key, root: &Pitch, ) -> Result<Option<Self>>

Performs Roman-numeral analysis using an explicit harmonic root.

This is useful for pitch-class-set browser views where the caller has already chosen a transposition root and does not want inversion or root inference to pick a different chord member.

Source§

impl RomanNumeral

Source

pub fn to_chord(&self) -> Result<Chord>

The chord the numeral stands for, spelled where its key sounds.

This is music21’s _updatePitches, and it is a figured-bass reading rather than a stack of intervals: the bass is the scale degree the inversion figure puts there, every number of the column is that many scale steps above it, and only then is the result respelled to the quality the numeral’s case and symbols asked for. Reading it off the scale is what lets a numeral mean something in a mode, and what makes V7b5 alter one note rather than name a different chord.

Source§

impl RomanNumeral

Source

pub fn new(figure: impl Into<String>, key: Key) -> Result<Self>

Parses a Roman numeral figure in a key.

Supports ordinary figures such as V7/V and augmented-sixth figures such as It+6, Fr+6, Ger+6, and Sw+6.

Source

pub fn with_minor_defaults( figure: impl Into<String>, key: Key, sixth_minor: Minor67Default, seventh_minor: Minor67Default, ) -> Result<Self>

The same, saying how the sixth and seventh degrees of a minor key are to be read: music21’s sixthMinor and seventhMinor.

Source

pub fn with_options( figure: impl Into<String>, key: Key, sixth_minor: Minor67Default, seventh_minor: Minor67Default, case_matters: bool, ) -> Result<Self>

The same again, saying whether the case of the numeral states the chord’s quality: music21’s caseMatters.

Source

pub fn over_scale( figure: impl Into<String>, key: Key, scale: Option<Scale>, sixth_minor: Minor67Default, seventh_minor: Minor67Default, case_matters: bool, ) -> Result<Self>

The same again over a scale that is not a key: music21’s numerals read against a ConcreteScale.

The key is still needed — a numeral reports one, and a secondary numeral establishes one — so pass the major key of the scale’s tonic, which is what music21 falls back on.

Source

pub fn bracketed_alterations(&self) -> &[(i8, u8)]

The alterations written in square brackets, as the semitones each moves its chord step by and the step it moves.

Source

pub fn omitted_steps(&self) -> &[u8]

The chord steps the figure leaves out, as [no3].

Source

pub fn added_steps(&self) -> &[(i8, u8)]

The notes the figure puts in beside the chord, as [add4]: the alteration in semitones and how far above the root each stands.

Source

pub fn scale(&self) -> Option<&Scale>

The scale the figure is read over, where it is not a key at all.

A numeral read this way spells its chord where the scale stands, so nothing downstream has to place it.

Source

pub fn implied_quality(&self) -> ImpliedQuality

The quality the figure states, which is what the notes read off the scale are respelled to.

Source

pub fn figure_numbers(&self) -> Vec<u8>

The numbers of the figured-bass column the figure’s digits stand for, written high to low and expanded out of music21’s shorthand.

Source

pub fn case_matters(&self) -> bool

Whether the case of the numeral states the chord’s quality.

Source

pub fn sixth_minor(&self) -> Minor67Default

How this numeral reads the sixth degree of a minor key.

Source

pub fn seventh_minor(&self) -> Minor67Default

How it reads the seventh.

Source

pub fn figures_written(&self) -> &str

Returns the original figure. The digits written under the numeral, as music21’s figuresWritten: the figure with the numeral, its accidental and its quality symbol taken off it, and nothing expanded.

Source

pub fn figures_notation(&self) -> &Notation

The figured-bass column the numeral’s digits stand for, expanded out of the shorthand they were written in: music21’s figuresNotationObj.

Source

pub fn figure(&self) -> &str

The figure the numeral was written with, as given: music21’s figure.

Source

pub fn degree(&self) -> u8

Returns the one-based scale degree.

Source

pub fn written_accidental(&self) -> i8

Returns the chromatic alteration of the scale degree in semitones.

Negative values are flats and positive values are sharps, so bII returns -1 and #iv returns 1.

Source

pub fn accidental(&self) -> i8

The alteration the numeral reports, once the sixth and seventh degrees of a minor key have been read against the chord asked for.

Source

pub fn inversion(&self) -> u8

Returns the inversion number, where root position is 0.

Source

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

Returns the secondary/applied target figure, if any.

Source

pub fn key(&self) -> &Key

Returns the key context.

Source

pub fn roman_numeral(&self) -> String

The numeral with its front alteration and nothing else: music21’s romanNumeral, so bII6 is bII and V65/V is V. An augmented sixth answers its nationality, It, Fr, Ger or Sw.

Source

pub fn roman_numeral_alone(&self) -> String

The numeral with nothing written in front of it: music21’s romanNumeralAlone, so bVII65/V is VII.

Source

pub fn figure_and_key(&self) -> String

The figure and its key together: music21’s figureAndKey, bII6 in a minor.

Source

pub fn scale_degree_with_alteration(&self) -> (u8, i8)

The scale degree with the alteration in front of it, as sharps (positive) or flats (negative): music21’s scaleDegreeWithAlteration.

Source

pub fn functionality_score(&self) -> u8

How strongly the figure implies its function, from music21’s functionalityScores table: I is 100, V7 80, an unknown figure 0. A secondary figure multiplies the scores of its halves. An augmented sixth is looked up by music21’s spelling, It6 rather than the It+6 this crate writes.

Source

pub fn is_neapolitan(&self, require_first_inversion: bool) -> bool

Whether this is a Neapolitan chord: a major triad on the flattened second degree, in first inversion unless require_first_inversion is off.

Source

pub fn is_mixture(&self, evaluate_secondary: bool) -> Result<bool>

Whether the chord is borrowed from the parallel mode: music21’s isMixture, so iv and bVI in a major key are mixture and IV in a minor key is. With evaluate_secondary a secondary figure is judged by the numeral after the slash.

Source

pub fn transpose(&self, interval: &Interval) -> Result<Self>

The same figure in the key transposed by interval.

Source

pub fn effective_key_of(&self) -> Result<Key>

The key the figure is actually read in: the key it was given, or the one a secondary numeral establishes — the V of V/V in G major is read in D major.

Trait Implementations§

Source§

impl Clone for RomanNumeral

Source§

fn clone(&self) -> RomanNumeral

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 RomanNumeral

Source§

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

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

impl<'de> Deserialize<'de> for RomanNumeral

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 Display for RomanNumeral

Source§

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

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

impl Serialize for RomanNumeral

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

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.