Expand description
Keys: the key parser, relative and parallel keys, Camelot and Open Key.
The parser tries three forms in order: a Camelot code (8A), an Open
Key code (1m), then a letter name with an optional sharp or flat and
mode word (A, Am, A minor, Bb, E♭ moll, C sharp minor). A
bare capital reads as major and a lone lowercase letter as minor; both
readings come back flagged, so the caller records or asks.
use sound_to_patch::music::key::{Key, Mode, parse_key};
let reading = parse_key("C sharp minor")?;
assert_eq!(reading.key, Key::new(1, Mode::Minor));
assert_eq!(reading.key.camelot().to_string(), "12A");
assert_eq!(reading.key.open_key().to_string(), "5m");Structs§
- Camelot
- A Camelot code: a number from 1 to 12,
Afor minor andBfor major. - Key
- A tonic pitch class and a mode.
- KeyReading
- A parsed key and the assumption it rests on, if any.
- OpenKey
- An Open Key code: a number from 1 to 12,
mfor minor anddfor major.
Enums§
- KeyAssumption
- A mode the parser assumed because the text named none.
- Mode
- Major or minor.
Functions§
- parse_
key - Parses a key name.