rstmt_core/traits/
notable.rs1use crate::pitch::{Pitch, Pitches};
6use crate::Octave;
7
8pub trait ASPN {
17 fn aspn(&self) -> String {
18 format!("{}.{}", self.pitch_class(), self.octave())
19 }
20
21 fn octave(&self) -> Octave;
22
23 fn pitch(&self) -> Pitch;
24
25 fn pitch_class(&self) -> Pitches {
26 self.pitch().class()
27 }
28}
29
30pub trait Notable: Copy + Sized + core::fmt::Display {
32 fn pitch(&self) -> Pitch;
34 fn pitch_class(&self) -> Pitches {
36 self.pitch().class()
37 }
38}
39
40impl Notable for Pitch {
45 fn pitch_class(&self) -> Pitches {
46 self.class()
47 }
48
49 fn pitch(&self) -> Pitch {
50 *self
51 }
52}
53
54impl Notable for Pitches {
55 fn pitch_class(&self) -> Pitches {
56 *self
57 }
58
59 fn pitch(&self) -> Pitch {
60 Pitch(self.pitch_class().value())
61 }
62}
63
64impl Notable for crate::Note {
65 fn pitch(&self) -> Pitch {
66 *self.pitch()
67 }
68}
69
70impl Notable for crate::PitchTy {
71 fn pitch(&self) -> Pitch {
72 Pitch(*self)
73 }
74}