use crate::notes::note_base::NoteBase;
use crate::octave::Octave;
use crate::pitch::{Accidental, PitchClass, PitchClassRepr, RawPitchClass};
impl<P, K> NoteBase<P, K>
where
P: RawPitchClass<Tag = K>,
K: Accidental,
{
pub const fn new(class: PitchClass<P, K>, octave: Octave) -> Self {
Self { class, octave }
}
pub fn from_octave(octave: Octave) -> Self
where
P: PitchClassRepr,
{
Self {
class: PitchClass::new(),
octave,
}
}
pub const fn class(&self) -> &PitchClass<P, K> {
&self.class
}
pub const fn class_mut(&mut self) -> &mut PitchClass<P, K> {
&mut self.class
}
pub const fn octave(&self) -> &Octave {
&self.octave
}
pub const fn octave_mut(&mut self) -> &mut Octave {
&mut self.octave
}
pub fn aspn(&self) -> String {
format!("{}.{}", self.class().name(), self.octave().value())
}
}