rstmt_core/notes/impls/
impl_note_base.rs1use crate::notes::note_base::NoteBase;
7use crate::octave::Octave;
8use crate::pitch::{Accidental, PitchClass, PitchClassRepr, RawPitchClass};
9
10impl<P, K> NoteBase<P, K>
11where
12 P: RawPitchClass<Tag = K>,
13 K: Accidental,
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 {
24 Self {
25 class: PitchClass::new(),
26 octave,
27 }
28 }
29 pub const fn class(&self) -> &PitchClass<P, K> {
31 &self.class
32 }
33 pub const fn class_mut(&mut self) -> &mut PitchClass<P, K> {
35 &mut self.class
36 }
37 pub const fn octave(&self) -> &Octave {
39 &self.octave
40 }
41 pub const fn octave_mut(&mut self) -> &mut Octave {
43 &mut self.octave
44 }
45 pub fn aspn(&self) -> String {
48 format!("{}.{}", self.class().name(), self.octave().value())
49 }
50}