[−][src]Struct tune::note::Note
A musical note encapsulating a clearly defined pitch.
The pitch can be derived using the Pitched
impl on the Note
type itself, assuming
standard 440 Hz tuning, or on NoteAtConcertPitch
, given a specific concert pitch.
Implementations
impl Note
[src]
pub fn from_midi_number(midi_number: i32) -> Self
[src]
pub fn from_letter_and_octave(
note_letter: NoteLetter,
octave: impl Into<Octave>
) -> Self
[src]
note_letter: NoteLetter,
octave: impl Into<Octave>
) -> Self
Creates a Note
instance given a NoteLetter
and an octave.
Examples
let a4 = Note::from_midi_number(69); assert_eq!(Note::from_letter_and_octave(NoteLetter::A, 4), a4); assert_eq!(Note::from_letter_and_octave(NoteLetter::A, Octave::from_octave_number(4)), a4); assert_eq!(Note::from_letter_and_octave(NoteLetter::A, HelmholtzOctave::OneLined), a4);
pub fn from_piano_key(piano_key: PianoKey) -> Self
[src]
pub fn midi_number(self) -> i32
[src]
pub fn letter_and_octave(self) -> (NoteLetter, Octave)
[src]
Splits the current note into a NoteLetter
and an Octave
.
Examples
let a4 = Note::from_midi_number(69); assert_eq!(a4.letter_and_octave(), (NoteLetter::A, Octave::from_octave_number(4))); let midi_root = Note::from_midi_number(0); assert_eq!(midi_root.letter_and_octave(), (NoteLetter::C, Octave::from_octave_number(-1)));
pub fn as_piano_key(self) -> PianoKey
[src]
Retrieves the associated PianoKey
assuming standard 12-EDO tuning.
pub fn at_pitch(self, pitched: impl Pitched) -> NoteAtConcertPitch
[src]
Creates a NoteAtConcertPitch
instance with self
sounding at a different pitch.
Examples
use tune::pitch::Pitched; let c4_at_260_hz = NoteLetter::C.in_octave(4).at_pitch(Pitch::from_hz(260.0)); assert_approx_eq!(c4_at_260_hz.pitch().as_hz(), 260.0); let (_note, concert_pitch) = c4_at_260_hz; assert_approx_eq!(concert_pitch.a4_pitch().as_hz(), 437.266136);
pub fn at_concert_pitch(self, concert_pitch: ConcertPitch) -> NoteAtConcertPitch
[src]
Convenience function creating a NoteAtConcertPitch
instance.
Examples
let a4 = NoteLetter::A.in_octave(4); let concert_pitch = ConcertPitch::from_a4_pitch(Pitch::from_hz(435.0)); assert_eq!(a4.at_concert_pitch(concert_pitch), (a4, concert_pitch));
pub fn num_semitones_before(self, other: Note) -> i32
[src]
Counts the number of semitones [left inclusive, right exclusive) between self
and other
.
pub fn plus_semitones(self, num_semitones: i32) -> Note
[src]
Retrieves the Note
instance num_semitones
above self
.
Trait Implementations
impl Clone for Note
[src]
impl Copy for Note
[src]
impl Debug for Note
[src]
impl Display for Note
[src]
Note
s are rendered in scientific pitch notation.
Examples
assert_eq!(Note::from_midi_number(0).to_string(), "C -1"); assert_eq!(Note::from_midi_number(69).to_string(), "A 4"); assert_eq!(Note::from_midi_number(70).to_string(), "A#/Bb 4"); assert_eq!(Note::from_midi_number(71).to_string(), "B 4"); assert_eq!(Note::from_midi_number(72).to_string(), "C 5"); assert_eq!(Note::from_midi_number(127).to_string(), "G 9"); // Format flags assert_eq!(format!("{:+}", Note::from_midi_number(70)), "A# 4"); assert_eq!(format!("{:-}", Note::from_midi_number(70)), "Bb 4"); assert_eq!(format!("{:10}", Note::from_midi_number(70)), "A#/Bb 4 "); assert_eq!(format!("{:<10}", Note::from_midi_number(70)), "A#/Bb 4 "); assert_eq!(format!("{:>10}", Note::from_midi_number(70)), " A#/Bb 4");
impl Eq for Note
[src]
impl Hash for Note
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Note
[src]
fn cmp(&self, other: &Note) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Note> for Note
[src]
impl PartialOrd<Note> for Note
[src]
fn partial_cmp(&self, other: &Note) -> Option<Ordering>
[src]
fn lt(&self, other: &Note) -> bool
[src]
fn le(&self, other: &Note) -> bool
[src]
fn gt(&self, other: &Note) -> bool
[src]
fn ge(&self, other: &Note) -> bool
[src]
impl Pitched for Note
[src]
impl PitchedNote for Note
[src]
fn note(self) -> Note
[src]
fn alter_pitch_by(self, delta: Ratio) -> NoteAtConcertPitch
[src]
impl StructuralEq for Note
[src]
impl StructuralPartialEq for Note
[src]
impl Tuning<Note> for ConcertPitch
[src]
fn pitch_of(&self, note: Note) -> Pitch
[src]
fn find_by_pitch(&self, pitch: Pitch) -> Approximation<Note>
[src]
impl Tuning<Note> for ()
[src]
Convenience implementation enabling to write ()
instead of ConcertPitch
::default()
.
Examples
assert_eq!(Pitch::from_hz(880.0).find_in(&()).approx_value, Note::from_midi_number(81));
fn pitch_of(&self, note_or_address: Note) -> Pitch
[src]
fn find_by_pitch(&self, pitch: Pitch) -> Approximation<Note>
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,