/
pitches.rb
41 lines (35 loc) · 1.25 KB
/
pitches.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# not talking about the queens, but what? the pitches
# parts stolen from jvoorhis music.rb, idea partly original, partly jvoorhis-stolen also
SCALE = {"C" => 0,
"C#" => 1,
"D" => 2,
"D#" => 3,
"E" => 4,
"F" => 5,
"F#" => 6,
"G" => 7,
"G#" => 8,
"A" => 9,
"A#" => 10,
"B" => 11} # assuming C major! this isn't quite right. we're not really representing notes here
# but positions in the scale.
OCTAVES = {-1 => (0..11), # starting note is C-1
0 => (12..23),
1 => (24..35),
2 => (36..47),
3 => (48..59),
4 => (60..71),
5 => (72..83),
6 => (84..95),
7 => (96..107),
8 => (108..119),
9 => (120..127)} # the 9th octave is incomplete and only goes as far as G
# chords! this can also happen with scales!
MINOR_7TH = [0, 2, 6, 9]
MAJOR_7TH = [0, 4, 7, 11]
MAJOR_SCALE = [0, 2, 4, 5, 7, 9, 11]
MINOR_SCALE = [0, 2, 3, 5, 7, 8, 10]
# higher-resolution nomenclature exists but I won't have time to use it
CIRCLE_OF_FIFTHS = %w{C, G, D, A, E, B, F#, C#, G#, D#, A#, F}
# relative minor is always x + 3
# this data structure is of course a ring