-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchordFunction.js
133 lines (112 loc) · 3.37 KB
/
chordFunction.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Can be replaced by any symbols (such as the notes themselves)
var tonics = ["i", "ii", "iii", "iv", "v", "vi", "vii"];
var tonicColor = "#eee";
var subColor = "#77bfff"
var dominantColor = "#ff636b"
var domDimColor = "#ad5def"
var subDimColor = "#42f4b9"
function resetNotes(notes) {
for (var i = 0; i < notes.length; i++) {
notes[i] = notes[i].toLowerCase();
}
}
function majorKey(notes) {
resetNotes(notes);
notes[0] = notes[0].toUpperCase();
notes[3] = notes[3].toUpperCase();
notes[4] = notes[4].toUpperCase();
}
function minorKey(notes) {
resetNotes(notes);
notes[1] = notes[1].toUpperCase();
notes[2] = notes[2].toUpperCase();
notes[5] = notes[5].toUpperCase();
notes[6] = notes[6].toUpperCase();
}
function printStrings() {
$("string").empty();
for (var i = 0; i < tonics.length; i++) {
var fifth = (i + 4) % tonics.length;
var fourth = (i + 3) % tonics.length;
$("#above").append("<fret>" + tonics[fifth] + "</fret>");
$("#main").append("<fret>" + tonics[i] + "</fret");
$("#below").append("<fret>" + tonics[fourth] + "</fret>");
}
}
function printStringsMultiple(octaves) {
$("string").empty();
for (var o = 0; o < octaves; o++) {
for (var i = 0; i < tonics.length; i++) {
var fifth = (i + 4) % tonics.length;
var fourth = (i + 3) % tonics.length;
$("#above").append("<fret>" + tonics[fifth] + "</fret>");
$("#main").append("<fret>" + tonics[i] + "</fret");
$("#below").append("<fret>" + tonics[fourth] + "</fret>");
}
}
}
function chordFunctionMajor() {
// $("fret:contains('i')").css("color", "yellow");
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "i";
}).css("color", tonicColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "iii";
}).css("color", tonicColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "vi";
}).css("color", tonicColor);
//Subdominant
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "iv";
}).css("color", subColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "ii";
}).css("color", subColor);
//Dominant
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "v";
}).css("color", dominantColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "vii";
}).css("color", dominantColor);
}
function chordFunctionMinor() {
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "i";
}).css("color", tonicColor);
$("fret").filter(function() {
return $(this).text().toLowerCase() === "iii";
}).css("color", tonicColor);
//Subdominant
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "iv";
}).css("color", subColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "vi";
}).css("color", subColor);
//Subdominant diminished
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "ii";
}).css("color", subColor);
//Dominant
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "v";
}).css("color", dominantColor);
$("fret")
.filter(function() {
return $(this).text().toLowerCase() === "vii";
}).css("color", dominantColor);
}