Struct music_theory::theory::note::Note
source · pub struct Note(_);
Expand description
The main note type. Does not take into account enharmonic spelling.
Example:
use music_theory::theory::*;
assert_eq!(Note::new(0), Note::A0);
Implementations§
source§impl Note
impl Note
sourcepub const MAX: Note = _
pub const MAX: Note = _
Biggest valid Note
value.
Example:
use music_theory::theory::*;
assert_eq!(Note::MAX + Note::C3, Note::MAX);
sourcepub const MIN: Note = _
pub const MIN: Note = _
Smallest valid Note
value.
Example:
use music_theory::theory::*;
assert_eq!(Note::MIN.shift_octave(-1), Note::MIN);
sourcepub const ZERO: Note = _
pub const ZERO: Note = _
The zeroth Note
, the same as Note::MIN
.
Example:
use music_theory::theory::*;
assert_eq!(Note::ZERO, Note::MIN);
pub const A0: Note = _
pub const AS0: Note = _
pub const B0: Note = _
pub const C0: Note = _
pub const CS0: Note = _
pub const D0: Note = _
pub const DS0: Note = _
pub const E0: Note = _
pub const F0: Note = _
pub const FS0: Note = _
pub const G0: Note = _
pub const GS0: Note = _
pub const A1: Note = _
pub const AS1: Note = _
pub const B1: Note = _
pub const C1: Note = _
pub const CS1: Note = _
pub const D1: Note = _
pub const DS1: Note = _
pub const E1: Note = _
pub const F1: Note = _
pub const FS1: Note = _
pub const G1: Note = _
pub const GS1: Note = _
pub const A2: Note = _
pub const AS2: Note = _
pub const B2: Note = _
pub const C2: Note = _
pub const CS2: Note = _
pub const D2: Note = _
pub const DS2: Note = _
pub const E2: Note = _
pub const F2: Note = _
pub const FS2: Note = _
pub const G2: Note = _
pub const GS2: Note = _
pub const A3: Note = _
pub const AS3: Note = _
pub const B3: Note = _
pub const C3: Note = _
pub const CS3: Note = _
pub const D3: Note = _
pub const DS3: Note = _
pub const E3: Note = _
pub const F3: Note = _
pub const FS3: Note = _
pub const G3: Note = _
pub const GS3: Note = _
pub const A4: Note = _
pub const AS4: Note = _
pub const B4: Note = _
pub const C4: Note = _
pub const CS4: Note = _
pub const D4: Note = _
pub const DS4: Note = _
pub const E4: Note = _
pub const F4: Note = _
pub const FS4: Note = _
pub const G4: Note = _
pub const GS4: Note = _
pub const A5: Note = _
pub const AS5: Note = _
pub const B5: Note = _
pub const C5: Note = _
pub const CS5: Note = _
pub const D5: Note = _
pub const DS5: Note = _
pub const E5: Note = _
pub const F5: Note = _
pub const FS5: Note = _
pub const G5: Note = _
pub const GS5: Note = _
pub const A6: Note = _
pub const AS6: Note = _
pub const B6: Note = _
pub const C6: Note = _
pub const CS6: Note = _
pub const D6: Note = _
pub const DS6: Note = _
pub const E6: Note = _
pub const F6: Note = _
pub const FS6: Note = _
pub const G6: Note = _
pub const GS6: Note = _
pub const A7: Note = _
pub const AS7: Note = _
pub const B7: Note = _
pub const C7: Note = _
pub const CS7: Note = _
pub const D7: Note = _
pub const DS7: Note = _
pub const E7: Note = _
pub const F7: Note = _
pub const FS7: Note = _
pub const G7: Note = _
pub const GS7: Note = _
pub const A8: Note = _
pub const AS8: Note = _
pub const B8: Note = _
pub const C8: Note = _
pub const CS8: Note = _
pub const D8: Note = _
pub const DS8: Note = _
pub const E8: Note = _
pub const F8: Note = _
pub const FS8: Note = _
pub const G8: Note = _
pub const GS8: Note = _
pub const A9: Note = _
pub const AS9: Note = _
pub const B9: Note = _
pub const C9: Note = _
pub const CS9: Note = _
pub const D9: Note = _
pub const DS9: Note = _
pub const E9: Note = _
pub const F9: Note = _
pub const FS9: Note = _
pub const G9: Note = _
pub const GS9: Note = _
sourcepub fn new(note: u32) -> Self
pub fn new(note: u32) -> Self
Create a new valid note. Will be clamped if nessesary.
Example:
use music_theory::theory::*;
assert_eq!(Note::new(12), Note::A1);
sourcepub fn inside(&self) -> u32
pub fn inside(&self) -> u32
Returns the inner value. You can not set the inner value directly to prevent invalid notes.
Example:
use music_theory::theory::*;
assert_eq!(Note::A2.inside(), 24);
sourcepub fn to_pitch(&self) -> f32
pub fn to_pitch(&self) -> f32
Return the pitch in hertz.
Note::A4
has an inner value of 48 and a pitch of 440 hz.
Example:
use music_theory::theory::*;
assert_eq!(Note::A4.to_pitch(), 440.0);
sourcepub fn to_midi_note(&self) -> u8
pub fn to_midi_note(&self) -> u8
Return the equivalent MIDI note.
Note::A4
has an inner value of 48 and a MIDI note number of 69.
Example:
use music_theory::theory::*;
assert_eq!(Note::A4.to_midi_note(), 69);
Trait Implementations§
source§impl AddAssign<Note> for Note
impl AddAssign<Note> for Note
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moresource§impl AddInterval for Note
impl AddInterval for Note
source§impl GeneratablePartialOrder for Note
impl GeneratablePartialOrder for Note
source§impl MulAssign<Note> for Note
impl MulAssign<Note> for Note
source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the
*=
operation. Read moresource§impl OctaveShiftable for Note
impl OctaveShiftable for Note
source§fn with_octave(self, octave: Octave) -> Note
fn with_octave(self, octave: Octave) -> Note
Have the value with everything the same except change the octave to the given one.
source§fn shift_octave(self, shift: OctaveShift) -> Note
fn shift_octave(self, shift: OctaveShift) -> Note
Have the value with everything the same except shift the octave from the current one with
the given shift.
source§impl Ord for Note
impl Ord for Note
source§impl PartialEq<Note> for Note
impl PartialEq<Note> for Note
source§impl PartialOrd<Note> for Note
impl PartialOrd<Note> 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 RangeBounds<Note> for Note
impl RangeBounds<Note> for Note
1.35.0 · source§fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
fn contains<U>(&self, item: &U) -> boolwhere T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,
source§impl RemAssign<Note> for Note
impl RemAssign<Note> for Note
source§fn rem_assign(&mut self, other: Self)
fn rem_assign(&mut self, other: Self)
Performs the
%=
operation. Read moresource§impl ToEnharmonicNote for Note
impl ToEnharmonicNote for Note
source§fn to_enharmonic_note(self) -> EnharmonicNote
fn to_enharmonic_note(self) -> EnharmonicNote
Take self and return EnharmonicNote.
source§impl ToLetterTry for Note
impl ToLetterTry for Note
impl Copy for Note
impl Eq for Note
impl StructuralEq for Note
impl StructuralPartialEq for Note
Auto Trait Implementations§
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