pub struct TimeSignature {
pub numerator: u16,
pub denominator: u16,
}Expand description
A musical time signature numerator/denominator.
Fields§
§numerator: u16Beats per bar (top number). Must be ≥ 1.
denominator: u16Beat unit as a note value (bottom number): 1, 2, 4, 8, 16, 32… Must be ≥ 1.
Implementations§
Source§impl TimeSignature
impl TimeSignature
Sourcepub const COMMON: TimeSignature
pub const COMMON: TimeSignature
Common time, 4/4.
Sourcepub fn new(numerator: u16, denominator: u16) -> Result<Self, AudioError>
pub fn new(numerator: u16, denominator: u16) -> Result<Self, AudioError>
Construct, validating that both numbers are ≥ 1.
Sourcepub fn ticks_per_beat(self, ppq: u32) -> Result<u32, AudioError>
pub fn ticks_per_beat(self, ppq: u32) -> Result<u32, AudioError>
Ticks in one beat (one denominator-note) at the given PPQ.
Errors if ppq == 0, the signature is malformed, or the denominator
does not divide ppq * 4 evenly (which would lose tick precision).
Sourcepub fn ticks_per_bar(self, ppq: u32) -> Result<u64, AudioError>
pub fn ticks_per_bar(self, ppq: u32) -> Result<u64, AudioError>
Ticks in one full bar at the given PPQ.
Sourcepub fn ticks_to_bbt(
self,
ticks: u64,
ppq: u32,
) -> Result<BarBeatTick, AudioError>
pub fn ticks_to_bbt( self, ticks: u64, ppq: u32, ) -> Result<BarBeatTick, AudioError>
Map an absolute tick position to a (bar, beat, tick) address.
Sourcepub fn bbt_to_ticks(self, pos: BarBeatTick, ppq: u32) -> Result<u64, AudioError>
pub fn bbt_to_ticks(self, pos: BarBeatTick, ppq: u32) -> Result<u64, AudioError>
Map a (bar, beat, tick) address back to an absolute tick position.
Errors if beat is not within the bar or tick overflows a beat.
Trait Implementations§
Source§impl Clone for TimeSignature
impl Clone for TimeSignature
impl Copy for TimeSignature
Source§impl Debug for TimeSignature
impl Debug for TimeSignature
impl Eq for TimeSignature
Source§impl PartialEq for TimeSignature
impl PartialEq for TimeSignature
impl StructuralPartialEq for TimeSignature
Auto Trait Implementations§
impl Freeze for TimeSignature
impl RefUnwindSafe for TimeSignature
impl Send for TimeSignature
impl Sync for TimeSignature
impl Unpin for TimeSignature
impl UnsafeUnpin for TimeSignature
impl UnwindSafe for TimeSignature
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
Mutably borrows from an owned value. Read more