pub struct Note(pub u8);Expand description
A musical note, corresponding to a specific frequency in 12 tone equal temperament space.
Tuple Fields§
§0: u8Implementations§
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);Source§impl Note
impl Note
Sourcepub fn play(&self, velocity: u8) -> PlayNote
pub fn play(&self, velocity: u8) -> PlayNote
Creates a PlayNote element from this note, which can then be used as a Segment.
use redact_composer_core::{elements::PlayNote, timing::Timing, IntoSegment};
use redact_composer_musical::{Note, NoteName::C};
let expected_play_note = PlayNote { note: 60, velocity: 100};
let play_note = Note::from((C, 4)).play(100);
assert_eq!(play_note, expected_play_note);
let segment = play_note.into_segment(0..480);
assert_eq!(segment.element_as::<PlayNote>(), Some(&expected_play_note));
assert_eq!(segment.timing, Timing::from(0..480));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<'de> Deserialize<'de> for Note
impl<'de> Deserialize<'de> for Note
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Note, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Note, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Element for Note
impl Element for Note
Source§fn wrapped_element(&self) -> Option<&(dyn Element + 'static)>
fn wrapped_element(&self) -> Option<&(dyn Element + 'static)>
None.
Source§impl From<Note> for PitchClass
impl From<Note> for PitchClass
Source§fn from(value: Note) -> PitchClass
fn from(value: Note) -> PitchClass
Converts to this type from the input type.
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<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 PartialOrd for Note
impl PartialOrd for Note
Source§impl Serialize for Note
impl Serialize for Note
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§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