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
impl Accidental
Sourcepub fn new(specifier: impl Into<AccidentalSpecifier>) -> Result<Self>
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.
Sourcepub fn list_names() -> Vec<&'static str>
pub fn list_names() -> Vec<&'static str>
Returns the standard accidental names known to music21.
Sourcepub fn is_valid_name(name: &str) -> bool
pub fn is_valid_name(name: &str) -> bool
Returns whether name is a supported accidental name, modifier, or
alternate music21/LilyPond-style accidental name.
Sourcepub fn standardize_name(name: &str) -> Result<String>
pub fn standardize_name(name: &str) -> Result<String>
Converts a supported accidental spelling to its standard music21 name.
Sourcepub fn set(&mut self, specifier: impl Into<AccidentalSpecifier>) -> Result<()>
pub fn set(&mut self, specifier: impl Into<AccidentalSpecifier>) -> Result<()>
Changes this accidental to a supported accidental.
Sourcepub fn set_allowing_non_standard_value(
&mut self,
specifier: impl Into<AccidentalSpecifier>,
) -> Result<()>
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.
Sourcepub fn set_name(&mut self, name: impl Into<String>) -> Result<()>
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.
Sourcepub fn set_alter(&mut self, alter: FloatType) -> Result<()>
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.
Sourcepub fn set_modifier(&mut self, modifier: impl Into<String>)
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.
Sourcepub fn full_name(&self) -> &str
pub fn full_name(&self) -> &str
Returns the most complete accidental name. This is currently the same as
Self::name, like Python music21.
Sourcepub fn is_twelve_tone(&self) -> bool
pub fn is_twelve_tone(&self) -> bool
Returns whether this accidental describes a twelve-tone alteration.
Sourcepub fn set_name_independently(&mut self, name: impl Into<String>)
pub fn set_name_independently(&mut self, name: impl Into<String>)
Sets name without updating alter or modifier.
Sourcepub fn set_alter_independently(&mut self, alter: FloatType)
pub fn set_alter_independently(&mut self, alter: FloatType)
Sets alter without updating name or modifier.
Sourcepub fn set_modifier_independently(&mut self, modifier: impl Into<String>)
pub fn set_modifier_independently(&mut self, modifier: impl Into<String>)
Sets modifier without updating name or alter.
Sourcepub fn inherit_display(&mut self, other: &Accidental)
pub fn inherit_display(&mut self, other: &Accidental)
Copies display-related settings from another accidental.
Sourcepub fn display_type(&self) -> &'static str
pub fn display_type(&self) -> &'static str
Returns the accidental display type.
Sourcepub fn set_display_type(&mut self, value: &str) -> Result<()>
pub fn set_display_type(&mut self, value: &str) -> Result<()>
Sets the accidental display type.
Sourcepub fn display_status(&self) -> Option<bool>
pub fn display_status(&self) -> Option<bool>
Returns whether notation processing has decided to display this
accidental. None means no decision has been made.
Sourcepub fn set_display_status(&mut self, value: Option<bool>)
pub fn set_display_status(&mut self, value: Option<bool>)
Sets the display status.
Sourcepub fn display_style(&self) -> &'static str
pub fn display_style(&self) -> &'static str
Returns the display style.
Sourcepub fn set_display_style(&mut self, value: &str) -> Result<()>
pub fn set_display_style(&mut self, value: &str) -> Result<()>
Sets the display style.
Sourcepub fn display_size(&self) -> String
pub fn display_size(&self) -> String
Returns the display size.
Sourcepub fn set_display_size(&mut self, value: &str) -> Result<()>
pub fn set_display_size(&mut self, value: &str) -> Result<()>
Sets the display size.
Sourcepub fn display_location(&self) -> &'static str
pub fn display_location(&self) -> &'static str
Returns the display location.
Sourcepub fn set_display_location(&mut self, value: &str) -> Result<()>
pub fn set_display_location(&mut self, value: &str) -> Result<()>
Sets the display location.
Sourcepub fn natural() -> Accidental
pub fn natural() -> Accidental
Returns a natural accidental.
Sourcepub fn flat() -> Accidental
pub fn flat() -> Accidental
Returns a flat accidental.
Sourcepub fn sharp() -> Accidental
pub fn sharp() -> Accidental
Returns a sharp accidental.
Trait Implementations§
Source§impl Clone for Accidental
impl Clone for Accidental
Source§fn clone(&self) -> Accidental
fn clone(&self) -> Accidental
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Accidental
impl Debug for Accidental
Source§impl Default for Accidental
impl Default for Accidental
Source§impl<'de> Deserialize<'de> for Accidental
impl<'de> Deserialize<'de> for Accidental
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>,
Source§impl Display for Accidental
impl Display for Accidental
Source§impl From<Accidental> for AccidentalSpecifier
impl From<Accidental> for AccidentalSpecifier
Source§fn from(value: Accidental) -> Self
fn from(value: Accidental) -> Self
Source§impl FromStr for Accidental
impl FromStr for Accidental
Source§impl PartialEq for Accidental
impl PartialEq for Accidental
Source§impl PartialOrd for Accidental
impl PartialOrd for Accidental
Source§impl Serialize for Accidental
impl Serialize for Accidental
Source§impl TryFrom<&str> for Accidental
impl TryFrom<&str> for Accidental
Source§impl TryFrom<String> for Accidental
impl TryFrom<String> for Accidental
Source§impl TryFrom<f64> for Accidental
impl TryFrom<f64> for Accidental
Source§impl TryFrom<i32> for Accidental
impl TryFrom<i32> for Accidental
Auto Trait Implementations§
impl Freeze for Accidental
impl RefUnwindSafe for Accidental
impl Send for Accidental
impl Sync for Accidental
impl Unpin for Accidental
impl UnsafeUnpin for Accidental
impl UnwindSafe for Accidental
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,
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