Skip to main content

Module roman

Module roman 

Source
Expand description

Roman numerals, stored as semitones above the tonic.

Upper case is a major chord and lower case a minor one; ° (or o) marks diminished, ø half-diminished and + augmented. A numeral without a sign takes its degree from the mode of the line, and a b or # is read against major. So i-VI-III-VII and i-bVI-bIII-bVII name the same chords. X/Y is a secondary chord: X read in the major key of the degree Y, so V/V lies 2 semitones above the tonic.

Give the mode when the key is known. Without one, a line that starts with I reads as major, since a major key also borrows III, VI and VII as secondary chords. Any other line is minor when it starts with i or holds a bare III, VI or VII, the degrees that only minor makes major. A line read as major without a minor sign comes back flagged. I/Y is refused: it could be a slash chord over the bass Y.

use sound_to_patch::music::roman::parse_line;

let offsets = |text| -> Vec<u8> {
    parse_line(text, None).unwrap().numerals.iter().map(|n| n.offset).collect()
};
assert_eq!(offsets("i-VI-III-VII"), [0, 8, 3, 10]);
assert_eq!(offsets("i-bVI-bIII-bVII"), [0, 8, 3, 10]);
assert_eq!(offsets("vi-IV-I-V"), [9, 5, 0, 7]);

Structs§

Line
A parsed line of numerals and the mode it was read in.
Numeral
One numeral of a line.

Enums§

Quality
The quality a numeral names.

Functions§

parse_line
Parses a line of numerals separated by -, –, spaces or commas, in mode when given.
parse_numeral
Parses one numeral in a line of mode.