pub struct Tuplet { /* private fields */ }Expand description
A length written as a tuplet: actual notes in the time of normal,
each side optionally counted in a written value.
This is the naming half of music21’s Tuplet. A Duration here is a
quarter length, so a tuplet is something a length is read as rather
than something a duration carries — what it is for is being able to say
that two thirds of a quarter is a quarter triplet.
Either written value may be unsaid, as music21’s may: a bare triplet is three in the time of two of nothing in particular, and wherever a length is needed an eighth is assumed, which is music21’s basic triplet.
Implementations§
Source§impl Tuplet
impl Tuplet
Sourcepub fn new(
actual: u32,
normal: u32,
duration_type: DurationType,
dots: u32,
) -> Self
pub fn new( actual: u32, normal: u32, duration_type: DurationType, dots: u32, ) -> Self
A tuplet of actual notes of a written value in the time of
normal of them.
Sourcepub fn ratio(actual: u32, normal: u32) -> Self
pub fn ratio(actual: u32, normal: u32) -> Self
actual notes in the time of normal, with neither side counted in
a written value: music21’s Tuplet(actual, normal).
use music21_rs::Tuplet;
let triplet = Tuplet::ratio(3, 2);
assert_eq!(triplet.duration_actual(), None);
assert_eq!(triplet.total_tuplet_length(), 1.0);Sourcepub fn tuplet_type(&self) -> Option<TupletType>
pub fn tuplet_type(&self) -> Option<TupletType>
Where the tuplet’s bracket falls over its notes, where something has
said: music21’s type.
Sourcepub fn set_tuplet_type(&mut self, tuplet_type: Option<TupletType>)
pub fn set_tuplet_type(&mut self, tuplet_type: Option<TupletType>)
Says where the bracket falls.
Sourcepub fn bracket(&self) -> TupletBracket
pub fn bracket(&self) -> TupletBracket
How the bracket is drawn: music21’s bracket.
Sourcepub fn set_bracket(&mut self, bracket: TupletBracket)
pub fn set_bracket(&mut self, bracket: TupletBracket)
Says how the bracket is drawn.
Sourcepub fn placement(&self) -> Option<Placement>
pub fn placement(&self) -> Option<Placement>
Which side of the notes the bracket is drawn: music21’s placement,
above unless something says otherwise.
Sourcepub fn set_placement(&mut self, placement: Option<Placement>)
pub fn set_placement(&mut self, placement: Option<Placement>)
Says which side of the notes the bracket is drawn.
Sourcepub fn actual_show(&self) -> Option<TupletShow>
pub fn actual_show(&self) -> Option<TupletShow>
How the number of notes played is shown: music21’s
tupletActualShow.
Sourcepub fn set_actual_show(&mut self, show: Option<TupletShow>)
pub fn set_actual_show(&mut self, show: Option<TupletShow>)
Says how the number of notes played is shown.
Sourcepub fn normal_show(&self) -> Option<TupletShow>
pub fn normal_show(&self) -> Option<TupletShow>
How the number of notes they stand for is shown: music21’s
tupletNormalShow.
Sourcepub fn set_normal_show(&mut self, show: Option<TupletShow>)
pub fn set_normal_show(&mut self, show: Option<TupletShow>)
Says how the number of notes they stand for is shown.
Sourcepub fn with_normal(self, duration_type: DurationType, dots: u32) -> Self
pub fn with_normal(self, duration_type: DurationType, dots: u32) -> Self
The same tuplet counting the normal side in a different written
value: music21’s durationNormal apart from its durationActual.
Sourcepub fn duration_actual(&self) -> Option<(DurationType, u32)>
pub fn duration_actual(&self) -> Option<(DurationType, u32)>
The written value the actual notes are written as, with its dots,
where one is said: music21’s durationActual.
Sourcepub fn duration_normal(&self) -> Option<(DurationType, u32)>
pub fn duration_normal(&self) -> Option<(DurationType, u32)>
The written value the normal count is counted in, with its dots,
where one is said: music21’s durationNormal.
Sourcepub fn set_duration_actual(&mut self, value: Option<(DurationType, u32)>)
pub fn set_duration_actual(&mut self, value: Option<(DurationType, u32)>)
Says, or unsays, the value the actual notes are written as.
Sourcepub fn set_duration_normal(&mut self, value: Option<(DurationType, u32)>)
pub fn set_duration_normal(&mut self, value: Option<(DurationType, u32)>)
Says, or unsays, the value the normal count is counted in.
Sourcepub fn tuplet_actual(&self) -> (u32, Option<(DurationType, u32)>)
pub fn tuplet_actual(&self) -> (u32, Option<(DurationType, u32)>)
The actual count beside the value it is written in: music21’s
tupletActual.
Sourcepub fn tuplet_normal(&self) -> (u32, Option<(DurationType, u32)>)
pub fn tuplet_normal(&self) -> (u32, Option<(DurationType, u32)>)
The normal count beside the value it is counted in: music21’s
tupletNormal.
Sourcepub fn set_duration_type(&mut self, duration_type: DurationType, dots: u32)
pub fn set_duration_type(&mut self, duration_type: DurationType, dots: u32)
Writes both sides of the tuplet in one value: music21’s
setDurationType.
Sourcepub fn set_ratio(&mut self, actual: u32, normal: u32)
pub fn set_ratio(&mut self, actual: u32, normal: u32)
Changes how many notes are played in the time of how many: music21’s
setRatio.
Sourcepub fn augmented(&self, amount: FloatType) -> Result<Self>
pub fn augmented(&self, amount: FloatType) -> Result<Self>
The same tuplet with both its written values scaled by amount:
music21’s augmentOrDiminish. The ratio stays as it is.
use music21_rs::{DurationType, Tuplet};
let mut sextuplet = Tuplet::ratio(6, 2);
sextuplet.set_duration_type(DurationType::Eighth, 0);
let halved = sextuplet.augmented(0.5)?;
assert_eq!(halved.duration_actual(), Some((DurationType::Sixteenth, 0)));§Errors
An amount that is not greater than nought, or a scaled value no
dotted note value writes.
Sourcepub fn total_tuplet_length(&self) -> FloatType
pub fn total_tuplet_length(&self) -> FloatType
How long the whole tuplet lasts: music21’s totalTupletLength, the
normal count of the value it is counted in.
Sourcepub fn duration_type(&self) -> DurationType
pub fn duration_type(&self) -> DurationType
The note value each one is written as, an eighth where none is said.
Sourcepub fn normal_duration_type(&self) -> DurationType
pub fn normal_duration_type(&self) -> DurationType
The written value the normal count is counted in, an eighth where
none is said.
Sourcepub fn normal_dots(&self) -> u32
pub fn normal_dots(&self) -> u32
The dots on that value.
Sourcepub fn multiplier(&self) -> FractionType
pub fn multiplier(&self) -> FractionType
What the written length is multiplied by inside the tuplet:
music21’s tupletMultiplier, how long the normal side lasts over
how long the actual notes would last unaltered.
use music21_rs::{DurationType, FractionType, Tuplet};
assert_eq!(Tuplet::ratio(3, 2).multiplier(), FractionType::new(2, 3));
// Three quarters in the time of one half.
let written =
Tuplet::new(3, 1, DurationType::Quarter, 0).with_normal(DurationType::Half, 0);
assert_eq!(written.multiplier(), FractionType::new(2, 3));Trait Implementations§
impl Copy for Tuplet
Source§impl<'de> Deserialize<'de> for Tuplet
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Tuplet
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 Eq for Tuplet
impl StructuralPartialEq for Tuplet
Auto Trait Implementations§
impl Freeze for Tuplet
impl RefUnwindSafe for Tuplet
impl Send for Tuplet
impl Sync for Tuplet
impl Unpin for Tuplet
impl UnsafeUnpin for Tuplet
impl UnwindSafe for Tuplet
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