rstmt_core/note/
impl_note_base.rs1use super::NoteBase;
7use crate::octave::Octave;
8use crate::pitch::{Accidental, PitchClass, PitchClassRepr, RawAccidental, RawPitchClass};
9
10impl<P, K> NoteBase<P, K>
11where
12 P: RawPitchClass<Tag = K>,
13 K: RawAccidental,
14{
15 pub const fn new(class: PitchClass<P, K>, octave: Octave) -> Self {
17 Self { class, octave }
18 }
19 pub fn from_octave(octave: Octave) -> Self
21 where
22 P: PitchClassRepr,
23 K: Accidental,
24 {
25 Self {
26 class: PitchClass::new(),
27 octave,
28 }
29 }
30 pub const fn class(&self) -> &PitchClass<P, K> {
32 &self.class
33 }
34 pub const fn class_mut(&mut self) -> &mut PitchClass<P, K> {
36 &mut self.class
37 }
38 pub const fn octave(&self) -> &Octave {
40 &self.octave
41 }
42 pub const fn octave_mut(&mut self) -> &mut Octave {
44 &mut self.octave
45 }
46 pub fn aspn(&self) -> String {
49 format!("{}.{}", self.class().name(), self.octave().value())
50 }
51}