euphony_core/pitch/interval.rs
1new_ratio!(Interval, i64);
2
3#[macro_export]
4macro_rules! named_interval {
5 ($name:ident($n:expr, $d:expr)) => {
6 pub const $name: $crate::pitch::interval::Interval =
7 $crate::pitch::interval::Interval($n, $d);
8 };
9}
10
11named_interval!(UNISON(0, 1));
12named_interval!(OCTAVE(1, 1));
13named_interval!(DOUBLE_OCTAVE(2, 1));
14
15impl core::ops::Neg for Interval {
16 type Output = Self;
17
18 fn neg(self) -> Self {
19 self.as_ratio().neg().into()
20 }
21}
22
23// new_ratio_struct!(AbsoluteInterval, i64);
24
25// impl core::ops::Add<Interval> for AbsoluteInterval {
26// type Output = AbsoluteInterval;
27
28// fn add(self, rhs: Interval) -> Self {
29// self.as_ratio().add(rhs.as_ratio()).into()
30// }
31// }
32
33// impl core::ops::AddAssign<Interval> for AbsoluteInterval {
34// fn add_assign(&mut self, rhs: Interval) {
35// *self = core::ops::Add::add(*self, rhs);
36// }
37// }
38
39// impl core::ops::Sub for AbsoluteInterval {
40// type Output = Interval;
41
42// fn sub(self, rhs: Self) -> Interval {
43// self.as_ratio().sub(rhs.as_ratio()).into()
44// }
45// }
46
47// impl core::ops::Sub<Interval> for AbsoluteInterval {
48// type Output = AbsoluteInterval;
49
50// fn sub(self, rhs: Interval) -> AbsoluteInterval {
51// self.as_ratio().sub(rhs.as_ratio()).into()
52// }
53// }
54
55// impl core::ops::SubAssign<Interval> for AbsoluteInterval {
56// fn sub_assign(&mut self, rhs: Interval) {
57// *self = core::ops::Sub::sub(*self, rhs);
58// }
59// }
60
61// impl core::ops::Div for AbsoluteInterval {
62// type Output = Interval;
63
64// fn div(self, rhs: Self) -> Self::Output {
65// self.as_ratio().div(rhs.as_ratio()).into()
66// }
67// }
68
69// new_ratio_conversions!(AbsoluteInterval, i64);