pub struct Volume { /* private fields */ }Expand description
How loud a note is: music21’s volume.Volume.
Implementations§
Source§impl Volume
impl Volume
Sourcepub fn merge_attributes(&mut self, other: &Volume)
pub fn merge_attributes(&mut self, other: &Volume)
Takes everything another volume says, the velocity and whether it is
relative: music21’s mergeAttributes.
Sourcepub fn from_velocity(velocity: IntegerType) -> Self
pub fn from_velocity(velocity: IntegerType) -> Self
A volume at a MIDI velocity, 0 to 127, clamped to that range.
Sourcepub fn from_velocity_scalar(scalar: FloatType) -> Result<Self>
pub fn from_velocity_scalar(scalar: FloatType) -> Result<Self>
A volume at a scalar between 0 and 1, clamped to that range.
Sourcepub fn velocity(&self) -> Option<IntegerType>
pub fn velocity(&self) -> Option<IntegerType>
The MIDI velocity, 0 to 127, or None when none was set.
Sourcepub fn set_velocity(&mut self, velocity: Option<IntegerType>)
pub fn set_velocity(&mut self, velocity: Option<IntegerType>)
Sets the MIDI velocity, clamped to 0 through 127, or clears it.
Sourcepub fn velocity_scalar(&self) -> Option<FloatType>
pub fn velocity_scalar(&self) -> Option<FloatType>
The velocity as a scalar between 0 and 1, or None when none was
set.
Sourcepub fn set_velocity_scalar(&mut self, scalar: Option<FloatType>) -> Result<()>
pub fn set_velocity_scalar(&mut self, scalar: Option<FloatType>) -> Result<()>
Sets the velocity from a scalar, clamped to 0 through 1, or
clears it. A value that is not a number is an error, as in music21.
Sourcepub fn velocity_is_relative(&self) -> bool
pub fn velocity_is_relative(&self) -> bool
Whether the velocity shifts the dynamics around it (music21’s default) or fixes the loudness on its own, as a velocity read from a MIDI file does.
Sourcepub fn set_velocity_is_relative(&mut self, relative: bool)
pub fn set_velocity_is_relative(&mut self, relative: bool)
Sets whether the velocity is relative to its context.
Sourcepub fn has_velocity_information(&self) -> bool
pub fn has_velocity_information(&self) -> bool
Whether a velocity was ever set: music21’s hasVolumeInformation on
the note that owns it.
Sourcepub fn realized(&self) -> FloatType
pub fn realized(&self) -> FloatType
The loudness this volume comes to on its own, between 0 and 1:
music21’s realized with no dynamic or articulation context.
Sourcepub fn realized_with(
&self,
dynamic_scalar: Option<FloatType>,
articulation_shift: FloatType,
base_level: FloatType,
clip: bool,
) -> FloatType
pub fn realized_with( &self, dynamic_scalar: Option<FloatType>, articulation_shift: FloatType, base_level: FloatType, clip: bool, ) -> FloatType
The loudness this volume comes to against the dynamic in force and
whatever the articulations add: music21’s getRealized, with the
context search it would do through a stream replaced by its answers.
A relative velocity doubles the scalar range, so 0.5 leaves the base
level alone and 0.7 raises it; an absolute one decides the answer by
itself. The dynamic scales; an articulation shifts, which is why an
accent on a note nobody has marked lifts it rather than doubling it.
clip holds the result inside 0 to 1.
Sourcepub fn realized_dynamic(&self) -> &'static str
pub fn realized_dynamic(&self) -> &'static str
The realized loudness as one of music21’s dynamic marks, ppp
through fff: dynamics.dynamicStrFromDecimal of the realized value.
Sourcepub fn realized_str(&self) -> String
pub fn realized_str(&self) -> String
The realized loudness written out to two places, which is what
music21’s getRealizedStr and cachedRealizedStr answer.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Volume
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Volume
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>,
impl StructuralPartialEq for Volume
Auto Trait Implementations§
impl Freeze for Volume
impl RefUnwindSafe for Volume
impl Send for Volume
impl Sync for Volume
impl Unpin for Volume
impl UnsafeUnpin for Volume
impl UnwindSafe for Volume
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