From 84acaa74395e7817246997c4242944f0e0a5dd3e Mon Sep 17 00:00:00 2001 From: aprzn Date: Wed, 8 Feb 2023 23:28:17 -0500 Subject: [PATCH] starting time signature code --- src/music.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/music.rs b/src/music.rs index 2f0b89a..f5924c8 100644 --- a/src/music.rs +++ b/src/music.rs @@ -17,6 +17,16 @@ pub struct BeatRate { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] pub struct StaticBeatRate(Duration); +pub struct TimeSignature { + initial: StaticTimeSignature, + changes: BTreeMap, +} + +pub struct StaticTimeSignature { + numerator: u32, + denominator: u32, +} + impl StaticBeatRate { 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 for TimeSignature { + fn from(rhs: StaticTimeSignature) -> Self { + Self { + initial: rhs, + changes: BTreeMap::new(), + } + } +} + + #[cfg(test)] mod tests { use super::*;