pub struct Dynamic { /* private fields */ }Expand description
A dynamic mark and the loudness it stands for.
use music21_rs::Dynamic;
let forte = Dynamic::new("f");
assert_eq!(forte.volume_scalar(), 0.7);
assert_eq!(forte.long_name(), Some("forte"));
// A mark with no loudness of its own is read without its `s` and `z`.
assert_eq!(Dynamic::new("sfz").volume_scalar(), 0.7);
// A loudness names the mark it falls under and keeps its own value.
let soft = Dynamic::from_scalar(0.4)?;
assert_eq!(soft.value(), "mp");
assert_eq!(soft.volume_scalar(), 0.4);Implementations§
Source§impl Dynamic
impl Dynamic
Sourcepub fn new(value: impl Into<String>) -> Self
pub fn new(value: impl Into<String>) -> Self
A dynamic from its mark. Any text is a mark, as it is upstream; one music21 has no loudness for sounds at the middle of the range.
Sourcepub fn placement(&self) -> Option<Placement>
pub fn placement(&self) -> Option<Placement>
Which side of the staff it is written on, where the score says.
Sourcepub fn set_placement(&mut self, placement: Option<Placement>)
pub fn set_placement(&mut self, placement: Option<Placement>)
Says which side of the staff it is written on.
Sourcepub fn from_scalar(scalar: FloatType) -> Result<Self>
pub fn from_scalar(scalar: FloatType) -> Result<Self>
A dynamic from a loudness between nought and one, named as the mark that loudness falls under and keeping the loudness itself.
Sourcepub fn set_value(&mut self, value: impl Into<String>)
pub fn set_value(&mut self, value: impl Into<String>)
Writes another mark. A loudness a caller gave is kept.
Sourcepub fn long_name(&self) -> Option<&'static str>
pub fn long_name(&self) -> Option<&'static str>
The Italian word for the mark, mezzoforte, where music21 has one.
Sourcepub fn english_name(&self) -> Option<&'static str>
pub fn english_name(&self) -> Option<&'static str>
What the mark means in English, where music21 says.
Sourcepub fn volume_scalar(&self) -> FloatType
pub fn volume_scalar(&self) -> FloatType
The loudness the dynamic stands for, between nought and one:
music21’s volumeScalar.
The one a caller gave, else the mark’s own. A mark with none of its
own is tried again without a leading letter where it has an s in
it and without a closing z, so sfz is as loud as f; failing
that it is the middle of the range.
Sourcepub fn set_volume_scalar(&mut self, scalar: FloatType) -> Result<()>
pub fn set_volume_scalar(&mut self, scalar: FloatType) -> Result<()>
Gives the dynamic a loudness of its own, overriding its mark’s.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Dynamic
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Dynamic
serde only.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 From<Dynamic> for StreamElement
impl From<Dynamic> for StreamElement
impl StructuralPartialEq for Dynamic
Auto Trait Implementations§
impl Freeze for Dynamic
impl RefUnwindSafe for Dynamic
impl Send for Dynamic
impl Sync for Dynamic
impl Unpin for Dynamic
impl UnsafeUnpin for Dynamic
impl UnwindSafe for Dynamic
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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