[][src]Struct libatm::midi_note::MIDINote

pub struct MIDINote {
    pub note_type: MIDINoteType,
    pub octave: u32,
}

MIDI note

Represents key on a piano, combining a note type with an octave. For example, middle C would be represented as MIDINote { note_type: MIDINoteType::C, octave: 4 }. For a detailed table of MIDI notes and octave numbers, see document here: https://www.cs.cmu.edu/~music/cmsip/readings/Standard-MIDI-file-format-updated.pdf.

Fields

note_type: MIDINoteTypeoctave: u32

Implementations

impl MIDINote[src]

pub fn new(note_type: MIDINoteType, octave: u32) -> Self[src]

Create new MIDINote

Arguments

Examples

// Middle C
let note = libatm::MIDINote::new(libatm::MIDINoteType::C, 4);
assert_eq!(60, note.convert());

Notes

The octave parameter is not validated, but must be between -1 and 9 in order to represent a valid MIDI note.

pub fn convert(&self) -> u32[src]

Convert MIDI note to an integer representation (MIDI note number)

The empty note (A.K.A. silence) is represented as u32::max_value(). The MIDI Tuning Standard only represents pitches up to 127, but instead of choosing some arbitrary number larger than 127, u32::max_value() is easily distinguishable.

Trait Implementations

impl Clone for MIDINote[src]

impl Copy for MIDINote[src]

impl Debug for MIDINote[src]

impl Eq for MIDINote[src]

impl FromIterator<MIDINote> for MIDINoteVec[src]

impl<'a> FromStr for MIDINote[src]

type Err = ParseMIDINoteError

The associated error which can be returned from parsing.

impl Hash for MIDINote[src]

impl Ord for MIDINote[src]

impl PartialEq<MIDINote> for MIDINote[src]

impl PartialOrd<MIDINote> for MIDINote[src]

impl StructuralEq for MIDINote[src]

impl StructuralPartialEq for MIDINote[src]

Auto Trait Implementations

impl RefUnwindSafe for MIDINote

impl Send for MIDINote

impl Sync for MIDINote

impl Unpin for MIDINote

impl UnwindSafe for MIDINote

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.