|
|
@ -17,6 +17,16 @@ pub struct BeatRate {
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
|
|
|
pub struct StaticBeatRate(Duration);
|
|
|
|
pub struct StaticBeatRate(Duration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct TimeSignature {
|
|
|
|
|
|
|
|
initial: StaticTimeSignature,
|
|
|
|
|
|
|
|
changes: BTreeMap<BeatPosition, StaticTimeSignature>,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct StaticTimeSignature {
|
|
|
|
|
|
|
|
numerator: u32,
|
|
|
|
|
|
|
|
denominator: u32,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl StaticBeatRate {
|
|
|
|
impl StaticBeatRate {
|
|
|
|
pub fn from_bpm(bpm: f32) -> Self {
|
|
|
|
pub fn from_bpm(bpm: f32) -> Self {
|
|
|
@ -52,6 +62,20 @@ impl BeatRate {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl StaticTimeSignature {
|
|
|
|
|
|
|
|
pub fn new(numerator: u32, denominator: u32) -> Self {Self {numerator, denominator}}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl From<StaticTimeSignature> for TimeSignature {
|
|
|
|
|
|
|
|
fn from(rhs: StaticTimeSignature) -> Self {
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
|
|
|
initial: rhs,
|
|
|
|
|
|
|
|
changes: BTreeMap::new(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|