pub struct Note(/* private fields */);
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 for Note
impl AddAssign 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 for Note
impl MulAssign 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 PartialOrd for Note
impl PartialOrd for Note
Source§impl RangeBounds<Note> for Note
impl RangeBounds<Note> for Note
Source§impl RemAssign for Note
impl RemAssign 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 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