File size: 57,030 Bytes
0d8675a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#! /usr/bin/python3

r'''############################################################################

################################################################################

#

#

#	      Tegridy MELODIES Python Module (TMELODIES)

#	      Version 1.0

#

#	      Project Los Angeles

#

#	      Tegridy Code 2024

#

#       https://github.com/asigalov61/tegridy-tools

#

#

################################################################################

#

#       All melodies in this module are licensed CC BY-NC-SA

#

################################################################################

#

#       Copyright 2024 Project Los Angeles / Tegridy Code

#

#       Licensed under the Apache License, Version 2.0 (the "License");

#       you may not use this file except in compliance with the License.

#       You may obtain a copy of the License at

#

#           http://www.apache.org/licenses/LICENSE-2.0

#

#       Unless required by applicable law or agreed to in writing, software

#       distributed under the License is distributed on an "AS IS" BASIS,

#       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#       See the License for the specific language governing permissions and

#       limitations under the License.

#

################################################################################

################################################################################

#

# You can decode all melodies easily with TMIDIX Python Module like so...

#

################################################################################



import random

import TMELODIES

import TMIDIX



melody = random.choice(TMELODIES.ALL_MELODIES)



mel_chords = TMELODIES.harmonize_melody(melody)



name, part, key, output_score = TMELODIES.melody_to_enhanced_score_notes(melody, 

                                                                        harmonized_tones_chords=mel_chords

                                                                        )



print('=' * 70)

print('Song:', name+' '+part+' in '+key) 

print('=' * 70)



midi_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,

                                                      output_signature = name+' '+part+' in '+key,

                                                      output_file_name = name+' '+part+' in '+key,

                                                      track_name='Project Los Angeles',

                                                      timings_multiplier=16

                                                      )



print('=' * 70)



################################################################################

'''

ALL_MELODIES = [['Arabian Nights', 'Verse', 'A', 'Minor',
                [[0, 13, 48], [13, 13, 50], [14, 27, 52], [28, 13, 48], [13, 13, 50],
                [14, 27, 52], [28, 13, 48], [13, 13, 52], [14, 19, 51], [20, 14, 47],
                [15, 19, 49], [19, 28, 51], [29, 13, 47], [14, 13, 51], [14, 20, 50],
                [20, 19, 50], [20, 18, 50], [18, 24, 50], [24, 27, 52], [28, 68, 48],
                [82, 13, 52], [14, 13, 53], [14, 20, 55], [20, 20, 51], [21, 14, 53],
                [14, 20, 55], [21, 20, 51], [20, 13, 55], [14, 20, 54], [21, 20, 50],
                [20, 13, 52], [14, 27, 54], [28, 13, 50], [14, 13, 54], [13, 20, 53],
                [21, 20, 53], [21, 13, 53], [13, 27, 53], [42, 13, 55], [14, 68, 52],
                [82, 13, 57], [14, 13, 59], [14, 27, 60], [27, 13, 57], [14, 13, 59],
                [14, 27, 60], [28, 13, 57], [13, 13, 59], [14, 27, 60], [28, 13, 57],
                [13, 13, 59], [14, 27, 60], [28, 13, 57], [14, 13, 59], [14, 27, 60],
                [27, 13, 57], [13, 13, 59], [14, 27, 60], [28, 27, 57], [28, 82, 52],
                [82, 13, 48], [14, 13, 50], [14, 27, 52], [28, 13, 48], [13, 13, 50],
                [14, 27, 52], [27, 13, 48], [14, 13, 52], [14, 19, 51], [19, 14, 47],
                [15, 19, 49], [20, 28, 51], [29, 13, 47], [14, 13, 51], [14, 20, 52],
                [20, 19, 52], [19, 18, 52], [19, 17, 60], [17, 20, 59], [21, 20, 57],
                [20, 62, 57]]],
              ['Beard Barb', 'Chorus', 'F', 'Major',
                [[0, 35, 81], [41, 42, 81], [42, 20, 83], [18, 20, 81], [19, 20, 79],
                [20, 21, 81], [20, 61, 79], [61, 12, 76], [10, 11, 74], [11, 65, 72],
                [82, 31, 81], [37, 43, 81], [42, 23, 83], [22, 20, 81], [20, 18, 79],
                [17, 22, 81], [22, 94, 79], [163, 32, 81], [39, 40, 81], [39, 23, 83],
                [21, 20, 81], [21, 20, 79], [18, 21, 81], [21, 82, 79], [83, 60, 72],
                [81, 30, 77], [29, 11, 76], [10, 21, 77], [22, 18, 81], [19, 22, 79],
                [21, 35, 81], [41, 11, 76], [9, 10, 74], [9, 77, 72]]],
              ['Beard Barb', 'Verse', 'A', 'Major',
                [[0, 27, 76], [39, 28, 74], [40, 28, 72], [39, 21, 69], [20, 10, 72],
                [12, 35, 67], [132, 20, 69], [19, 10, 72], [12, 29, 67], [49, 20, 69],
                [20, 10, 72], [9, 32, 67], [72, 20, 76], [19, 25, 77], [125, 35, 77],
                [42, 35, 74], [41, 34, 71], [40, 18, 76], [20, 11, 71], [11, 57, 72],
                [69, 18, 76], [20, 12, 69], [22, 11, 69], [12, 8, 71], [8, 11, 72],
                [13, 7, 71], [6, 11, 72], [13, 10, 69], [9, 17, 67], [17, 35, 76],
                [82, 12, 69], [13, 7, 71], [7, 13, 72], [12, 8, 71], [8, 11, 72],
                [12, 10, 69], [9, 16, 67], [18, 30, 76], [83, 13, 69], [13, 7, 71],
                [8, 10, 72], [10, 8, 71], [8, 10, 72], [11, 10, 69], [10, 17, 67],
                [19, 32, 76], [81, 5, 76], [13, 3, 76], [9, 5, 76], [13, 6, 76], [8, 5, 74],
                [14, 7, 74], [6, 13, 72]]],
              ['Blue Railcart', 'Chorus', 'B-', 'Minor',
                [[0, 23, 70], [26, 10, 65], [13, 10, 70], [13, 12, 68], [14, 12, 66],
                [13, 25, 63], [26, 16, 66], [13, 13, 65], [15, 24, 60], [25, 13, 66],
                [14, 13, 65], [14, 12, 61], [40, 12, 70], [12, 15, 69], [14, 13, 70],
                [13, 14, 72], [14, 12, 70], [13, 23, 66], [27, 13, 65], [13, 12, 73],
                [13, 12, 72], [13, 13, 73], [15, 34, 70], [56, 23, 70], [27, 13, 65],
                [13, 13, 70], [12, 14, 68], [13, 15, 66], [14, 26, 63], [26, 16, 66],
                [14, 13, 65], [14, 27, 60], [27, 14, 66], [12, 12, 65], [15, 13, 61],
                [25, 24, 70], [27, 15, 69], [13, 13, 70], [13, 14, 72], [14, 13, 70],
                [14, 24, 66], [26, 13, 65], [13, 11, 73], [13, 14, 72], [13, 12, 73],
                [14, 38, 70]]],
              ['Blue Railcart', 'Verse', 'E-', 'Minor',
                [[0, 11, 65], [13, 13, 70], [12, 13, 69], [13, 13, 70], [15, 14, 72],
                [12, 13, 70], [14, 13, 68], [13, 13, 70], [14, 24, 68], [26, 23, 66],
                [27, 36, 66], [56, 12, 63], [12, 13, 68], [13, 13, 67], [12, 13, 68],
                [15, 13, 70], [12, 12, 68], [14, 13, 63], [13, 14, 66], [15, 46, 65],
                [107, 11, 65], [12, 14, 70], [15, 14, 69], [12, 13, 70], [14, 15, 72],
                [13, 12, 70], [13, 14, 68], [13, 14, 66], [15, 29, 65], [27, 24, 63],
                [26, 14, 70], [55, 13, 65], [12, 13, 73], [13, 13, 72], [13, 12, 70],
                [13, 15, 69], [14, 13, 70], [14, 12, 72], [13, 13, 69], [14, 57, 70]]],
              ['Bremen Musicians', 'Verse', 'C', 'Major',
                [[0, 15, 60], [16, 15, 60], [15, 15, 60], [15, 15, 62], [15, 15, 64],
                [16, 15, 64], [15, 15, 60], [15, 15, 64], [16, 30, 67], [30, 30, 64],
                [31, 60, 67], [60, 15, 65], [16, 15, 65], [15, 15, 65], [15, 15, 64],
                [15, 15, 62], [16, 15, 62], [15, 15, 65], [15, 15, 69], [15, 30, 67],
                [31, 30, 65], [30, 61, 67], [61, 45, 64], [46, 15, 64], [15, 30, 67],
                [31, 30, 64], [31, 15, 69], [15, 15, 69], [15, 15, 69], [15, 15, 71],
                [16, 30, 72], [30, 30, 69], [31, 15, 74], [15, 15, 74], [15, 15, 74],
                [15, 15, 72], [16, 15, 71], [15, 15, 67], [15, 15, 71], [15, 15, 74],
                [16, 30, 72], [30, 30, 71], [31, 61, 69], [61, 45, 65], [45, 15, 65],
                [16, 30, 69], [30, 30, 72], [31, 30, 71], [30, 30, 69], [30, 30, 71],
                [31, 30, 74], [30, 15, 76], [16, 15, 74], [15, 45, 72]]],
              ['Chunga Changa', 'Chorus', 'G', 'Major',
                [[0, 7, 67], [16, 6, 72], [16, 15, 71], [20, 7, 69], [9, 7, 67], [17, 6, 69],
                [14, 19, 71], [24, 6, 69], [6, 6, 67], [16, 6, 69], [15, 21, 69],
                [22, 5, 67], [9, 6, 67], [14, 6, 69], [15, 21, 69], [23, 5, 67], [9, 6, 67],
                [15, 5, 69], [15, 21, 69], [23, 4, 67], [7, 6, 67], [15, 6, 69],
                [15, 21, 69], [22, 5, 67], [8, 5, 69], [15, 7, 71], [16, 19, 69],
                [22, 7, 67], [70, 7, 67], [15, 6, 72], [15, 20, 71], [21, 6, 69], [8, 5, 67],
                [16, 6, 69], [16, 21, 71], [23, 6, 69], [7, 5, 67], [14, 6, 69],
                [16, 21, 69], [24, 4, 67], [6, 6, 67], [15, 6, 69], [16, 19, 69],
                [22, 3, 67], [8, 6, 67], [15, 6, 69], [15, 22, 69], [24, 5, 67], [9, 7, 67],
                [15, 5, 69], [13, 22, 69], [23, 6, 67], [7, 7, 65], [17, 7, 64],
                [14, 20, 62], [24, 8, 60]]],
              ['Chunga Changa', 'Verse', 'C', 'Minor',
                [[0, 4, 60], [15, 5, 63], [14, 6, 67], [16, 5, 67], [46, 20, 67], [23, 6, 65],
                [6, 6, 67], [16, 7, 68], [14, 14, 67], [77, 23, 72], [30, 6, 63],
                [15, 6, 62], [16, 6, 62], [47, 16, 62], [20, 6, 63], [7, 7, 65], [17, 6, 67],
                [15, 13, 63], [91, 6, 60], [16, 6, 63], [14, 6, 67], [16, 6, 67],
                [47, 17, 67], [21, 6, 65], [7, 6, 67], [16, 7, 68], [17, 28, 67],
                [71, 22, 72], [32, 7, 63], [15, 7, 62], [16, 7, 62], [47, 15, 62],
                [22, 6, 63], [6, 9, 65], [17, 7, 67], [16, 12, 60]]],
              ['Clouds', 'Chorus', 'E', 'Minor',
                [[0, 15, 71], [13, 7, 76], [17, 6, 79], [15, 110, 83], [162, 5, 83],
                [17, 15, 83], [13, 16, 84], [15, 17, 83], [16, 14, 81], [14, 13, 79],
                [15, 45, 83], [45, 51, 78], [137, 16, 71], [14, 5, 75], [15, 6, 78],
                [17, 123, 81], [165, 16, 83], [15, 6, 81], [15, 15, 83], [15, 6, 84],
                [15, 5, 83], [15, 5, 81], [15, 38, 84], [45, 72, 83], [105, 16, 84],
                [15, 16, 83], [15, 16, 84], [15, 15, 83], [15, 16, 81], [15, 15, 80],
                [15, 30, 83], [30, 15, 81], [15, 76, 72], [135, 29, 83], [30, 30, 78],
                [30, 60, 81], [60, 59, 79], [90, 12, 81], [15, 18, 79], [15, 17, 81],
                [15, 17, 79], [15, 16, 78], [15, 16, 76], [15, 31, 83], [30, 15, 79],
                [15, 72, 76], [135, 31, 79], [30, 28, 75], [30, 85, 76]]],
              ['Clouds', 'Verse', 'E', 'Minor',
                [[0, 16, 71], [15, 15, 76], [15, 30, 79], [31, 16, 78], [14, 15, 76],
                [14, 15, 75], [14, 17, 76], [15, 18, 78], [17, 15, 75], [14, 71, 76],
                [89, 15, 71], [15, 17, 72], [17, 23, 74], [30, 5, 74], [14, 13, 74],
                [13, 15, 76], [15, 15, 74], [16, 16, 72], [15, 17, 74], [15, 31, 72],
                [32, 43, 71], [57, 17, 72], [17, 13, 71], [15, 27, 69], [28, 15, 72],
                [17, 15, 76], [15, 16, 81], [15, 17, 79], [15, 16, 78], [14, 14, 76],
                [15, 55, 79], [92, 17, 78], [15, 13, 76], [15, 30, 71], [30, 14, 76],
                [13, 17, 78], [16, 13, 79], [13, 16, 78], [16, 14, 81], [14, 17, 79],
                [16, 33, 78], [31, 20, 76]]],
              ['Daddys Song', 'Chorus', 'A-', 'Major',
                [[0, 7, 73], [15, 6, 68], [14, 15, 70], [14, 5, 68], [15, 7, 73], [14, 5, 68],
                [15, 14, 70], [14, 7, 68], [14, 15, 72], [29, 9, 72], [14, 4, 68],
                [15, 27, 70], [29, 13, 68], [28, 6, 72], [15, 5, 68], [14, 14, 70],
                [14, 6, 68], [15, 6, 72], [14, 5, 68], [15, 15, 70], [14, 6, 68],
                [29, 15, 70], [14, 14, 68], [14, 14, 66], [15, 29, 65], [29, 19, 68],
                [28, 6, 73], [15, 5, 68], [14, 16, 70], [14, 4, 68], [15, 5, 73],
                [14, 5, 68], [14, 14, 70], [15, 8, 68], [14, 18, 73], [29, 15, 73],
                [14, 14, 72], [15, 27, 75], [28, 19, 70], [29, 6, 73], [14, 16, 73],
                [15, 17, 72], [14, 17, 70], [14, 6, 72], [15, 18, 72], [14, 20, 70],
                [15, 11, 68], [28, 13, 66], [15, 15, 65], [14, 17, 63], [14, 34, 68],
                [58, 4, 73], [14, 16, 73], [14, 15, 72], [15, 15, 70], [14, 7, 72],
                [15, 16, 72], [14, 18, 70], [14, 13, 68], [29, 17, 68], [15, 17, 70],
                [14, 20, 72], [14, 16, 73]]],
              ['Daddys Song', 'Verse', 'C#', 'Minor',
                [[0, 23, 68], [29, 28, 68], [29, 30, 73], [29, 17, 68], [14, 13, 66],
                [14, 30, 64], [29, 27, 66], [29, 31, 64], [28, 29, 63], [29, 29, 66],
                [29, 31, 69], [29, 27, 68], [29, 13, 63], [14, 17, 64], [14, 31, 66],
                [29, 31, 68], [29, 35, 64], [57, 20, 68], [29, 24, 68], [29, 31, 73],
                [29, 10, 68], [14, 15, 69], [14, 27, 71], [29, 27, 73], [29, 28, 69],
                [29, 18, 66], [28, 27, 73], [29, 29, 69], [29, 28, 68], [28, 12, 66],
                [15, 13, 64], [14, 31, 66], [29, 27, 68], [29, 20, 61]]],
              ['Dreidel', 'Chorus', 'C', 'Major',
                [[0, 6, 64], [14, 8, 67], [17, 6, 64], [14, 7, 67], [15, 6, 64], [14, 7, 67],
                [17, 22, 64], [32, 6, 64], [15, 6, 67], [16, 6, 67], [14, 8, 65],
                [16, 6, 64], [16, 35, 62], [49, 6, 62], [14, 7, 65], [16, 6, 62],
                [14, 6, 65], [17, 6, 62], [15, 6, 65], [17, 20, 62], [30, 6, 62],
                [15, 7, 67], [15, 7, 65], [16, 7, 64], [15, 7, 62], [15, 26, 60]]],
              ['Dreidel', 'Verse', 'C', 'Major',
                [[0, 22, 55], [32, 6, 60], [15, 8, 60], [14, 8, 62], [15, 8, 62],
                [15, 12, 64], [17, 25, 60], [31, 8, 64], [15, 7, 67], [15, 8, 67],
                [15, 9, 65], [15, 8, 64], [17, 36, 62], [50, 6, 62], [14, 7, 62],
                [15, 7, 62], [15, 6, 64], [16, 6, 64], [15, 7, 65], [15, 21, 62],
                [32, 7, 62], [16, 7, 67], [16, 8, 65], [15, 8, 64], [15, 8, 62],
                [16, 41, 60]]],
              ['Duck Tales', 'Chorus', 'A', 'Major',
                [[0, 12, 68], [20, 11, 68], [31, 8, 59], [7, 22, 71], [21, 11, 68],
                [75, 25, 64], [28, 12, 62], [21, 14, 60], [19, 13, 62], [21, 14, 64],
                [20, 14, 62], [20, 14, 60], [20, 10, 62], [20, 13, 68], [22, 12, 68],
                [32, 8, 59], [7, 23, 71], [24, 13, 68], [73, 25, 64], [29, 13, 62],
                [19, 14, 60], [19, 12, 62], [20, 15, 64], [21, 12, 62], [20, 13, 60],
                [20, 12, 62], [22, 12, 68], [21, 12, 68]]],
              ['Duck Tales', 'Verse', 'F#', 'Major',
                [[0, 12, 52], [20, 13, 56], [22, 13, 59], [19, 11, 61], [20, 8, 62],
                [14, 10, 61], [20, 23, 61], [29, 10, 59], [20, 24, 57], [31, 30, 56],
                [51, 23, 57], [32, 24, 56], [48, 15, 52], [21, 17, 56], [21, 14, 59],
                [20, 14, 61], [20, 9, 62], [14, 12, 61], [19, 16, 61], [22, 16, 59],
                [28, 24, 62], [30, 28, 61], [49, 26, 62], [34, 26, 61], [69, 16, 54],
                [21, 13, 57], [21, 12, 61], [20, 26, 61], [34, 28, 59], [67, 15, 61],
                [21, 14, 64], [20, 13, 66], [21, 26, 68], [32, 7, 66], [12, 15, 66]]],
              ['Eagles Learn to Fly', 'Verse', 'F#', 'Minor',
                [[0, 28, 68], [29, 17, 73], [14, 15, 68], [43, 12, 66], [21, 9, 66],
                [8, 16, 64], [14, 14, 63], [14, 33, 61], [73, 14, 61], [14, 15, 64],
                [14, 17, 68], [14, 40, 73], [44, 14, 68], [14, 48, 73], [43, 14, 68],
                [15, 27, 71], [28, 36, 66], [43, 16, 59], [15, 15, 62], [14, 5, 66],
                [15, 41, 71], [43, 14, 66], [14, 27, 71], [29, 29, 73], [29, 29, 69],
                [28, 34, 64], [44, 7, 73], [14, 8, 73], [14, 15, 73], [15, 67, 71],
                [72, 15, 71], [14, 14, 69], [14, 14, 68], [15, 13, 66], [28, 26, 68],
                [29, 14, 69], [29, 26, 68], [29, 15, 73], [14, 20, 68], [43, 14, 66],
                [22, 8, 66], [7, 14, 64], [14, 15, 63], [15, 28, 61]]],
              ['Freak', 'Chorus', 'D', 'Minor',
                [[0, 17, 76], [19, 6, 81], [19, 20, 81], [37, 4, 69], [8, 9, 69],
                [11, 23, 77], [28, 14, 74], [28, 17, 74], [19, 6, 79], [17, 18, 79],
                [20, 18, 74], [19, 21, 77], [19, 37, 76], [39, 6, 73], [17, 20, 79],
                [18, 19, 77], [18, 12, 74], [59, 17, 76], [19, 14, 72], [56, 17, 76],
                [16, 6, 74], [19, 6, 71], [20, 18, 72], [17, 25, 69]]],
              ['Freak', 'Verse', 'C', 'Minor',
                [[0, 19, 76], [18, 20, 77], [19, 21, 76], [21, 17, 72], [17, 18, 69],
                [20, 33, 72], [35, 19, 71], [20, 21, 74], [19, 20, 76], [19, 20, 74],
                [20, 17, 71], [17, 20, 74], [20, 35, 77], [36, 17, 76], [18, 19, 79],
                [19, 18, 81], [18, 20, 79], [21, 19, 76], [20, 17, 72], [18, 34, 76],
                [37, 6, 74], [17, 18, 74], [20, 19, 76], [19, 18, 74], [20, 17, 76],
                [17, 20, 77], [19, 37, 79]]],
              ['Friend Song', 'Chorus', 'A', 'Minor',
                [[0, 14, 71], [13, 15, 69], [14, 18, 62], [28, 15, 62], [13, 11, 65],
                [14, 27, 69], [28, 14, 67], [14, 11, 65], [14, 6, 64], [13, 6, 64],
                [14, 16, 64], [14, 14, 69], [14, 29, 72], [41, 15, 72], [14, 5, 71],
                [14, 3, 71], [13, 12, 71], [14, 12, 67], [14, 27, 69], [28, 26, 71],
                [27, 40, 72], [56, 26, 71], [27, 27, 69], [28, 16, 62], [27, 12, 62],
                [14, 12, 65], [14, 27, 69], [28, 14, 67], [13, 13, 65], [14, 6, 64],
                [14, 6, 64], [14, 14, 64], [14, 12, 69], [14, 27, 72], [41, 13, 72],
                [14, 4, 71], [14, 3, 71], [14, 13, 71], [14, 12, 74], [13, 17, 72],
                [28, 24, 71], [28, 11, 69]]],
              ['Friend Song', 'Verse', 'A', 'Minor',
                [[0, 3, 69], [14, 3, 71], [14, 13, 72], [13, 4, 74], [14, 4, 72], [14, 4, 71],
                [14, 4, 69], [55, 54, 64], [55, 23, 60], [27, 4, 69], [14, 4, 71],
                [14, 54, 72], [55, 51, 74], [56, 24, 72], [27, 31, 71], [28, 25, 59],
                [27, 5, 67], [14, 4, 69], [14, 13, 71], [14, 3, 72], [14, 5, 71],
                [13, 5, 69], [14, 6, 68], [55, 55, 65], [55, 18, 64], [28, 3, 68],
                [14, 4, 69], [13, 52, 71], [56, 52, 72], [55, 22, 71], [27, 26, 69],
                [28, 26, 57]]],
              ['Gang Dance', 'Chorus', 'D', 'Minor',
                [[0, 11, 64], [21, 23, 64], [25, 7, 70], [49, 6, 69], [23, 23, 69],
                [24, 12, 64], [68, 43, 65], [45, 6, 64], [23, 8, 65], [14, 7, 64],
                [10, 6, 65], [11, 8, 67], [12, 13, 69], [50, 7, 67], [24, 25, 67],
                [22, 11, 74], [48, 6, 73], [23, 25, 73], [24, 10, 69], [47, 6, 74],
                [23, 54, 74]]],
              ['Gang Dance', 'Verse', 'D', 'Minor',
                [[0, 27, 69], [35, 5, 68], [10, 27, 69], [35, 6, 68], [10, 9, 69],
                [24, 11, 65], [24, 12, 64], [22, 11, 62], [49, 43, 67], [47, 6, 62],
                [25, 5, 67], [11, 5, 67], [12, 6, 67], [10, 7, 69], [12, 13, 67],
                [72, 43, 67], [46, 7, 60], [24, 7, 67], [20, 23, 70], [25, 11, 69],
                [22, 15, 67], [24, 9, 65], [24, 8, 65], [48, 4, 65], [11, 4, 65],
                [11, 5, 65], [12, 5, 65], [11, 6, 65], [12, 9, 67], [13, 12, 65]]],
              ['Gang Song', 'Chorus', 'C', 'Minor',
                [[0, 24, 62], [38, 22, 62], [38, 25, 62], [38, 23, 63], [37, 24, 60],
                [38, 24, 55], [38, 9, 63], [19, 11, 63], [19, 12, 62], [19, 9, 63],
                [19, 30, 65], [38, 25, 65], [38, 32, 65], [38, 27, 65], [38, 28, 67],
                [37, 14, 55], [39, 6, 67], [18, 12, 67], [19, 14, 65], [19, 10, 67],
                [19, 31, 68], [38, 10, 70], [19, 22, 72], [38, 13, 72], [19, 9, 70],
                [19, 9, 68], [19, 30, 67], [38, 10, 68], [19, 22, 70], [37, 11, 70],
                [19, 10, 68], [20, 11, 67], [18, 20, 65], [19, 10, 64], [19, 12, 65],
                [19, 11, 68], [19, 30, 67], [38, 13, 67], [19, 11, 67], [19, 34, 65],
                [38, 71, 63]]],
              ['Gang Song', 'Verse', 'C', 'Minor',
                [[0, 9, 55], [19, 13, 60], [19, 12, 62], [19, 12, 63], [19, 10, 60],
                [19, 15, 59], [19, 10, 60], [19, 11, 62], [19, 11, 59], [19, 32, 60],
                [95, 11, 60], [18, 11, 63], [19, 10, 67], [20, 41, 72], [56, 12, 72],
                [19, 13, 70], [19, 14, 68], [19, 12, 67], [19, 13, 65], [19, 19, 68],
                [19, 41, 67], [114, 9, 67], [19, 14, 70], [18, 10, 68], [19, 11, 65],
                [20, 13, 62], [18, 12, 60], [19, 10, 59], [19, 14, 67], [19, 13, 65],
                [19, 27, 63], [133, 13, 60], [19, 14, 62], [19, 9, 62], [19, 15, 62],
                [56, 8, 62], [20, 14, 62], [18, 11, 63], [19, 13, 62], [19, 17, 60]]],
              ['Gang Stop', 'Chorus', 'F', 'Minor',
                [[0, 13, 72], [25, 3, 67], [13, 13, 63], [25, 2, 62], [13, 14, 60],
                [27, 14, 72], [25, 2, 67], [12, 12, 63], [26, 3, 62], [12, 14, 60],
                [26, 4, 72], [13, 2, 72], [5, 2, 72], [6, 2, 72], [13, 3, 72], [13, 24, 73],
                [26, 19, 72], [27, 12, 73], [14, 4, 72], [13, 3, 68], [12, 3, 67],
                [12, 46, 65], [54, 23, 68], [25, 2, 65], [14, 24, 68], [27, 2, 65],
                [12, 9, 68], [11, 3, 65], [12, 24, 68], [27, 2, 65], [14, 22, 68],
                [25, 3, 65], [13, 10, 68], [12, 2, 65], [13, 3, 67], [13, 1, 67], [6, 2, 67],
                [5, 2, 67], [14, 2, 67], [12, 24, 68], [27, 17, 67], [27, 24, 63],
                [27, 21, 62], [26, 32, 60]]],
              ['Gang Stop', 'Verse', 'F', 'Minor',
                [[0, 14, 66], [26, 3, 67], [14, 12, 68], [25, 3, 67], [13, 3, 66],
                [14, 2, 67], [12, 12, 70], [24, 4, 69], [15, 13, 68], [26, 3, 67],
                [13, 2, 66], [13, 2, 67], [11, 22, 70], [26, 2, 69], [13, 12, 68],
                [26, 3, 67], [11, 2, 66], [13, 2, 67], [12, 18, 67], [28, 22, 60],
                [25, 42, 59], [54, 21, 68], [25, 3, 65], [14, 13, 68], [25, 9, 65],
                [12, 9, 68], [12, 3, 65], [13, 22, 68], [26, 2, 65], [15, 12, 68],
                [24, 8, 65], [12, 11, 68], [14, 3, 65], [12, 23, 68], [25, 3, 65],
                [14, 23, 68], [25, 11, 65], [14, 10, 68], [11, 10, 65], [12, 24, 62],
                [27, 22, 67], [26, 23, 63], [26, 16, 60]]],
              ['Grasshopper', 'Chorus', 'B-', 'Minor',
                [[0, 6, 70], [19, 6, 72], [19, 4, 72], [9, 5, 72], [10, 6, 72], [18, 5, 72],
                [19, 6, 73], [19, 4, 73], [9, 5, 73], [10, 6, 73], [18, 6, 73], [19, 10, 73],
                [19, 7, 72], [19, 7, 70], [18, 7, 69], [19, 7, 70], [19, 9, 70], [37, 6, 70],
                [19, 6, 72], [19, 4, 72], [9, 6, 72], [10, 7, 72], [18, 6, 72], [19, 6, 73],
                [19, 4, 73], [9, 5, 73], [10, 7, 73], [18, 5, 73], [19, 8, 73], [19, 7, 72],
                [19, 7, 70], [18, 7, 69], [19, 9, 70]]],
              ['Grasshopper', 'Verse', 'F', 'Minor',
                [[0, 8, 70], [19, 10, 65], [19, 9, 70], [19, 9, 65], [18, 7, 70], [19, 9, 69],
                [19, 10, 69], [37, 8, 69], [19, 11, 65], [19, 9, 69], [19, 9, 65],
                [18, 9, 69], [19, 9, 70], [19, 10, 70], [37, 7, 70], [19, 11, 65],
                [19, 8, 70], [19, 9, 65], [18, 8, 70], [19, 9, 69], [19, 9, 69], [37, 8, 69],
                [19, 9, 65], [19, 8, 69], [19, 9, 65], [18, 8, 69], [19, 14, 70]]],
              ['Gummy Bears', 'Chorus', 'B-', 'Major',
                [[0, 18, 74], [24, 8, 75], [14, 36, 77], [40, 26, 77], [35, 9, 77],
                [15, 8, 77], [13, 7, 77], [13, 10, 77], [13, 8, 75], [13, 7, 74],
                [13, 8, 72], [13, 20, 74], [23, 10, 77], [14, 33, 70], [38, 11, 70],
                [26, 4, 70], [14, 7, 77], [12, 7, 77], [13, 7, 77], [14, 9, 77], [13, 8, 75],
                [13, 8, 74], [12, 10, 72], [12, 5, 70], [26, 5, 77], [18, 8, 74], [8, 5, 70],
                [25, 4, 74], [26, 4, 70], [14, 10, 75], [13, 11, 74], [15, 22, 72],
                [27, 23, 74], [35, 10, 70], [27, 9, 70], [23, 10, 70], [26, 10, 70],
                [26, 9, 70], [26, 10, 70], [25, 11, 70], [26, 11, 70]]],
              ['Gummy Bears', 'Verse', 'B-', 'Major',
                [[0, 12, 62], [19, 12, 58], [18, 10, 62], [16, 12, 65], [18, 11, 62],
                [16, 10, 65], [16, 14, 67], [17, 12, 69], [17, 11, 70], [17, 21, 65],
                [26, 9, 62], [25, 12, 67], [18, 14, 65], [19, 10, 63], [16, 12, 65],
                [18, 12, 63], [17, 8, 62], [16, 12, 63], [18, 10, 62], [17, 10, 60],
                [16, 27, 65], [50, 14, 62], [21, 12, 58], [17, 11, 62], [16, 13, 65],
                [18, 11, 62], [17, 12, 65], [16, 14, 67], [17, 16, 69], [16, 13, 70],
                [17, 13, 65], [18, 12, 62], [16, 10, 58], [17, 13, 67], [18, 13, 65],
                [17, 14, 63], [18, 11, 65], [16, 11, 62], [19, 11, 65], [16, 13, 67],
                [17, 12, 69], [16, 11, 70], [17, 32, 72]]],
              ['Hava Nagilah', 'Chorus', 'C', 'Minor',
                [[0, 9, 66], [24, 35, 66], [50, 10, 63], [24, 10, 62], [25, 8, 62],
                [25, 46, 62], [49, 7, 63], [25, 35, 63], [49, 12, 62], [12, 10, 63],
                [13, 10, 60], [24, 5, 60], [25, 29, 60], [49, 41, 60], [50, 30, 63],
                [37, 8, 62], [12, 9, 60], [23, 12, 60], [23, 34, 67], [46, 42, 66],
                [46, 8, 63], [11, 9, 66], [11, 9, 63], [12, 11, 62], [11, 69, 66]]],
              ['Hava Nagilah', 'Verse', 'D', 'Minor',
                [[0, 34, 62], [49, 69, 62], [74, 18, 66], [25, 18, 63], [25, 17, 62],
                [24, 36, 66], [50, 66, 66], [74, 22, 69], [24, 14, 67], [25, 17, 66],
                [25, 36, 67], [49, 69, 67], [74, 21, 70], [25, 20, 69], [25, 17, 67],
                [24, 48, 66], [50, 10, 63], [12, 8, 66], [12, 11, 63], [25, 83, 62]]],
              ['It Too Shall Pass', 'Verse', 'C', 'Minor',
                [[0, 4, 75], [18, 4, 72], [18, 4, 79], [36, 4, 75], [18, 4, 72], [18, 6, 79],
                [36, 4, 72], [18, 4, 74], [18, 3, 75], [18, 4, 77], [18, 4, 75], [36, 4, 74],
                [36, 4, 74], [18, 4, 71], [18, 4, 79], [36, 4, 74], [18, 6, 71], [18, 4, 79],
                [36, 4, 74], [18, 3, 75], [18, 4, 77], [18, 4, 79], [18, 4, 77], [36, 3, 75],
                [36, 4, 79], [18, 6, 76], [18, 4, 84], [36, 4, 79], [18, 6, 76], [18, 4, 84],
                [36, 6, 79], [18, 4, 80], [18, 4, 82], [18, 4, 84], [18, 4, 82],
                [36, 12, 80], [36, 4, 80], [18, 6, 84], [1, 12, 84], [17, 6, 82],
                [18, 4, 80], [19, 3, 80], [35, 6, 79], [36, 4, 77], [1, 17, 77], [17, 5, 80],
                [18, 9, 79], [18, 6, 74], [18, 4, 75], [72, 4, 80], [18, 6, 84], [18, 4, 82],
                [18, 4, 80], [18, 4, 80], [36, 4, 79], [36, 4, 77], [18, 6, 80], [18, 4, 79],
                [18, 4, 71], [18, 3, 72]]],
              ['Learn at School', 'Chorus', 'E', 'Minor',
                [[0, 14, 64], [14, 8, 74], [15, 15, 74], [14, 7, 72], [15, 17, 72],
                [15, 9, 71], [14, 24, 71], [29, 12, 64], [15, 9, 72], [14, 18, 72],
                [15, 8, 71], [14, 16, 71], [15, 6, 69], [15, 30, 69], [29, 16, 67],
                [14, 18, 69], [15, 14, 72], [14, 17, 71], [15, 13, 67], [14, 14, 64],
                [15, 16, 67], [15, 16, 66], [14, 18, 71], [15, 16, 63], [14, 29, 66],
                [29, 36, 64]]],
              ['Learn at School', 'Verse', 'E', 'Minor',
                [[0, 15, 59], [15, 9, 67], [14, 18, 67], [15, 8, 66], [14, 16, 66],
                [15, 7, 64], [14, 19, 64], [29, 14, 59], [15, 8, 67], [15, 15, 67],
                [14, 8, 66], [15, 17, 66], [14, 7, 64], [15, 19, 64], [29, 14, 64],
                [15, 15, 67], [14, 8, 71], [15, 13, 71], [14, 17, 69], [15, 18, 67],
                [14, 8, 71], [15, 17, 71], [15, 14, 69], [14, 18, 67], [15, 31, 69],
                [29, 46, 71]]],
              ['Let Them Run', 'Chorus', 'E', 'Minor',
                [[0, 7, 61], [15, 11, 61], [17, 9, 64], [15, 30, 64], [32, 28, 63],
                [59, 10, 63], [14, 8, 66], [15, 26, 66], [31, 32, 64], [61, 12, 64],
                [14, 8, 68], [15, 30, 68], [33, 28, 66], [60, 12, 69], [14, 12, 68],
                [17, 45, 71], [90, 11, 68], [14, 10, 71], [18, 30, 71], [33, 24, 69],
                [59, 11, 66], [16, 8, 69], [16, 29, 69], [31, 23, 68], [62, 11, 64],
                [13, 10, 68], [15, 54, 66], [61, 56, 68], [62, 14, 61]]],
              ['Let Them Run', 'Verse', 'C#', 'Minor',
                [[0, 7, 68], [15, 7, 69], [16, 13, 68], [30, 9, 61], [14, 7, 63], [16, 9, 64],
                [15, 6, 61], [16, 8, 68], [15, 7, 69], [14, 17, 68], [29, 8, 63],
                [14, 8, 64], [18, 10, 66], [15, 5, 63], [16, 8, 68], [15, 9, 69],
                [15, 20, 68], [31, 8, 63], [15, 6, 64], [16, 18, 66], [30, 7, 68],
                [13, 10, 69], [16, 38, 68], [93, 7, 73], [14, 9, 74], [17, 19, 73],
                [31, 8, 68], [14, 9, 69], [16, 11, 71], [15, 7, 68], [16, 8, 73],
                [15, 8, 74], [15, 19, 73], [32, 10, 66], [14, 8, 68], [14, 10, 69],
                [17, 10, 73], [16, 11, 71], [16, 8, 69], [16, 19, 73], [29, 10, 68],
                [16, 8, 64], [15, 20, 63], [30, 10, 66], [16, 10, 64], [15, 60, 61]]],
              ['Lullaby', 'Chorus', 'E-', 'Major',
                [[0, 22, 70], [30, 31, 70], [30, 30, 72], [30, 29, 70], [30, 25, 75],
                [29, 32, 75], [31, 31, 72], [30, 25, 70], [44, 21, 63], [30, 16, 63],
                [16, 27, 68], [29, 31, 70], [30, 25, 72], [29, 32, 72], [31, 30, 70],
                [30, 30, 68], [32, 20, 67], [29, 32, 67], [30, 30, 68], [30, 33, 67],
                [31, 87, 70], [120, 59, 68], [59, 57, 65], [60, 80, 63]]],
              ['Lullaby', 'Verse', 'E-', 'Major',
                [[0, 27, 70], [25, 19, 67], [16, 45, 70], [44, 16, 67], [15, 26, 70],
                [30, 32, 70], [31, 28, 68], [29, 31, 67], [32, 30, 65], [30, 30, 67],
                [30, 67, 70], [180, 46, 70], [45, 15, 65], [14, 45, 70], [46, 16, 65],
                [14, 32, 70], [32, 30, 68], [29, 29, 67], [28, 31, 65], [30, 29, 63],
                [30, 32, 67], [31, 66, 70]]],
              ['Mamonthy Song', 'Chorus', 'F', 'Minor',
                [[0, 15, 72], [14, 15, 77], [14, 7, 79], [15, 5, 80], [14, 25, 79],
                [28, 14, 77], [29, 15, 72], [14, 15, 77], [14, 5, 79], [15, 5, 80],
                [14, 30, 79], [28, 11, 77], [29, 14, 72], [14, 15, 77], [14, 5, 79],
                [14, 7, 80], [15, 29, 79], [28, 24, 77], [29, 15, 72], [14, 16, 75],
                [14, 11, 73], [14, 8, 72], [14, 27, 75], [29, 19, 73], [28, 14, 73],
                [15, 16, 82], [14, 15, 80], [14, 16, 82], [14, 30, 80], [29, 26, 79],
                [28, 7, 77], [14, 29, 77], [29, 24, 72], [71, 6, 72], [14, 17, 72],
                [15, 15, 76], [14, 15, 79], [14, 30, 82], [29, 26, 80], [29, 15, 79],
                [15, 15, 80], [16, 12, 79], [12, 31, 77]]],
              ['Mamonthy Song', 'Verse', 'A-', 'Major',
                [[0, 15, 72], [14, 4, 75], [14, 4, 75], [14, 3, 75], [15, 28, 75],
                [28, 30, 77], [29, 15, 72], [14, 5, 75], [14, 4, 75], [14, 4, 75],
                [15, 29, 75], [57, 13, 68], [14, 9, 77], [14, 4, 77], [14, 4, 77],
                [14, 27, 77], [29, 28, 80], [28, 14, 79], [15, 16, 77], [14, 5, 75],
                [14, 3, 75], [14, 20, 75], [57, 16, 75], [15, 16, 80], [14, 15, 79],
                [14, 11, 80], [14, 30, 79], [29, 30, 77], [28, 16, 79], [15, 30, 77],
                [28, 27, 75], [71, 13, 75], [14, 15, 80], [15, 14, 70], [14, 15, 72],
                [14, 30, 73], [29, 28, 77], [28, 16, 75], [14, 27, 73], [29, 34, 72]]],
              ['New Year Song', 'Verse', 'C', 'Major',
                [[0, 49, 79], [53, 8, 76], [27, 25, 76], [27, 50, 79], [53, 7, 76],
                [27, 13, 76], [27, 23, 79], [26, 26, 77], [27, 22, 76], [27, 25, 74],
                [27, 80, 72], [107, 45, 81], [53, 19, 84], [27, 18, 81], [26, 45, 79],
                [54, 8, 76], [27, 17, 76], [26, 27, 79], [27, 26, 77], [27, 23, 76],
                [26, 28, 74], [27, 87, 72], [108, 46, 81], [53, 16, 84], [27, 17, 81],
                [27, 46, 79], [53, 7, 76], [27, 16, 76], [26, 28, 79], [27, 27, 77],
                [27, 29, 76], [27, 28, 74], [26, 52, 72]]],
              ['Open Secret', 'Chorus', 'G', 'Minor',
                [[0, 4, 79], [12, 3, 84], [13, 13, 83], [26, 4, 77], [13, 4, 80],
                [13, 11, 79], [25, 4, 79], [13, 4, 84], [13, 13, 83], [26, 4, 77],
                [12, 3, 80], [13, 14, 79], [25, 5, 79], [14, 4, 84], [13, 4, 83],
                [13, 4, 83], [13, 4, 79], [12, 3, 83], [13, 2, 84], [11, 4, 84], [13, 4, 84],
                [13, 6, 86], [13, 10, 87], [12, 6, 86], [9, 4, 86], [3, 7, 84], [15, 4, 83],
                [13, 8, 84]]],
              ['Open Secret', 'Verse', 'E-', 'Minor',
                [[0, 15, 79], [51, 13, 79], [52, 4, 79], [12, 4, 79], [13, 14, 80],
                [13, 3, 75], [13, 14, 79], [13, 3, 77], [13, 12, 77], [26, 15, 77],
                [51, 15, 77], [52, 4, 77], [13, 5, 80], [13, 12, 79], [13, 5, 74],
                [12, 12, 77], [13, 3, 75], [13, 11, 75], [26, 15, 75], [52, 15, 75],
                [51, 3, 75], [13, 4, 75], [13, 12, 77], [13, 4, 75], [13, 4, 74],
                [13, 4, 72], [12, 51, 82], [52, 14, 80], [39, 5, 84], [13, 3, 82],
                [13, 4, 80], [13, 10, 79], [13, 4, 77], [13, 3, 75], [13, 5, 74],
                [12, 7, 72]]],
              ['Righteous Road', 'Chorus', 'E-', 'Minor',
                [[0, 20, 67], [18, 23, 68], [19, 19, 70], [17, 36, 71], [35, 37, 68],
                [35, 23, 64], [20, 38, 65], [36, 19, 71], [19, 4, 70], [18, 5, 70],
                [16, 4, 66], [19, 5, 66], [18, 9, 63], [17, 28, 63], [38, 6, 63],
                [17, 21, 63], [18, 17, 62], [16, 21, 63], [18, 22, 65], [18, 21, 66],
                [18, 20, 68], [18, 23, 70], [18, 22, 68], [18, 7, 66], [19, 6, 66],
                [19, 5, 58], [19, 18, 58], [17, 9, 63]]],
              ['Righteous Road', 'Verse', 'E-', 'Minor',
                [[0, 5, 66], [18, 21, 66], [20, 6, 65], [17, 5, 65], [18, 5, 65],
                [18, 22, 65], [19, 19, 66], [35, 21, 66], [20, 20, 68], [16, 20, 66],
                [18, 21, 65], [18, 6, 63], [18, 24, 63], [20, 21, 58], [36, 19, 58],
                [18, 19, 63], [18, 18, 62], [17, 20, 63], [17, 21, 65], [19, 21, 66],
                [19, 20, 65], [16, 21, 66], [19, 20, 68], [18, 20, 70], [18, 21, 71],
                [17, 19, 70], [16, 22, 68], [20, 23, 70]]],
              ['Snow Maiden', 'Chorus', 'G', 'Major',
                [[0, 17, 62], [26, 26, 62], [27, 10, 70], [54, 25, 67], [29, 21, 60],
                [24, 12, 69], [54, 22, 65], [23, 25, 58], [30, 12, 67], [13, 11, 65],
                [27, 10, 64], [13, 26, 67], [14, 12, 65], [13, 15, 65], [105, 14, 60],
                [27, 6, 58], [13, 6, 58], [13, 18, 58], [54, 16, 62], [26, 6, 60],
                [14, 9, 60], [13, 17, 60], [54, 19, 64], [26, 6, 62], [14, 13, 62],
                [13, 21, 61], [26, 12, 59], [14, 10, 61], [13, 12, 62]]],
              ['Snow Maiden', 'Verse', 'D', 'Major',
                [[0, 6, 66], [13, 5, 66], [14, 4, 69], [13, 5, 69], [13, 28, 69], [25, 5, 67],
                [15, 5, 67], [12, 17, 71], [27, 27, 71], [28, 26, 69], [53, 9, 66],
                [14, 8, 66], [13, 3, 69], [12, 6, 69], [14, 25, 69], [27, 6, 67],
                [14, 6, 67], [13, 19, 71], [27, 15, 71], [13, 29, 69], [67, 5, 66],
                [14, 4, 66], [13, 4, 66], [13, 4, 66], [13, 23, 66], [27, 5, 62],
                [14, 4, 62], [13, 12, 64], [27, 22, 64], [26, 15, 62], [53, 4, 62],
                [13, 4, 62], [14, 5, 62], [13, 7, 64], [13, 20, 66], [27, 5, 62],
                [13, 5, 62], [14, 17, 62], [26, 20, 61], [27, 12, 62]]],
              ['Sun Circle', 'Chorus', 'G', 'Major',
                [[0, 17, 62], [30, 16, 62], [29, 51, 67], [60, 20, 69], [30, 21, 71],
                [30, 21, 69], [30, 12, 67], [30, 14, 62], [29, 16, 62], [30, 51, 67],
                [60, 21, 69], [30, 21, 71], [29, 19, 71], [30, 14, 69], [30, 18, 62],
                [30, 20, 62], [30, 51, 69], [59, 21, 71], [30, 20, 72], [30, 22, 74],
                [30, 18, 69], [30, 19, 69], [30, 18, 71], [30, 54, 72], [59, 20, 67],
                [30, 18, 69], [30, 49, 71]]],
              ['Sun Circle', 'Verse', 'G', 'Minor',
                [[0, 29, 62], [29, 20, 63], [20, 9, 62], [9, 58, 67], [59, 31, 69],
                [31, 22, 70], [21, 8, 69], [8, 44, 62], [60, 27, 62], [29, 17, 70],
                [21, 4, 70], [7, 31, 70], [30, 21, 69], [22, 2, 69], [8, 30, 67],
                [32, 67, 66], [91, 28, 65], [29, 21, 67], [21, 7, 65], [8, 55, 70],
                [60, 30, 72], [29, 23, 74], [22, 6, 72], [7, 48, 65], [62, 28, 65],
                [29, 17, 69], [18, 8, 70], [10, 30, 72], [31, 15, 70], [17, 13, 72],
                [15, 45, 74]]],
              ['Sunbath', 'Verse', 'F', 'Major',
                [[0, 11, 72], [19, 10, 70], [11, 9, 69], [31, 8, 65], [31, 7, 62],
                [29, 7, 64], [19, 105, 65], [106, 12, 72], [20, 12, 70], [10, 11, 69],
                [32, 9, 65], [30, 10, 62], [32, 8, 64], [19, 95, 65], [105, 9, 69],
                [18, 13, 72], [12, 87, 67], [96, 10, 69], [18, 11, 72], [10, 86, 65],
                [94, 11, 67], [20, 8, 69], [11, 8, 70], [32, 9, 67], [30, 10, 64],
                [31, 10, 67], [17, 101, 65], [107, 10, 69], [22, 11, 72], [13, 86, 67],
                [91, 10, 69], [21, 12, 72], [11, 80, 65], [91, 9, 67], [20, 8, 69],
                [11, 7, 70], [32, 7, 67], [31, 9, 64], [31, 9, 67], [18, 79, 65]]],
              ['Tail Spin', 'Chorus', 'G', 'Major',
                [[0, 6, 67], [16, 8, 71], [16, 6, 62], [16, 5, 65], [8, 5, 67], [15, 4, 67],
                [8, 6, 71], [16, 5, 62], [16, 5, 65], [16, 5, 67], [16, 7, 71], [16, 5, 62],
                [15, 5, 65], [8, 6, 67], [19, 7, 67], [16, 7, 67], [15, 14, 67], [21, 6, 67],
                [16, 7, 71], [16, 6, 62], [16, 5, 65], [8, 5, 67], [16, 3, 67], [8, 6, 71],
                [15, 5, 62], [16, 5, 65], [16, 5, 67], [16, 7, 71], [16, 5, 62], [15, 5, 65],
                [8, 6, 67]]],
              ['Tail Spin', 'Verse', 'C', 'Major',
                [[0, 14, 62], [14, 17, 67], [16, 17, 64], [32, 3, 64], [8, 6, 64],
                [16, 25, 66], [41, 15, 60], [15, 17, 64], [15, 17, 62], [30, 2, 62],
                [10, 6, 62], [16, 22, 64], [71, 4, 60], [8, 5, 60], [15, 7, 60], [16, 6, 64],
                [17, 7, 64], [17, 6, 62], [16, 7, 62], [21, 2, 62], [8, 3, 62], [8, 7, 64],
                [14, 3, 64], [10, 6, 66], [13, 5, 66], [9, 13, 67]]],
              ['Thirty Three Cows', 'Chorus', 'A', 'Major',
                [[0, 8, 76], [20, 6, 76], [9, 8, 76], [20, 5, 76], [10, 18, 76], [20, 28, 72],
                [39, 8, 74], [19, 4, 74], [10, 8, 74], [20, 6, 74], [10, 17, 74],
                [19, 26, 71], [40, 7, 72], [19, 4, 72], [10, 8, 72], [19, 5, 72],
                [10, 16, 72], [20, 29, 69], [39, 18, 70], [20, 12, 72], [10, 20, 70],
                [19, 13, 69], [10, 23, 67], [59, 19, 69], [19, 4, 72], [10, 17, 72],
                [20, 11, 69], [10, 19, 72], [19, 28, 74], [40, 8, 67], [20, 13, 67],
                [9, 18, 69], [20, 11, 68], [10, 17, 67], [19, 23, 76], [40, 7, 76],
                [19, 5, 76], [10, 8, 76], [20, 4, 76], [10, 15, 76], [19, 5, 72],
                [10, 18, 72], [20, 12, 76], [10, 17, 74]]],
              ['Thirty Three Cows', 'Verse', 'A', 'Major',
                [[0, 9, 64], [19, 8, 62], [10, 12, 60], [28, 17, 60], [31, 13, 64],
                [28, 16, 67], [17, 18, 72], [31, 14, 72], [72, 11, 71], [19, 13, 69],
                [11, 12, 67], [26, 12, 69], [30, 11, 67], [30, 16, 64], [17, 14, 62],
                [102, 11, 64], [19, 10, 62], [11, 13, 60], [27, 13, 60], [31, 11, 64],
                [28, 16, 67], [17, 17, 72], [31, 16, 72], [72, 11, 71], [18, 11, 72],
                [10, 15, 74], [29, 12, 71], [28, 13, 69], [31, 17, 71], [17, 17, 67],
                [100, 18, 64], [19, 10, 62], [10, 13, 60], [29, 15, 60], [30, 12, 64],
                [29, 17, 67], [18, 18, 72], [30, 16, 72], [71, 9, 71], [20, 13, 69],
                [12, 13, 67], [27, 12, 69], [28, 13, 67], [30, 19, 64], [18, 19, 62],
                [101, 11, 64], [18, 10, 62], [10, 15, 60], [28, 13, 60], [29, 13, 64],
                [31, 18, 72], [17, 19, 71], [31, 18, 69], [71, 12, 64], [18, 12, 62],
                [10, 14, 60], [29, 15, 60], [30, 12, 64], [29, 18, 72], [19, 17, 71],
                [29, 17, 69], [69, 19, 69], [18, 12, 69], [12, 13, 74], [30, 12, 74],
                [29, 14, 74], [31, 16, 76], [15, 59, 77]]],
              ['USSR Anthem', 'Chorus', 'C', 'Major',
                [[0, 23, 67], [23, 46, 76], [47, 35, 74], [35, 11, 72], [12, 46, 74],
                [47, 23, 71], [23, 23, 67], [24, 46, 72], [46, 35, 71], [36, 11, 69],
                [11, 46, 71], [47, 23, 64], [24, 23, 64], [23, 46, 69], [47, 23, 67],
                [23, 23, 65], [24, 46, 67], [47, 23, 60], [23, 23, 60], [24, 46, 72],
                [46, 35, 71], [36, 11, 69], [11, 93, 67]]],
              ['USSR Anthem', 'Verse', 'C', 'Major',
                [[0, 23, 67], [23, 46, 72], [47, 35, 67], [35, 11, 69], [12, 46, 71],
                [47, 23, 64], [23, 23, 64], [24, 46, 69], [46, 35, 67], [36, 11, 65],
                [11, 46, 67], [47, 23, 60], [24, 23, 60], [23, 46, 62], [47, 23, 62],
                [23, 23, 64], [24, 46, 65], [47, 23, 65], [23, 23, 67], [24, 46, 69],
                [46, 23, 71], [24, 23, 72], [23, 70, 74]]],
              ['White Ships', 'Chorus', 'G', 'Minor',
                [[0, 9, 81], [18, 9, 81], [19, 9, 81], [19, 9, 83], [19, 9, 81], [9, 9, 83],
                [9, 9, 81], [19, 18, 80], [19, 9, 76], [19, 9, 79], [18, 9, 79], [19, 9, 79],
                [19, 9, 81], [19, 9, 79], [9, 9, 81], [9, 9, 79], [19, 18, 78], [19, 9, 74],
                [19, 18, 74], [37, 28, 74], [38, 9, 73], [18, 9, 74], [19, 9, 76],
                [19, 9, 78], [19, 75, 71]]],
              ['White Ships', 'Verse', 'B', 'Minor',
                [[0, 18, 71], [28, 9, 71], [9, 9, 71], [19, 9, 74], [19, 28, 78],
                [37, 18, 76], [19, 9, 74], [19, 18, 76], [28, 9, 76], [9, 9, 76],
                [19, 9, 78], [19, 28, 76], [37, 18, 74], [19, 9, 73], [19, 28, 74],
                [37, 28, 71], [38, 28, 79], [37, 28, 76], [38, 112, 78]]],
              ['Winged Swing', 'Chorus', 'D', 'Major',
                [[0, 27, 57], [22, 37, 66], [43, 70, 66], [86, 25, 66], [22, 23, 67],
                [21, 46, 66], [43, 79, 64], [108, 21, 64], [22, 95, 71], [107, 25, 71],
                [22, 20, 69], [22, 23, 68], [21, 91, 69], [130, 54, 62], [43, 89, 74],
                [107, 20, 74], [22, 23, 72], [22, 14, 70], [21, 42, 70], [43, 88, 69],
                [108, 23, 69], [22, 23, 71], [21, 22, 69], [22, 83, 71], [84, 42, 73],
                [43, 106, 74]]],
              ['Winged Swing', 'Verse', 'D', 'Minor',
                [[0, 27, 69], [32, 8, 70], [11, 7, 69], [11, 11, 65], [10, 9, 64],
                [11, 14, 62], [11, 20, 65], [22, 36, 64], [64, 30, 69], [33, 11, 70],
                [10, 7, 69], [11, 10, 65], [11, 10, 64], [11, 16, 62], [10, 59, 64],
                [86, 29, 66], [33, 12, 67], [11, 3, 69], [10, 12, 69], [11, 11, 70],
                [11, 5, 72], [11, 23, 72], [21, 28, 70], [43, 12, 70], [11, 5, 69],
                [11, 18, 69], [21, 29, 67], [43, 12, 62], [11, 5, 64], [11, 68, 64]]],
              ['With a Smile', 'Chorus', 'C#', 'Minor',
                [[0, 14, 61], [17, 7, 64], [17, 7, 68], [17, 7, 68], [17, 7, 68], [17, 7, 68],
                [17, 20, 68], [35, 17, 73], [17, 17, 61], [17, 17, 64], [17, 8, 63],
                [17, 10, 63], [17, 10, 63], [17, 21, 63], [34, 18, 63], [17, 17, 64],
                [17, 20, 68], [17, 18, 66], [17, 16, 68], [18, 18, 69], [17, 17, 68],
                [17, 18, 66], [17, 17, 68], [17, 18, 69], [17, 34, 73], [34, 49, 71],
                [68, 15, 73], [17, 18, 68], [17, 18, 71], [17, 7, 69], [17, 5, 69],
                [17, 7, 69], [18, 23, 69], [34, 17, 73], [17, 17, 66], [17, 17, 69],
                [17, 8, 68], [17, 7, 68], [17, 7, 68], [17, 25, 68], [34, 15, 73],
                [17, 19, 64], [17, 17, 63], [17, 19, 64], [17, 18, 66], [17, 17, 69],
                [17, 15, 68], [18, 18, 66], [17, 17, 64], [17, 17, 66], [17, 37, 69],
                [34, 51, 68]]],
              ['With a Smile', 'Verse', 'B-', 'Major',
                [[0, 20, 68], [17, 20, 65], [18, 32, 70], [34, 33, 68], [34, 20, 63],
                [17, 18, 66], [17, 19, 65], [17, 19, 63], [17, 72, 61], [102, 21, 65],
                [17, 20, 68], [17, 13, 70], [18, 11, 70], [17, 18, 70], [17, 18, 72],
                [17, 20, 75], [17, 19, 73], [17, 21, 72], [17, 20, 70], [17, 38, 73],
                [34, 51, 68], [68, 19, 70], [17, 19, 72], [17, 51, 73], [51, 20, 72],
                [17, 18, 70], [17, 20, 65], [18, 19, 68], [17, 20, 66], [17, 82, 70],
                [102, 20, 72], [17, 19, 70], [17, 18, 73], [17, 18, 68], [17, 19, 72],
                [17, 10, 70], [17, 23, 70], [17, 18, 68], [17, 19, 63], [18, 19, 65],
                [17, 37, 63], [34, 41, 61]]],
              ['Wizard of Oz', 'Verse', 'F', 'Major',
                [[0, 25, 69], [30, 6, 72], [17, 5, 72], [15, 5, 77], [16, 9, 77],
                [16, 28, 81], [30, 6, 79], [16, 6, 79], [16, 15, 81], [17, 5, 79],
                [16, 5, 76], [16, 7, 72], [15, 29, 79], [31, 13, 77], [15, 14, 69],
                [17, 5, 72], [15, 6, 72], [14, 6, 77], [17, 6, 77], [16, 28, 81],
                [32, 5, 79], [15, 6, 79], [15, 12, 81], [15, 6, 79], [17, 5, 76],
                [15, 10, 72], [14, 37, 77], [48, 10, 81], [16, 24, 84], [31, 24, 84],
                [31, 24, 84], [32, 24, 84], [31, 21, 77], [28, 12, 77], [17, 62, 77],
                [62, 12, 82], [18, 22, 86], [31, 23, 86], [31, 25, 86], [31, 22, 86],
                [31, 30, 86], [33, 38, 84], [76, 8, 81], [16, 9, 84], [14, 8, 82],
                [15, 8, 77], [16, 8, 74], [15, 27, 82], [32, 27, 81], [141, 7, 72],
                [16, 19, 79], [31, 21, 79], [30, 44, 79], [48, 5, 77], [16, 63, 77]]]]

################################################################################

FILTERED_CHORDS = [[0], [0, 3], [0, 3, 5], [0, 3, 5, 8], [0, 3, 5, 9], [0, 3, 5, 10], [0, 3, 7],
                  [0, 3, 7, 10], [0, 3, 8], [0, 3, 9], [0, 3, 10], [0, 4], [0, 4, 6],
                  [0, 4, 6, 9], [0, 4, 6, 10], [0, 4, 7], [0, 4, 7, 10], [0, 4, 8], [0, 4, 9],
                  [0, 4, 10], [0, 5], [0, 5, 8], [0, 5, 9], [0, 5, 10], [0, 6], [0, 6, 9],
                  [0, 6, 10], [0, 7], [0, 7, 10], [0, 8], [0, 9], [0, 10], [1], [1, 4],
                  [1, 4, 6], [1, 4, 6, 9], [1, 4, 6, 10], [1, 4, 6, 11], [1, 4, 7],
                  [1, 4, 7, 10], [1, 4, 7, 11], [1, 4, 8], [1, 4, 8, 11], [1, 4, 9], [1, 4, 10],
                  [1, 4, 11], [1, 5], [1, 5, 8], [1, 5, 8, 11], [1, 5, 9], [1, 5, 10],
                  [1, 5, 11], [1, 6], [1, 6, 9], [1, 6, 10], [1, 6, 11], [1, 7], [1, 7, 10],
                  [1, 7, 11], [1, 8], [1, 8, 11], [1, 9], [1, 10], [1, 11], [2], [2, 5],
                  [2, 5, 8], [2, 5, 8, 11], [2, 5, 9], [2, 5, 10], [2, 5, 11], [2, 6], [2, 6, 9],
                  [2, 6, 10], [2, 6, 11], [2, 7], [2, 7, 10], [2, 7, 11], [2, 8], [2, 8, 11],
                  [2, 9], [2, 10], [2, 11], [3], [3, 5], [3, 5, 8], [3, 5, 8, 11], [3, 5, 9],
                  [3, 5, 10], [3, 5, 11], [3, 7], [3, 7, 10], [3, 7, 11], [3, 8], [3, 8, 11],
                  [3, 9], [3, 10], [3, 11], [4], [4, 6], [4, 6, 9], [4, 6, 10], [4, 6, 11],
                  [4, 7], [4, 7, 10], [4, 7, 11], [4, 8], [4, 8, 11], [4, 9], [4, 10], [4, 11],
                  [5], [5, 8], [5, 8, 11], [5, 9], [5, 10], [5, 11], [6], [6, 9], [6, 10],
                  [6, 11], [7], [7, 10], [7, 11], [8], [8, 11], [9], [10], [11]]

################################################################################

import copy
from collections import Counter
from itertools import groupby

################################################################################

def ordered_set(seq):
  dic = {}
  return [k for k, v in dic.fromkeys(seq).items()]

################################################################################

def grouped_set(seq):
  return [k for k, v in groupby(seq)]

################################################################################

def melody_pitches(melody):
  return [p[2] for p in melody[4]]

################################################################################

def melody_tones(melody):
  return [t[2] % 12 for t in melody[4]]

################################################################################

def melody_pitches_counts(melody):
  return [list(c) for c in Counter(melody_pitches(melody)).most_common()]

################################################################################

def melody_tones_counts(melody):
  return [list(c) for c in Counter(melody_tones(melody)).most_common()]

################################################################################

def transpose_melody(melody, transpose_value):

  mel = copy.deepcopy(melody)

  score = mel[4]

  for note in score:
    note[2] += transpose_value

  return mel[:4] + [score]

################################################################################

def adjust_melody_average_timings(melody, average_time):

  mel = copy.deepcopy(melody)

  score = mel[4]

  dtimes = [d[1] for d in score]
  old_avg_dtime = sum(dtimes) / len(dtimes)

  tadjk = old_avg_dtime / average_time

  for note in score:
    note[1] = int(note[1] / tadjk)
    note[2] = int(note[2] / tadjk)

  dtimes = [d[1] for d in score]
  new_avg_dtime = sum(dtimes) / len(dtimes)

  return [mel[:4] + [score], new_avg_dtime, old_avg_dtime]

################################################################################

def most_common_melody_pitch_and_tone(melody):

  mel_pitches = melody_pitches(melody)
  mel_tones = [t % 12 for t in mel_pitches]

  return [list(Counter(mel_pitches).most_common()[0]), list(Counter(mel_tones).most_common()[0])]

################################################################################

def melody_dtimes_counts(melody):
  return [list(c) for c in Counter([n[0] for n in melody[4]]).most_common()]

################################################################################

def melody_durations_counts(melody):
  return [list(c) for c in Counter([n[1] for n in melody[4]]).most_common()]

################################################################################

def melody_notes_count(melody):
  return len(melody[4])

################################################################################

def most_common_melody_dtime_and_duration(melody):
  return [melody_dtimes_counts(melody)[0], melody_durations_counts(melody)[0]]

################################################################################

def melody_run_time(melody):
  dtimes = [n[0] for n in melody[4]]
  last_dur = melody[4][-1][1]

  rel_run_time = sum(dtimes)+last_dur
  ms_run_time = rel_run_time * 16
  sec_run_time = ms_run_time / 1000
  min_run_time = sec_run_time / 60

  return [rel_run_time, ms_run_time, sec_run_time, min_run_time]

################################################################################

def harmonize_melody(melody):
  
  mel_tones = melody_tones(melody)

  cur_chord = []

  harmonized_chords = []

  for i, m in enumerate(mel_tones):
    cur_chord.append(m)
    cc = sorted(set(cur_chord))

    if cc in FILTERED_CHORDS:
      harmonized_chords.append(cc)

    else:
      while sorted(set(cur_chord)) not in FILTERED_CHORDS:
        cur_chord.pop(0)
      cc = sorted(set(cur_chord))
      harmonized_chords.append(cc)

  return harmonized_chords

################################################################################

def melody_range(melody):

  mel_pitches = melody_pitches(melody)

  max_pitch = max(mel_pitches)
  avg_pitch = sum(mel_pitches) / len(mel_pitches)
  min_pitch = min(mel_pitches)

  pitch_range = max_pitch - min_pitch

  return [max_pitch, avg_pitch, min_pitch, pitch_range]

################################################################################

def melody_octave(melody):
  return int(melody_range(melody)[1] // 12)

################################################################################

def melody_to_enhanced_score_notes(melody, 

                                   melody_channel=3, 

                                   melody_velocity=-1,

                                   melody_patch=40,

                                   harmonized_tones_chords=[],

                                   harmonized_tones_chords_base_octave=-1,

                                   harmonized_tones_chords_channel=0,

                                   harmonized_tones_chords_velocity=-1,

                                   harmonized_tones_chords_patch=0              

                                   ):

  name = melody[0]
  part = melody[1]
  key1 = melody[2]
  key2 = melody[3]

  if harmonized_tones_chords_base_octave > -1:
    mel_base_octave = harmonized_tones_chords_base_octave
  
  else:
    mel_base_octave = melody_octave(melody) - 1

  escore_notes = []

  time = 0

  for i, note in enumerate(melody[4]):
    
    time += note[0]
    dur = note[1]
    ptc = note[2]

    if melody_velocity == -1:
      vel = int(110 + ((ptc % 12) * 1.5))
    else:
      vel = melody_velocity

    escore_notes.append(['note', time, dur, melody_channel, ptc, vel, melody_patch])

    if harmonized_tones_chords and i < len(harmonized_tones_chords):

      for t in harmonized_tones_chords[i]:

        ptc = (mel_base_octave * 12) + t

        if harmonized_tones_chords_velocity == -1:
          vel = int(80 + ((ptc % 12) * 1.5))
        else:
          vel = harmonized_tones_chords_velocity

        escore_notes.append(['note', time, dur, harmonized_tones_chords_channel, ptc, vel, harmonized_tones_chords_patch])

  return [name, part, key1 + ' ' + key2, escore_notes]

################################################################################

def flip_melody(melody):

  mel = copy.deepcopy(melody)

  old_mel_range = melody_range(melody)

  for note in mel[4]:
    note[2] = 127 - note[2]

  new_mel_range = melody_range(mel)

  transpose_value = int(old_mel_range[1] - new_mel_range[1])

  new_melody = transpose_melody(mel, transpose_value)

  return melody[:4] + [new_melody[4]]

################################################################################

def reverse_melody(melody, full_reverse=True):

  mel = copy.deepcopy(melody)

  if full_reverse:
    
    abs_times = []

    atime = 0

    for t in mel[4]:
      atime += t[0]
      abs_times.append(atime)

    abs_dtimes = []

    for i, t in enumerate(mel[4]):
      abs_dtimes.append(abs_times[i]+t[1])

    new_dtimes = []
    pt = abs_dtimes[-1]

    for t in abs_dtimes[::-1]:
      new_dtimes.append(pt-t)
      pt = t

    new_mel = copy.deepcopy(mel[4][::-1])

    for i, t in enumerate(new_mel):
      t[0] = new_dtimes[i]

    return melody[:4] + [new_mel]

  else:
    mel_pitches = melody_pitches(melody)[::-1]

    for i, note in enumerate(mel[4]):
      note[2] = mel_pitches[i]

    return melody[:4] + [mel[4]]
    
################################################################################
#
# This is the end of TMELODIES Python module
#
################################################################################