Enum wmidi::Note[][src]

#[repr(u8)]
pub enum Note {
Show variants CMinus1, DbMinus1, DMinus1, EbMinus1, EMinus1, FMinus1, GbMinus1, GMinus1, AbMinus1, AMinus1, BbMinus1, BMinus1, C0, Db0, D0, Eb0, E0, F0, Gb0, G0, Ab0, A0, Bb0, B0, C1, Db1, D1, Eb1, E1, F1, Gb1, G1, Ab1, A1, Bb1, B1, C2, Db2, D2, Eb2, E2, F2, Gb2, G2, Ab2, A2, Bb2, B2, C3, Db3, D3, Eb3, E3, F3, Gb3, G3, Ab3, A3, Bb3, B3, C4, Db4, D4, Eb4, E4, F4, Gb4, G4, Ab4, A4, Bb4, B4, C5, Db5, D5, Eb5, E5, F5, Gb5, G5, Ab5, A5, Bb5, B5, C6, Db6, D6, Eb6, E6, F6, Gb6, G6, Ab6, A6, Bb6, B6, C7, Db7, D7, Eb7, E7, F7, Gb7, G7, Ab7, A7, Bb7, B7, C8, Db8, D8, Eb8, E8, F8, Gb8, G8, Ab8, A8, Bb8, B8, C9, Db9, D9, Eb9, E9, F9, Gb9, G9,
}
Expand description

A midi note.

The format for the enum is $NOTE $MODIFIER? $OCTAVE. Note can be a note from A to G. Modifier can be b for flat or Sharp for sharp. Octave is the number. The octave -1 is represented as Minus1.

Example

use wmidi::Note;
let ab7_chord = [Note::AbMinus1, Note::C4, Note::Gb4]; // We omit the 5th for a jazzier sound
let dmaj_chord = [Note::D2, Note::FSharp3, Note::A3];
assert_eq!(u8::from(Note::C3), 48u8);
assert_eq!(Note::from_u8_lossy(48), Note::C3);

Variants

CMinus1
DbMinus1
DMinus1
EbMinus1
EMinus1
FMinus1
GbMinus1
GMinus1
AbMinus1
AMinus1
BbMinus1
BMinus1
C0
Db0
D0
Eb0
E0
F0
Gb0
G0
Ab0
A0
Bb0
B0
C1
Db1
D1
Eb1
E1
F1
Gb1
G1
Ab1
A1
Bb1
B1
C2
Db2
D2
Eb2
E2
F2
Gb2
G2
Ab2
A2
Bb2
B2
C3
Db3
D3
Eb3
E3
F3
Gb3
G3
Ab3
A3
Bb3
B3
C4
Expand description

Middle C.

Db4
D4
Eb4
E4
F4
Gb4
G4
Ab4
A4
Expand description

A440.

Bb4
B4
C5
Db5
D5
Eb5
E5
F5
Gb5
G5
Ab5
A5
Bb5
B5
C6
Db6
D6
Eb6
E6
F6
Gb6
G6
Ab6
A6
Bb6
B6
C7
Db7
D7
Eb7
E7
F7
Gb7
G7
Ab7
A7
Bb7
B7
C8
Db8
D8
Eb8
E8
F8
Gb8
G8
Ab8
A8
Bb8
B8
C9
Db9
D9
Eb9
E9
F9
Gb9
G9

Implementations

impl Note[src]

pub const CSharpMinus1: Note[src]

pub const DSharpMinus1: Note[src]

pub const FSharpMinus1: Note[src]

pub const GSharpMinus1: Note[src]

pub const ASharpMinus1: Note[src]

pub const CSharp0: Note[src]

pub const DSharp0: Note[src]

pub const FSharp0: Note[src]

pub const GSharp0: Note[src]

pub const ASharp0: Note[src]

pub const CSharp1: Note[src]

pub const DSharp1: Note[src]

pub const FSharp1: Note[src]

pub const GSharp1: Note[src]

pub const ASharp1: Note[src]

pub const CSharp2: Note[src]

pub const DSharp2: Note[src]

pub const FSharp2: Note[src]

pub const GSharp2: Note[src]

pub const ASharp2: Note[src]

pub const CSharp3: Note[src]

pub const DSharp3: Note[src]

pub const FSharp3: Note[src]

pub const GSharp3: Note[src]

pub const ASharp3: Note[src]

pub const CSharp4: Note[src]

pub const DSharp4: Note[src]

pub const FSharp4: Note[src]

pub const GSharp4: Note[src]

pub const ASharp4: Note[src]

pub const CSharp5: Note[src]

pub const DSharp5: Note[src]

pub const FSharp5: Note[src]

pub const GSharp5: Note[src]

pub const ASharp5: Note[src]

pub const CSharp6: Note[src]

pub const DSharp6: Note[src]

pub const FSharp6: Note[src]

pub const GSharp6: Note[src]

pub const ASharp6: Note[src]

pub const CSharp7: Note[src]

pub const DSharp7: Note[src]

pub const FSharp7: Note[src]

pub const GSharp7: Note[src]

pub const ASharp7: Note[src]

pub const CSharp8: Note[src]

pub const DSharp8: Note[src]

pub const FSharp8: Note[src]

pub const GSharp8: Note[src]

pub const ASharp8: Note[src]

pub const CSharp9: Note[src]

pub const DSharp9: Note[src]

pub const FSharp9: Note[src]

pub const LOWEST_NOTE: Note[src]

The lowest representable note.

pub const HIGHEST_NOTE: Note[src]

The highest representable note.

pub unsafe fn from_u8_unchecked(note: u8) -> Note[src]

Creates a note from a u8. note must be between [0, 127] inclusive to create a valid note.

Example

 let parsed_note = 60;
 let note = unsafe { wmidi::Note::from_u8_unchecked(parsed_note) };

Safety

note must be less than or equal to 127.

pub fn from_u8_lossy(note: u8) -> Note[src]

Create a note from a u8. Only the 7 least significant bits of note are used.

pub fn to_freq_f32(self) -> f32[src]

The frequency using the standard 440Hz tuning.

Example

let note = wmidi::Note::A3;
sing(note.to_freq_f32());

pub fn to_freq_f64(self) -> f64[src]

The frequency using the standard 440Hz tuning.

Example

let note = wmidi::Note::A3;
sing(note.to_freq_f64());

pub fn step(self, half_steps: i8) -> Result<Note, Error>[src]

Get the note relative to self.

Example

use wmidi::Note;
fn minor_chord(root: Note) -> Result<[Note; 3], wmidi::Error> {
    Ok([root, root.step(3)?, root.step(7)?])
}
assert_eq!(minor_chord(Note::C2), Ok([Note::C2, Note::Eb2, Note::G2]));

pub fn to_str(self) -> &'static str[src]

Get a str representation of the note. For example: "C3" or "A#/Bb2".

Trait Implementations

impl Clone for Note[src]

fn clone(&self) -> Note[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Note[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Display for Note[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<U7> for Note[src]

fn from(note: U7) -> Note[src]

Performs the conversion.

impl Hash for Note[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for Note[src]

fn cmp(&self, other: &Note) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Note> for Note[src]

fn eq(&self, other: &Note) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<Note> for Note[src]

fn partial_cmp(&self, other: &Note) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl TryFrom<u8> for Note[src]

Convert from a u8 to a Note. The u8 must be in the range [0, 127] inclusive.

fn try_from(note: u8) -> Result<Note, Error>[src]

Creates a note from a u8. note must be between [0, 127] inclusive to create a valid note.

Example

 use std::convert::TryFrom;
 fn decode_note(number: u8) -> Result<wmidi::Note, wmidi::Error> {
     let parsed_note = 60;
     let note = wmidi::Note::try_from(parsed_note)?;
     Ok(note)
 }

type Error = Error

The type returned in the event of a conversion error.

impl Copy for Note[src]

impl Eq for Note[src]

impl StructuralEq for Note[src]

impl StructuralPartialEq 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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.