[−][src]Struct minstrel::Note
A note, represented as a single positive integer (called it's value
).
A value
of 0 = C0, 1 = Db0 etc.
You can create a Note
by either parsing from a string or directly
inputting a number value:
use minstrel::Note; use std::str::FromStr; // Directly let A0 = Note::new(9); // From a string let Eb100 = Note::from_str("Eb100");
Note
s have a number of useful features. For example, you can easily
transpose one by using the addition or subtraction operators:
use minstrel::Note; let C1 = Note::new(12); assert_eq!(C1 + 5, Note::new(17)); assert_eq!(C1 - 2, Note::new(10));
You can also get the semitone difference between two Note
s just by
subtracting them:
use minstrel::Note; let C0 = Note::new(0); let E0 = Note::new(4); // It doesn't matter which order the notes are in assert_eq!(C0 - E0, 4); assert_eq!(E0 - C0, 4);
Finally, you can call into_iter
on a Note
to iterate over it:
use minstrel::Note; // Prints the chromatic scale for note in Note::new(0).into_iter().take(12) { println!("{}", note); }
Fields
value: usize
Implementations
impl Note
[src]
pub fn new(value: usize) -> Self
[src]
Creates a new Note
with the given value
.
Examples
use minstrel::Note; let C0 = Note::new(0); let F4 = Note::new(53); let Ab5 = Note::new(68);
pub fn disregard_octave(self) -> Self
[src]
Returns a new Note
where the inner value
holds no octave information
i.e. it is constrained between 0 and 11.
Examples
use minstrel::Note; let F = Note::new(53).disregard_octave(); let Ab5 = Note::new(68); let Ab = Ab5.disregard_octave();
Trait Implementations
impl Add<usize> for Note
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, semitones: usize) -> Self::Output
[src]
impl Clone for Note
[src]
impl Copy for Note
[src]
impl Debug for Note
[src]
impl Display for Note
[src]
impl Eq for Note
[src]
impl FromStr for Note
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl IntoIterator for Note
[src]
type Item = Self
The type of the elements being iterated over.
type IntoIter = NoteIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl PartialEq<Note> for Note
[src]
impl StructuralEq for Note
[src]
impl StructuralPartialEq for Note
[src]
impl Sub<Note> for Note
[src]
type Output = usize
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self::Output
[src]
impl Sub<usize> for 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<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
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>,