-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
301 lines (251 loc) · 12.1 KB
/
index.html
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Let Fira Sans do all its magic -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans&subset=cyrillic" rel="stylesheet">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Composer's friend</title>
<!-- The document -->
<link href="css/style.css" rel="stylesheet">
<!-- D3.js -->
<script src="js/d3.min.js"></script>
<!-- Simple slider for D3 -->
<script src="js/d3-simple-slider.min.js"></script>
<!-- Mousetrap for key bindings -->
<script src="js/mousetrap.min.js"></script>
</head>
<body>
<!-- jQuery -->
<script src="js/jquery-3.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<link rel="stylesheet" href="css/uikit.css" />
<script src="js/uikit.js"></script>
<!-- Create div containers -->
<div class="all-container">
<h2 style="font-family: 'Fira Sans'">Composer's Friend</h2>
<ul uk-accordion="multiple: true; collapsible: false">
<li class="uk-open">
<h3 class="uk-accordion-title"> Circle of Fifths</h3>
<div class="uk-accordion-content">
<div class="theory" id="theory-container"></div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Chord Progressions</h3>
<div class="uk-accordion-content">
<div class="chord-progressions"></div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Chord Builder</h3>
<div class="uk-accordion-content">
<div class="chord-builder"></div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Chord Player</h3>
<div class="uk-accordion-content">
<div class="chord-player">
</div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Keyboard</h3>
<div class="uk-accordion-content">
<div class="keyboard"></div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Guitar</h3>
<div class="uk-accordion-content">
<div class="fretboard fb-guitar"></div>
<div class="uk-margin">
<form style="text-align: center">
<select class="uk-select option-guitar-tuning" style="width: 710px;"></select>
</form>
</div>
</div>
</li>
<li>
<h3 class="uk-accordion-title">Bass</h3>
<div class="uk-accordion-content">
<div class="fretboard-bass fb-bass"></div>
<div class="uk-margin">
<form style="text-align: center">
<select class="uk-select option-bass-tuning" style="width: 710px;"></select>
</form>
</div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">Options</h3>
<div class="uk-accordion-content">
<div class="comptools-options">
<form>
<fieldset class="uk-fieldset">
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
<label><input class="uk-checkbox option-use-sound" type="checkbox" checked> Play sound</label>
</div>
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
<label><input class="uk-checkbox option-use-midi" type="checkbox"> Use MIDI output</label>
</div>
<div class="uk-margin">
<select class="uk-select option-midi-output"></select>
</div>
</fieldset>
</form>
</div>
</div>
</li>
<li class="uk-open">
<h3 class="uk-accordion-title">About</h3>
<div class="uk-accordion-content">
<p><strong>Composer's Friend</strong> is a a JavaScript library for helping you practice playing guitar and piano and composing chord progressions.
The library can be tailored to other fretboard and keyboard note visualization applications and has advanced features, such as MIDI
connectivity. This is an example application created by using all of the library's functions.</p>
<p>© 2017-2019 Aleksei Tepljakov. Some documentation can be found in the <a href="https://atdesign.ee/about-music/composing-tool/">blog post</a>. More documentation will follow.</p>
</div>
</li>
</ul>
</div>
<!-- Add Tone.js -->
<script src="js/Tone.min.js"></script>
<!-- Chrome audio context policy fix -->
<script type="text/javascript">
if (Tone.context.state !== 'running') {
Tone.context.resume();
}
document.documentElement.addEventListener(
"mousedown", function () {
mouse_IsDown = true;
if (Tone.context.state !== 'running') {
Tone.context.resume();
}
});
</script>
<script type="text/javascript">
var comptools_sound_player = new Tone.PolySynth(8, Tone.Synth).toMaster();
</script>
<!-- THE test script -->
<script src="js/composer-tools.js"></script>
<!-- Create a couple of fretboards ... -->
<script type="text/javascript">
my_theory = new comptoolsTheory("theory-container");
my_progbuild = new comptoolsChordProgressions('.chord-progressions');
my_chbuild = new comptoolsChordbuilder(".chord-builder");
st_keyboard = new comptoolsKeyboard(".keyboard", "C1-C5");
fb_guitar = new comptoolsFretboard(".fb-guitar", "E2A2D3G3B3E4");
my_chplayer = new comptoolsChordPlayer('.chord-player');
// Options for the bass
bass_options = {"firstFretWidth": 70,
"fretboardClass": "fretboard-bass",
"fretboardNutClass": "fretboard-nut-bass",
"fretCount": 17};
fb_bass = new comptoolsFretboard(".fb-bass", "E1A1D2G2", bass_options);
// Connect all the instruments together
the_glue = new InstrumentGlue();
the_glue.objArray.push(st_keyboard);
the_glue.objArray.push(fb_guitar);
the_glue.objArray.push(fb_bass);
st_keyboard.selection_callback = the_glue.funCallback;
fb_guitar.selection_callback = the_glue.funCallback;
fb_bass.selection_callback = the_glue.funCallback;
the_glue.theory = my_theory;
my_theory.selection_callback = the_glue.funHighlightNotes;
// This is also bound to theory since chord
// progressions appear for the given scale
the_glue.chord_progressions = my_progbuild;
the_glue.chord_builder = my_chbuild;
my_chbuild.selection_callback = the_glue.funHighlightChordNotes;
// For the chord player, we must set the instrument glue config
// variable so that all elements know how to access the necessary function
comptools_config.instrument_glue = the_glue;
comptools_config.theory = my_theory;
comptools_config.chord_player = my_chplayer;
comptools_config.chord_builder = my_chbuild;
// We need to assign a handler to the sortable component
// since when the order is changed, the timeline must be redrawn
// in chord player.
$('#chord-list').on('change', function () {
my_chplayer.update_callback();
});
// Options
my_options = new comptoolsOptions();
// Populate tuning options for guitar
for (var i in guit_tunings_6_string) {
$('.option-guitar-tuning').append($('<option>', {
value: guit_tunings_6_string[i],
text: '6 String: ' + i
}));
}
for (var i in guit_tunings_7_string) {
$('.option-guitar-tuning').append($('<option>', {
value: guit_tunings_7_string[i],
text: '7 String: ' + i
}));
}
for (var i in guit_tunings_8_string) {
$('.option-guitar-tuning').append($('<option>', {
value: guit_tunings_8_string[i],
text: '8 String: ' + i
}));
}
// Add the "Custom" option
$('.option-guitar-tuning').append($('<option>', {
value: "custom",
text: "> Custom tuning"
}));
$('.option-guitar-tuning').on('change', function(e){
if (this.value.toLowerCase() === "custom"){
var tuning = prompt("New tuning", fb_guitar.tuning);
if (tuning !== null) {
fb_guitar.updateTuning(tuning);
}
}else
{
fb_guitar.updateTuning(this.value);
}
});
// Bass tunings
for (var i in bass_tunings) {
$('.option-bass-tuning').append($('<option>', {
value: bass_tunings[i],
text: i
}));
}
// Add the "Custom" option
$('.option-bass-tuning').append($('<option>', {
value: "custom",
text: "> Custom tuning"
}));
$('.option-bass-tuning').on('change', function(e){
if (this.value.toLowerCase() === "custom"){
var tuning = prompt("New tuning", fb_bass.tuning);
if (tuning !== null) {
fb_bass.updateTuning(tuning);
}
}else
{
fb_bass.updateTuning(this.value);
}
});
$('.import-chord-list').on('click', function () {
var chtext = prompt("Paste chord list text here", "");
if (chtext !== null) {
my_chplayer.import_chords(chtext);
}
});
$('.export-chord-list').on('click', function () {
var mytext = my_chplayer.export_chords();
prompt("Copy and save this text", mytext);
});
// Experimental MIDI player feature
// TODO: Major problem when using with Korg BLE MIDI driver, must speak to Korg about this
comptools_midi_player = new comptoolsMIDIPlayer();
comptools_midi_player.initialize();
</script>
</body>
</html>