#midi #music #chords #cli #music-theory

bin+lib staff

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

7 releases (4 breaking)

Uses new Rust 2021

0.5.0 Nov 22, 2022
0.4.2 Nov 15, 2022
0.3.0 Aug 14, 2022
0.2.0 Aug 11, 2022
0.1.0 Aug 10, 2022

#251 in Audio

Download history 22/week @ 2022-08-16 12/week @ 2022-08-23 2/week @ 2022-08-30 9/week @ 2022-09-06 7/week @ 2022-09-13 3/week @ 2022-09-20 6/week @ 2022-09-27 13/week @ 2022-10-04 3/week @ 2022-10-11 21/week @ 2022-10-18 8/week @ 2022-10-25 6/week @ 2022-11-01 65/week @ 2022-11-08 69/week @ 2022-11-15 78/week @ 2022-11-22 20/week @ 2022-11-29

232 downloads per month

MIT license

59KB
1.5K SLoC

Staff

crate documentation

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

Installation

cargo install staff --features=cli

Usage

Command-line interface

$ staff chord C#m7

C# F G# B
$ staff scale D dorian

D E F G A B C

Library

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

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));

lib.rs:

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

Examples

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

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

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

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

assert!(chord.into_iter().eq(notes));

Create a C Major scale and iterate over its notes.

use staff::{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),
]));

Dependencies

~0.3–1.2MB
~24K SLoC