1pub const BASE12_EQUIVALENTS: [(i32, &str); 12] = [
9 (0, "C"),
10 (1, ""),
11 (2, "D"),
12 (3, ""),
13 (4, "E"),
14 (5, "F"),
15 (6, ""),
16 (7, "G"),
17 (8, ""),
18 (9, "A"),
19 (10, ""),
20 (11, "B"),
21];
22
23pub const BASE12_INTERVALS: [(i32, &str); 11] = [
26 (0, "P1"),
27 (1, "m2"),
28 (2, "M2"),
29 (3, "m3"),
30 (4, "M3"),
31 (5, "P4"),
32 (7, "P5"),
33 (8, "m6"),
34 (9, "M6"),
35 (10, "m7"),
36 (11, "M7"),
37];
38
39pub const BASE26_EQUIVALENTS: [(i32, &str); 26] = [
42 (0, "C-"),
43 (1, "C"),
44 (2, "C#"),
45 (3, ""),
46 (4, "D-"),
47 (5, "D"),
48 (6, "D#"),
49 (7, ""),
50 (8, "E-"),
51 (9, "E"),
52 (10, "E#"),
53 (11, "F-"),
54 (12, "F"),
55 (13, "F#"),
56 (14, ""),
57 (15, "G-"),
58 (16, "G"),
59 (17, "G#"),
60 (18, ""),
61 (19, "A-"),
62 (20, "A"),
63 (21, "A#"),
64 (22, ""),
65 (23, "B-"),
66 (24, "B"),
67 (25, "B#"),
68];
69
70pub const BASE26_INTERVALS: [(i32, &str); 11] = [
73 (0, "P1"),
74 (3, "m2"),
75 (4, "M2"),
76 (7, "m3"),
77 (8, "M3"),
78 (11, "P4"),
79 (15, "P5"),
80 (18, "m6"),
81 (19, "M6"),
82 (22, "m7"),
83 (23, "M7"),
84];
85
86pub fn named<'a>(
89 table: &'a [(i32, &'static str)],
90) -> impl Iterator<Item = (&'static str, i32)> + 'a {
91 table
92 .iter()
93 .filter(|(_, name)| !name.is_empty())
94 .map(|(number, name)| (*name, *number))
95}
96
97#[cfg(test)]
98mod tests {
99 use super::*;
100
101 #[test]
102 fn the_representations_leave_the_unused_numbers_out() {
103 assert_eq!(named(&BASE12_EQUIVALENTS).count(), 7);
104 assert_eq!(named(&BASE26_EQUIVALENTS).count(), 21);
105 assert!(named(&BASE26_EQUIVALENTS).any(|row| row == ("F-", 11)));
106 }
107}