Crate music_note

Source
Expand description

Music theory library with midi, notes, chords, scales, and more

§Examples

Create a C Major (1st inversion) chord and iterate over its notes.

use music_note::{midi, Chord, Pitch};

// C/E
let chord = Chord::from_midi(
    midi!(C, 4),
    [midi!(E, 3), midi!(G, 3), midi!(C, 4)]
);

assert_eq!(chord.to_string(), "C/E");

let pitches = [Pitch::E, Pitch::G, Pitch::C];
assert!(chord.into_iter().eq(pitches));

Create a C Major scale and iterate over its notes.

use music_note::{midi, Note, Scale};

// C major
let scale = Scale::major(midi!(C, 4));

assert!(scale.eq([
    midi!(C, 4),
    midi!(D, 4),
    midi!(E, 4),
    midi!(F, 4),
    midi!(G, 4),
    midi!(A, 4),
    midi!(B, 4),
]));

Re-exports§

pub use chord::Chord;
pub use staff::Key;
pub use staff::Staff;
pub use note::Note;
pub use scale::Scale;

Modules§

chord
midi
note
scale
set
staff

Macros§

midi

Structs§

Interval
Music interval in semitones.

Enums§

Natural
A natural pitch
Pitch
Pitch class that can be found on the chromatic scale.