-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusicxml_process.js
1266 lines (963 loc) · 38.5 KB
/
musicxml_process.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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* jslint esversion: 6, maxerr: 100 */
/* jshint eqeqeq: false */
var MLIB;
var parameters;
var xml_string_loaded;
var xml_string_in;
var xml_string_out;
var demonstration_scores_array;
function show_sidebar()
{
// javascript to create sidebar menu
let elt = document.getElementById('sidebar');
elt.innerHTML = `
<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse " >
<!-- sidebar menu start-->
<ul class="faq-menu" id="nav-accordion">
<li>
<a href ="index.htm">
<i class="fa fa-home"></i>
<span>Home</span>
</a>
</li>
<li>
<a href="javascript:;">
<span style="color: #eee; font-weight: 800;">Processing Functions</span>
</a></li>
<li>
<a href="javascript:set_content_name('view_play');">
<span style="width: 15px;"> </span>
<i class="fa fa-music "></i>
<span style="color: #ddd;" >View</span></a></li>
<li>
<a href="javascript:set_content_name('transpose');">
<span style="width: 15px;"> </span>
<i class="fa fa-arrows-v"></i>
<span>Transpose</span></a></li>
<li>
<a href="javascript:set_content_name('add_bass');">
<span style="width: 15px;"> </span>
<i class="fa fa-level-down"></i>
<span style="color: #ddd;">Add Bass</span></a></li>
<li>
<a href="javascript:set_content_name('add_solo');">
<span style="width: 15px;"> </span>
<i class="fa fa-level-down"></i>
<span style="color: #ddd;">Add Solo Section</span></a></li>
<li>
<a href="javascript:set_content_name('trim_score');">
<span style="width: 15px;"> </span>
<i class="fa fa-scissors"></i>
<span style="color: #ddd;">Trim</span></a></li>
<li>
<a href="javascript:set_content_name('voice_leading');">
<span style="width: 15px;"> </span>
<i class="fa fa-arrow-right"></i>
<span style="color: #ddd;">Voice Leading</span></a></li>
<li>
<a href="javascript:set_content_name('melody_chords');">
<span style="width: 15px;"> </span>
<i class="fa fa-level-up"></i>
<span style="color: #ddd;">Melody Chords</span></a></li>
<li>
<a href="javascript:set_content_name('add_rhythm');">
<span style="width: 15px;"> </span>
<i class="fa fa-level-down"></i>
<span style="color: #ddd;">Add Rhythm Text</span></a></li>
<p style="color: #eee; margin-left: 20px;">--------------------------</p>
<li>
<a href ="musicxml_faq.htm">
<i class="fa fa-question"></i>
<span>Frequent Questions</span>
</a>
</li>
<li>
<a href ="musicxml_about.htm">
<i class="fa fa-user"></i>
<span>About Us</span>
</a>
</li>
<li>
<a href ="musicxml_contact.htm">
<i class="fa fa-phone"></i>
<span>Contact Us</span>
</a>
</li>
</ul>
<!-- sidebar menu end-->
`;
}
var parameters;
var load_or_open;
// in musicxml_process.htm this shows the parameters for the process
// onther files, like index and faq can override it.
function set_content_name(content_name)
{
console.log(get_self(content_name));
console.log("load_or_open: %s", load_or_open);
parameters.process_content = content_name;
//console.log("parameters.process_content: %s", parameters.process_content);
save_parameters_to_local_storage();
if (load_or_open == "load")
{
load_musicxml_process_page(content_name);
return;
}
// see if this is a process to open
let content_id = content_name + "_content";
let process_found = false;
let content_text = document.getElementsByClassName("content_text");
for (let ii = 0; ii < content_text.length; ii++)
{
let content_elt = content_text[ii];
//console.log("II: %s content_text ID: %s (%s)", ii, content_elt.id, content_id);
if (content_elt.id == content_id)
{
//console.log("SET DISPLAY BLOCK: %s", content_elt.id);
content_elt.style.display = "block";
process_found = true;
}
else
{
content_elt.style.display = "none";
}
}
if (!process_found)
{
console.error("process to show not found: %s", content_name);
}
}
function set_default_parameters(do_save)
{
//console.log(get_self(do_save));
parameters = {
max_number_of_notes_leading: "4",
max_number_of_notes_melody: "4",
bass_format: "radio_chords",
demonstration_score: "Every Time I Say Goodbye",
first_trim_measure: "2",
first_note: "2",
last_trim_measure: "4",
last_note: "1",
process_content: "view_play",
seventh_position: "treble",
show_output: false,
show_output_select: "0",
staff_type: "bass-clef",
starting_inversion: "root",
transpose_direction: "closest",
transpose_key: "None",
};
// if user clicked set_default_paramaters
if (do_save)
{
save_parameters_to_local_storage();
}
}
function clear_score()
{
xml_string_loaded = "";
xml_string_in = "";
xml_string_out = "";
let download_div_elt = document.getElementById('download_div');
download_div_elt.style.display = "none";
}
function change_file_name(elt)
{
let output_file_name = elt.value;
console.log(get_self(output_file_name));
prepare_output_file(xml_string_out, output_file_name);
}
// to save output
function prepare_output_file(output_string, output_file_name)
{
if (!output_file_name || output_file_name == "")
{
output_file_name = "new_score" + parameters.output_file_extension;
let elt = document.getElementById("output_file_name");
elt.innerText = output_file_name;
}
//console.log("prepare_output_file: output_file_name: %s", output_file_name);
let properties = {type: 'text/plain'}; // Specify the file's mime-type.
let output_file_data = [output_string];
//console.log("string DATA length: %s", output_file_data.length);
let file;
try
{
// Specify the filename using the File constructor, but ...
//console.log("SAVE AS FILE");
// we will want to get output file name
file = new File(output_file_data, output_file_name, properties);
}
catch (e)
{
// ... fall back to the Blob constructor if that isn't supported.
//console.log("SAVE AS BLOB");
file = new Blob(output_file_data, properties);
}
//console.log("After create FILE");
let url = URL.createObjectURL(file);
let download_div_elt = document.getElementById('download_div');
download_div_elt.style.display = "block";
let download_elt = document.getElementById('download_link');
download_elt.download = output_file_name;
download_elt.href = url;
//console.log("After set download_link href");
let label_elt = document.getElementById("output_file_label");
label_elt.scrollIntoViewIfNeeded();
}
function get_parameter_change(element, dont_save)
{
//console.log(get_self());
//console.log("element.id: %s element.name: %s type: %s tagName: %s dont_save: %s",
// element.id, element.name, element.type, element.tagName dont_save);
let name;
let value;
let type = element.type;
if (element.tagName == "SELECT")
{
type = "SELECT";
name = element.id;
let index = element.selectedIndex;
//console.log("SELECT NAME: %s index: %s", name, index);
value = element.options[index].value;
}
else if (element.type == "radio")
{
name = element.name;
value = element.id;
}
else if (element.type == "number" || element.type == "text")
{
name = element.id;
value = element.value;
}
parameters[name] = value;
//console.log("get_parameter_change: type: %s name: %s value: %s", type, name, value);
if (!dont_save)
save_parameters_to_local_storage();
}
function get_parameters_from_elts()
{
//console.log(get_self());
let parameter_elts = document.getElementsByClassName("parameters");
let DONT_SAVE = true;
for (let iparm = 0; iparm < parameter_elts.length; iparm++)
{
let elt = parameter_elts[iparm];
//console.log("type: %s id: %s name: %s tagName: %s value: %s", elt.type, elt.id, elt.name, elt.tagName, elt.value);
if (elt.type == "number" || elt.type == "text")
{
get_parameter_change(elt, DONT_SAVE);
}
else if (elt.tagName == "SELECT")
{
get_parameter_change(elt, DONT_SAVE);
}
else if (elt.type == "radio")
{
//console.log("RADIO: checked: %s", elt.checked);
if (elt.checked)
get_parameter_change(elt, DONT_SAVE);
}
else
{
//console.log("Unknown Element type: %s", elt.type);
}
}
// ADH - we will better T/F logic for parameters
if (parameters.show_output_select == "1")
parameters.show_output = true;
else
parameters.show_output = false;
save_parameters_to_local_storage();
}
function get_demonstration_score(element, dont_save)
{
console.log(get_self());
get_parameter_change(element, dont_save);
let value;
name = element.id;
let index = element.selectedIndex;
console.log("NAME: %s index: %s", name, index);
value = element.options[index].value;
}
// these read the latest parameters
function add_to_parameters(svar)
{
let value = get_element_value(svar);
//console.log("add_to_parameters: svar: %s: value: %s", svar, value);
parameters[svar] = value;
}
function add_to_parameters_number(svar)
{
let value = get_element_value(svar);
//console.log("add_to_parameters: svar: %s: value: %s", svar, value);
parameters[svar] = Number(value);
}
// process xml_string_loaded, or
// get new text from demotration score
function process_loaded_xml()
{
console.log(get_self());
if (!xml_string_loaded || xml_string_loaded == "")
{
console.log("parameters.demonstration_score: %s", parameters.demonstration_score);
let score_name = parameters.demonstration_score;
let score_data = demonstration_scores_array[score_name];
MLIB.show_object(demonstration_scores_array, "demonstration_scores_array");
MLIB.show_object(score_data, "score_data");
parameters.song_name = score_data.name;
set_element_value("song_name", song_name);
parameters.song_name = song_name;
console.log("score_name: %s song_name: %s", score_name, parameters.song_name);
load_url_text(score_data.url, "process");
}
else
{
console.log("xml_string_loaded.length: %s", xml_string_loaded.length);
process_xml(xml_string_loaded);
}
}
function process_xml(xml_string_loaded)
{
console.log(get_self(parameters.process_content));
get_parameters_from_elts();
//console.log("show_output: %s", parameters.show_output);
// save in var for debug
xml_string_in = xml_string_loaded;
//console.log("xml_string_in length: %s\n %s", xml_string_in.length, xml_string_in.substr(0,100));
if (!xml_string_in || xml_string_in == "")
{
console.error("NO XML STRING");
alert("XML Not Loaded");
return;
}
xml_string_out = "";
var song_name;
let dom_object = MLIB.musicxml_to_dom(xml_string_in);
switch (parameters.process_content)
{
case 'view_play':
// will display below
short_content = ""; // not used for file name
break;
case 'transpose':
short_content = parameters.transpose_key;
MLIB.transpose_musicxml_dom(parameters, dom_object);
break;
case 'add_bass':
short_content = "bass";
MLIB.add_bass_to_musicxml_dom(parameters, dom_object);
break;
case 'add_solo':
short_content = "solo";
MLIB.add_solo_to_musicxml_dom(parameters, dom_object);
break;
case 'trim_score':
short_content = "trimmed";
MLIB.do_trim_score_musicxml_dom(parameters, dom_object);
break;
case 'voice_leading':
short_content = "leading";
MLIB.do_voice_leading_musicxml_dom(parameters, dom_object);
break;
case 'melody_chords':
short_content = "melody";
MLIB.do_melody_chords_musicxml_dom(parameters, dom_object);
break;
case 'add_rhythm':
short_content = "rhythm";
MLIB.add_rhythm_to_musicxml_dom(parameters, dom_object);
break;
default:
console.error("UNKNOWN process_content: %s", parameters.process_content);
break;
}
// display processed score
MLIB.view_musicxml_dom(parameters, dom_object);
song_name = MLIB.osmd_object.sheet.title.text;
let output_file_name = sprintf("%s_%s%s", song_name, short_content, parameters.output_file_extension);
//console.log("TITLE: %s output_file_name: %s", song_name, output_file_name);
set_element_value("song_name", song_name);
parameters.song_name = song_name;
set_element_value("output_file_name", output_file_name);
if (parameters.process_content != "view_play")
{
xml_string_out = MLIB.dom_object_to_return_string(dom_object);
// create the output file ready for download
prepare_output_file(xml_string_out, output_file_name);
}
}
function zoomin()
{
//window.setTimeout(function ()
//{
MLIB.view_params.zoom *= 1.25;
set_element_value("zoom", MLIB.view_params.zoom);
MLIB.osmd_object.Zoom = MLIB.view_params.zoom;
MLIB.osmd_object.render();
//}, 0);
}
function zoomout()
{
//window.setTimeout(function ()
//{
MLIB.view_params.zoom /= 1.25;
set_element_value("zoom", MLIB.view_params.zoom);
MLIB.osmd_object.Zoom = MLIB.view_params.zoom;
MLIB.osmd_object.render();
//}, 0);
}
function zoom100()
{
//window.setTimeout(function ()
//{
MLIB.view_params.zoom = 1.00;
MLIB.osmd_object.Zoom = MLIB.view_params.zoom;
set_element_value("zoom", MLIB.view_params.zoom);
MLIB.osmd_object.render();
//}, 0);
}
function show_transposed_score()
{
if (xml_string_out === "")
{
alert("No Transposed Score available");
}
else
{
let elt = document.getElementById("transposed_score");
elt.style.display = "block";
elt.innerText = xml_string_out;
}
}
function copy_transposed_score()
{
if (xml_string_out === "")
{
alert("No Transposed Score available");
}
else
{
copyToClipboard(xml_string_out);
alert(xml_string_out.length + " bytes copied to clipboard");
}
}
function copyToClipboard(text) {
let dummy = document.createElement("textarea");
// to avoid breaking orgain page when copying more words
// cant copy when adding below this code
// dummy.style.display = 'none'
document.body.appendChild(dummy);
//Be careful if you use texarea. setAttribute('value', value), which works with "input" does not work with "textarea". – Eduard
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
var url_vars;
function get_url_vars()
{
//console.log(get_self());
if (url_vars)
console.error("url_vars already defined");
let url_string = window.location.href;
let ipos = url_string.indexOf("#");
if (ipos >= 0)
{
url_string = url_string.substr(0, ipos);
}
url_vars = [];
url_string.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key,value)
{
url_vars[key] = unescape(value);
});
return url_vars;
}
function get_url_var(svar)
{
//console.log(get_self(svar));
if (!url_vars)
{
//console.log("getting url_vars");
get_url_vars();
}
let sval = url_vars[svar];
if (!sval)
sval = "";
return(sval);
}
// save parameters after every change
function save_parameters_to_local_storage()
{
//console.log(get_self());
let json_string = JSON.stringify(parameters);
//console.log("json_string: %s", json_string);
let storage_key = "musicxml_process";
//console.log("setItem for storage_key: %s\n%s", storage_key, json_string);
localStorage.setItem(storage_key, json_string);
}
function load_parameters_from_local_storage(skip_set)
{
//console.log(get_self());
let storage_key = "musicxml_process";
let json_string = localStorage.getItem(storage_key);
//console.log("load_parameters_from_local_storage: %s\n%s", storage_key, json_string);
let parameters_parsed = JSON.parse(json_string);
for (let key in parameters_parsed)
{
if (key == "show_output")
continue;
let value = parameters_parsed[key];
//console.log("load_parameters_from_local_storage:SET key: %s value: %s", key, value);
parameters[key] = value;
if (!skip_set)
set_element_value(key, value);
}
}
// these are not in the library functions (yet) because they are only used in this one .htm file
function set_element_value(sid, value)
{
//console.log(get_self(sid, value));
if (sid == "process_content")
{
// not setting sidebar tab yet
content_name = value;
//console.log("CALL set_content_name('%s'))", content_name);
set_content_name(content_name);
return;
}
let elt = document.getElementById(sid);
if (!elt)
{
// see if this is a radio group - by class of elements
let elts = document.getElementsByName(sid);
for (let ii = 0; ii < elts.length; ii++)
{
elt = elts[ii];
//console.log("elt id: %s name: %s value: %s", elt.id, elt.name, value);
if (elt.id == value)
{
//console.log("ii: %s set check: %s", ii, elt.id);
elt.checked = true;
return;
}
}
console.error("set_element_value: ITEM TO CHECK NOT FOUND: %s", sid);
return;
}
if (!elt)
{
console.error("set_element_value: ELT NOT FOUND: %s", sid);
return;
}
//console.log("elt.id: %s elt.name: %s type: %s tagName: %s", elt.id, elt.name, elt.type, elt.tagName);
if (elt.tagName == "SELECT")
{
//console.log("elt.options.length: %s", elt.options.length);
for (let ii=0; ii < elt.options.length; ii++)
{
let elt_value = elt.options[ii].value;
//console.log("ii: %s sid: %s value: %s (value == elt_value): %s",
// ii, sid, elt_value, (value == elt_value) ? "T" : "F" );
if (elt_value == value)
{
elt.selectedIndex = ii;
//console.log("set_element_value: SELECT: %s value: %s index: %s", sid, ii, value);
return;
}
}
if (sid == "demonstration_score")
{
return; // we will set this on page load later
// we will select this later
}
console.error(sid + " - SELECT value not found: " + value, sid, value);
}
else if (elt.tagName == "DIV" || elt.tagName == "SPAN")
{
elt.innerText = value;
}
else
{
elt.value = value;
//console.log("set_element_value: sid: %s value: %s elt.value: %s", sid, value, elt.value);
}
}
function get_element_value(sid)
{
let elt = document.getElementById(sid);
if (!elt)
console.error("elt not found: " + sid);
let value;
if (elt.tagName == "SELECT")
{
value = elt.options[elt.selectedIndex].value;
}
else
value = elt.value;
return(value);
}
function get_element_number(sid)
{
let value = get_element_value(sid);
value = Number(value);
return(value);
}
// get link to load page
function get_musicxml_load_html(content_name, text_label)
{
//console.log("get_musicxml_load_html(%s,%s)", content_name, text_label);
let shtml = sprintf(`<p></p><a href='Javascript:load_musicxml_process_page("%s");'>
<button>%s MusicXML File</button>
</a><br>
`, content_name, text_label);
return(shtml);
}
function load_musicxml_process_page(content_name)
{
//console.log("load_musicxml_process_page(%s)", content_name);
// save content into localStorage as process_content
let skip_set = true;
load_parameters_from_local_storage(skip_set);
parameters.process_content = content_name;
save_parameters_to_local_storage();
let surl = "musicxml_process.htm";
window.location.href = surl;
}
function do_view_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>View and Play</h3>
<img src="images/view.png" >
View you score and play it in your browser.\n`;
if (add_link)
shtml += get_musicxml_load_html("view_play", "View and Play");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_transpose_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Transpose Score</h3>
<img src="images/transpose.png" >
Transpose your MusicXML score, chords and key signatures to any key.\n`;
if (add_link)
shtml += get_musicxml_load_html("transpose", "Transpose");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_add_bass_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Add Bass Accompaniment</h3>
<img src="images/add-bass.png" >
Add a simple Accompaniment to your MusicXML score.
<p>
For instance, a piano accompaniment for a choral score.
</p>\n`;
if (add_link)
shtml += get_musicxml_load_html("add_bass", "Add Base Notes");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_add_solo_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Add Solo Section</h3>
<img src="images/add-solo.png" >
Add a simple Accompaniment to your MusicXML score.
<p>
For instance, a piano accompaniment for a choral score.
</p>\n`;
if (add_link)
shtml += get_musicxml_load_html("add_solo", "Add Base Notes");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_trim_score_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Trim Score</h3>
<img src="images/trim-score.png" >
Select a portion of a MusicXML score you want to keep with just the desired measures and notes.
<p></p>
Create and save a new MusicXML file with just the desired part of the original score.
\n`;
if (add_link)
shtml += get_musicxml_load_html("trim_score", "Trim Score");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_voice_leading_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Voice Leading Chords is not complete yet.</h3>
<img src="images/accompaniment.png" >
Voice Leading Chords will read a melody from the first part in your MusicXML score,
and add bass and chords notes to accompany the melody.
<p></p>
This is designed to be played when aocompianing a singer or soloist.
<p></p>
One chord is provided for each chord in the leadsheet - using voice leading and inversions to minimize hand movement
while providing accompaniment.
\n`;
if (add_link)
shtml += get_musicxml_load_html("voice_leading", "Add Voice Leasing Chords");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_melody_chords_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Melody Chords is not complete yet.</h3>
<img src="images/piano-jazz.png" >
Melody Chords will read a melody from the first part in your MusicXML score, and add bass and chords notes to accompany the melody.
\n`;
if (add_link)
shtml += get_musicxml_load_html("melody_chords", "Add Melody Chords");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
function do_add_rhythm_text(sid, add_link)
{
let shtml = `<div class=info>
<h3>Add Rhythm Notation</h3>
<img src="images/add-rhythm.png" >
<br clear=all>
Equally spaces out notes based on duration,
<br> and optionally
Adds "1 & 2 & 3 & ..." as lyrics to your MusicXML score.
<p>
This may help with parsing out syncopated rhythms when learning a new melody.
</p>\n`;
if (add_link)
shtml += get_musicxml_load_html("add_rhythm", "Add Base Notes");
shtml +=`<br clear=all>
</div><p></p>
`;
let element = document.getElementById(sid);
element.innerHTML += shtml;
}
// Stuff for drop and load files
function setup_drop_and_paste()
{
// where files are dropped + file selector is opened
let dropRegion = document.getElementById("drop-region");
// open file selector when clicked on the drop region