Skip to main content

Accidental

Struct Accidental 

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

Symbolic and numerical accidental information for a pitch.

This mirrors the main behavior of Python music21’s music21.pitch.Accidental: a standard accidental has a name, modifier, and semitone alter; names compare by spelling while ordering uses alter.

Implementations§

Source§

impl Accidental

Source

pub fn new(specifier: impl Into<AccidentalSpecifier>) -> Result<Self>

Creates an accidental from a name, modifier, alternate name, unicode symbol, semitone alteration, or another accidental.

Source

pub fn list_names() -> Vec<&'static str>

Returns the standard accidental names known to music21.

Source

pub fn is_valid_name(name: &str) -> bool

Returns whether name is a supported accidental name, modifier, or alternate music21/LilyPond-style accidental name.

Source

pub fn standardize_name(name: &str) -> Result<String>

Converts a supported accidental spelling to its standard music21 name.

Source

pub fn set(&mut self, specifier: impl Into<AccidentalSpecifier>) -> Result<()>

Changes this accidental to a supported accidental.

Source

pub fn set_allowing_non_standard_value( &mut self, specifier: impl Into<AccidentalSpecifier>, ) -> Result<()>

Changes this accidental, preserving non-standard names or alteration values in the same way Python music21’s allowNonStandardValue=True does.

Source

pub fn name(&self) -> &str

Returns the standard or non-standard accidental name.

Source

pub fn set_name(&mut self, name: impl Into<String>) -> Result<()>

Sets the accidental name. Standard names update alter and modifier; non-standard names are preserved without changing them.

Source

pub fn alter(&self) -> FloatType

Returns the semitone alteration from the natural step.

Source

pub fn set_alter(&mut self, alter: FloatType) -> Result<()>

Sets the semitone alteration. Standard values update name and modifier; non-standard values are preserved without changing them.

Source

pub fn modifier(&self) -> &str

Returns the music21 modifier string, such as #, -, ##, or ~.

Source

pub fn set_modifier(&mut self, modifier: impl Into<String>)

Sets the modifier. Unknown modifiers are preserved without changing the name or alteration, matching Python music21.

Source

pub fn unicode(&self) -> String

Returns a unicode representation of the accidental.

Source

pub fn full_name(&self) -> &str

Returns the most complete accidental name. This is currently the same as Self::name, like Python music21.

Source

pub fn is_twelve_tone(&self) -> bool

Returns whether this accidental describes a twelve-tone alteration.

Source

pub fn set_name_independently(&mut self, name: impl Into<String>)

Sets name without updating alter or modifier.

Source

pub fn set_alter_independently(&mut self, alter: FloatType)

Sets alter without updating name or modifier.

Source

pub fn set_modifier_independently(&mut self, modifier: impl Into<String>)

Sets modifier without updating name or alter.

Source

pub fn inherit_display(&mut self, other: &Accidental)

Copies display-related settings from another accidental.

Source

pub fn display_type(&self) -> &'static str

Returns the accidental display type.

Source

pub fn set_display_type(&mut self, value: &str) -> Result<()>

Sets the accidental display type.

Source

pub fn display_status(&self) -> Option<bool>

Returns whether notation processing has decided to display this accidental. None means no decision has been made.

Source

pub fn set_display_status(&mut self, value: Option<bool>)

Sets the display status.

Source

pub fn display_style(&self) -> &'static str

Returns the display style.

Source

pub fn set_display_style(&mut self, value: &str) -> Result<()>

Sets the display style.

Source

pub fn display_size(&self) -> String

Returns the display size.

Source

pub fn set_display_size(&mut self, value: &str) -> Result<()>

Sets the display size.

Source

pub fn display_location(&self) -> &'static str

Returns the display location.

Source

pub fn set_display_location(&mut self, value: &str) -> Result<()>

Sets the display location.

Source

pub fn natural() -> Accidental

Returns a natural accidental.

Source

pub fn flat() -> Accidental

Returns a flat accidental.

Source

pub fn sharp() -> Accidental

Returns a sharp accidental.

Trait Implementations§

Source§

impl Clone for Accidental

Source§

fn clone(&self) -> Accidental

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Accidental

Source§

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

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

impl Default for Accidental

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Accidental

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 Accidental

Source§

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

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

impl From<Accidental> for AccidentalSpecifier

Source§

fn from(value: Accidental) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Accidental

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Accidental

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Accidental

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Accidental

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 TryFrom<&str> for Accidental

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<String> for Accidental

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<f64> for Accidental

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: FloatType) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<i32> for Accidental

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: IntegerType) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<i8> for Accidental

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: i8) -> Result<Self>

Performs the conversion.

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,