Struct redact_composer_musical::Note
source · pub struct Note(pub u8);
Expand description
A musical note, corresponding to a specific frequency in 12 tone equal temperament space.
Tuple Fields§
§0: u8
Implementations§
source§impl Note
impl Note
sourcepub fn pitch_class(&self) -> PitchClass
pub fn pitch_class(&self) -> PitchClass
Returns the note’s PitchClass
.
use redact_composer_musical::{Note, NoteName::C, PitchClass};
assert_eq!(Note::from((C, 4)).pitch_class(), PitchClass(0));
sourcepub fn octave(&self) -> i8
pub fn octave(&self) -> i8
Returns the octave number of this note:
use redact_composer_musical::{Note, NoteName::{B, C}};
assert_eq!(Note::from((C, 0)).octave(), 0);
assert_eq!(Note::from((B, 5)).octave(), 5);
sourcepub fn interval_with(&self, other_note: &Note) -> Interval
pub fn interval_with(&self, other_note: &Note) -> Interval
Returns the interval between this note and another.
use redact_composer_musical::{Interval, Note, NoteName::C};
assert_eq!(Note::from((C, 3)).interval_with(&Note::from((C, 4))), Interval::Octave);
Trait Implementations§
source§impl Add<Interval> for Note
impl Add<Interval> for Note
source§impl AddAssign<Interval> for Note
impl AddAssign<Interval> for Note
source§fn add_assign(&mut self, rhs: Interval)
fn add_assign(&mut self, rhs: Interval)
Performs the
+=
operation. Read moresource§impl From<(PitchClass, i8)> for Note
impl From<(PitchClass, i8)> for Note
source§fn from(value: (PitchClass, i8)) -> Self
fn from(value: (PitchClass, i8)) -> Self
use redact_composer_musical::{Note, NoteName::C, PitchClass};
let c3 = Note::from((PitchClass(0), 4));
assert_eq!(c3, Note(60));
source§impl From<Note> for PitchClass
impl From<Note> for PitchClass
source§impl Ord for Note
impl Ord for Note
source§impl PartialEq<(NoteName, i8)> for Note
impl PartialEq<(NoteName, i8)> for Note
source§impl PartialEq<Note> for (NoteName, i8)
impl PartialEq<Note> for (NoteName, i8)
source§impl PartialEq<PitchClass> for Note
impl PartialEq<PitchClass> for Note
source§fn eq(&self, other: &PitchClass) -> bool
fn eq(&self, other: &PitchClass) -> bool
use redact_composer_musical::{Note, NoteName::C, PitchClass};
assert!(Note::from((C, 3)) == PitchClass::from(C));
source§impl PartialEq for Note
impl PartialEq for Note
source§impl PartialOrd for Note
impl PartialOrd for Note
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<Interval> for Note
impl Sub<Interval> for Note
source§impl SubAssign<Interval> for Note
impl SubAssign<Interval> for Note
source§fn sub_assign(&mut self, rhs: Interval)
fn sub_assign(&mut self, rhs: Interval)
Performs the
-=
operation. Read moreimpl Copy for Note
impl Eq for Note
impl StructuralPartialEq for Note
Auto Trait Implementations§
impl Freeze for Note
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnwindSafe for Note
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more