[][src]Crate tonality

Types and operations that are useful for dealing with musical notation.

This library will help you answer questions like "Which accidental, if any, is used for writing the pitch A flat in the key of B flat major?"

Alteration versus accidental

Though they are similar, these two types serve different purposes. An Alteration can only apply to a Tpc, while an accidental can only apply to a Step - turning it into a Tpc.

Example

It can be used for finding the tonal pitch classes in a chord:

let key = Key::Fs;
type Chord = Vec<(isize, Alteration)>;
let dom7: Chord = vec![(0, 0), (2, 0), (4, 0), (6, -1)];
let tpcs: Vec<Tpc> = dom7
    .iter()
    .filter_map(|&(scale_deg, alter)| key.scale_degree(scale_deg).alter(alter))
    .collect();
let expected = vec![Tpc::Fs, Tpc::As, Tpc::Cs, Tpc::E];
assert_eq!(expected, tpcs);

Re-exports

pub use accidental::Accidental;
pub use alteration::Alteration;
pub use key::Key;
pub use step::Step;
pub use tpc::Tpc;

Modules

accidental

Accidentals

alteration

The difference from the normal value of the step in the key, in semitones

key

Key signatures

pitch

A MIDI pitch

step

A step of a diatonic scale

tpc

Tonal pitch classes