note_pen/
interval.rs

1/// An interval is the absolute difference in pitch between two notes.
2///
3/// The interval is simply internally the number of half-steps between two notes.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[repr(transparent)]
7pub struct Interval(pub i16);
8
9impl Interval {
10    pub const UNISON: Self = Self(0);
11    pub const MINOR_SECOND: Self = Self(1);
12    pub const MAJOR_SECOND: Self = Self(2);
13    pub const MINOR_THIRD: Self = Self(3);
14    pub const MAJOR_THIRD: Self = Self(4);
15    pub const DIMINISHED_FOURTH: Self = Self(4);
16    pub const PERFECT_FOURTH: Self = Self(5);
17    pub const TRITONE: Self = Self(6);
18    pub const PERFECT_FIFTH: Self = Self(7);
19    pub const AUGMENTED_FIFTH: Self = Self(8);
20    pub const MINOR_SIXTH: Self = Self(8);
21    pub const MAJOR_SIXTH: Self = Self(9);
22    pub const MINOR_SEVENTH: Self = Self(10);
23    pub const MAJOR_SEVENTH: Self = Self(11);
24    pub const OCTAVE: Self = Self(12);
25}