asigalov61 commited on
Commit
b64b0f8
1 Parent(s): c506e91

Upload TMIDIX.py

Browse files
Files changed (1) hide show
  1. TMIDIX.py +1420 -21
TMIDIX.py CHANGED
@@ -1761,7 +1761,8 @@ def plot_ms_SONG(ms_song,
1761
  plot_size=(11,4),
1762
  note_height = 0.75,
1763
  show_grid_lines=False,
1764
- return_plt = False
 
1765
  ):
1766
 
1767
  '''Tegridy ms SONG plotter/vizualizer'''
@@ -1774,15 +1775,15 @@ def plot_ms_SONG(ms_song,
1774
 
1775
  else:
1776
 
1777
- start_times = [s[1] / 1000 for s in notes]
1778
- durations = [s[2] / 1000 for s in notes]
1779
  pitches = [s[4] for s in notes]
1780
  patches = [s[6] for s in notes]
1781
 
1782
  colors = generate_colors(max_num_colors)
1783
  colors[drums_color_num] = (1, 1, 1)
1784
 
1785
- pbl = notes[preview_length_in_notes][1] / 1000
1786
 
1787
  fig, ax = plt.subplots(figsize=plot_size)
1788
  #fig, ax = plt.subplots()
@@ -1816,7 +1817,7 @@ def plot_ms_SONG(ms_song,
1816
  plt.title(plot_title)
1817
 
1818
  if return_plt:
1819
- return plt
1820
 
1821
  plt.show()
1822
 
@@ -1927,7 +1928,7 @@ def Tegridy_Any_Pickle_File_Writer(Data, input_file_name='TMIDI_Pickle_File'):
1927
 
1928
  ###################################################################################
1929
 
1930
- def Tegridy_Any_Pickle_File_Reader(input_file_name='TMIDI_Pickle_File', ext='.pickle'):
1931
 
1932
  '''Tegridy Pickle File Loader
1933
 
@@ -1939,12 +1940,16 @@ def Tegridy_Any_Pickle_File_Reader(input_file_name='TMIDI_Pickle_File', ext='.pi
1939
  Project Los Angeles
1940
  Tegridy Code 2021'''
1941
 
1942
- print('Tegridy Pickle File Loader')
1943
- print('Loading the pickle file. Please wait...')
 
1944
 
1945
  with open(input_file_name + ext, 'rb') as pickle_file:
1946
  content = pickle.load(pickle_file)
1947
 
 
 
 
1948
  return content
1949
 
1950
  ###################################################################################
@@ -4707,23 +4712,62 @@ def augment_enhanced_score_notes(enhanced_score_notes,
4707
 
4708
  ###################################################################################
4709
 
 
 
 
 
 
 
 
 
 
 
 
 
4710
  def extract_melody(chordified_enhanced_score,
4711
- melody_range=[60, 84],
4712
  melody_channel=0,
4713
- melody_patch=0
 
 
 
4714
  ):
4715
 
4716
- melody_score = copy.deepcopy([c[0] for c in chordified_enhanced_score if c[0][3] != 9])
4717
-
4718
- for e in melody_score:
4719
- e[3] = melody_channel
4720
- e[6] = melody_patch
4721
 
4722
- if e[4] < melody_range[0]:
4723
- e[4] = (e[4] % 12) + melody_range[0]
4724
-
4725
- if e[4] >= melody_range[1]:
4726
- e[4] = (e[4] % 12) + (melody_range[1]-12)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4727
 
4728
  return fix_monophonic_score_durations(melody_score)
4729
 
@@ -4960,6 +5004,1361 @@ def patch_enhanced_score_notes(enhanced_score_notes,
4960
 
4961
  ###################################################################################
4962
 
4963
- # This is the end of the TMIDI X Python module
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4964
 
4965
  ###################################################################################
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1761
  plot_size=(11,4),
1762
  note_height = 0.75,
1763
  show_grid_lines=False,
1764
+ return_plt = False,
1765
+ timings_multiplier=1
1766
  ):
1767
 
1768
  '''Tegridy ms SONG plotter/vizualizer'''
 
1775
 
1776
  else:
1777
 
1778
+ start_times = [(s[1] * timings_multiplier) / 1000 for s in notes]
1779
+ durations = [(s[2] * timings_multiplier) / 1000 for s in notes]
1780
  pitches = [s[4] for s in notes]
1781
  patches = [s[6] for s in notes]
1782
 
1783
  colors = generate_colors(max_num_colors)
1784
  colors[drums_color_num] = (1, 1, 1)
1785
 
1786
+ pbl = (notes[preview_length_in_notes][1] * timings_multiplier) / 1000
1787
 
1788
  fig, ax = plt.subplots(figsize=plot_size)
1789
  #fig, ax = plt.subplots()
 
1817
  plt.title(plot_title)
1818
 
1819
  if return_plt:
1820
+ return fig
1821
 
1822
  plt.show()
1823
 
 
1928
 
1929
  ###################################################################################
1930
 
1931
+ def Tegridy_Any_Pickle_File_Reader(input_file_name='TMIDI_Pickle_File', ext='.pickle', verbose=True):
1932
 
1933
  '''Tegridy Pickle File Loader
1934
 
 
1940
  Project Los Angeles
1941
  Tegridy Code 2021'''
1942
 
1943
+ if verbose:
1944
+ print('Tegridy Pickle File Loader')
1945
+ print('Loading the pickle file. Please wait...')
1946
 
1947
  with open(input_file_name + ext, 'rb') as pickle_file:
1948
  content = pickle.load(pickle_file)
1949
 
1950
+ if verbose:
1951
+ print('Done!')
1952
+
1953
  return content
1954
 
1955
  ###################################################################################
 
4712
 
4713
  ###################################################################################
4714
 
4715
+ def stack_list(lst, base=12):
4716
+ return sum(j * base**i for i, j in enumerate(lst[::-1]))
4717
+
4718
+ def destack_list(num, base=12):
4719
+ lst = []
4720
+ while num:
4721
+ lst.append(num % base)
4722
+ num //= base
4723
+ return lst[::-1]
4724
+
4725
+ ###################################################################################
4726
+
4727
  def extract_melody(chordified_enhanced_score,
4728
+ melody_range=[48, 84],
4729
  melody_channel=0,
4730
+ melody_patch=0,
4731
+ melody_velocity=0,
4732
+ stacked_melody=False,
4733
+ stacked_melody_base_pitch=60
4734
  ):
4735
 
4736
+ if stacked_melody:
 
 
 
 
4737
 
4738
+
4739
+ all_pitches_chords = []
4740
+ for e in chordified_enhanced_score:
4741
+ all_pitches_chords.append(sorted(set([p[4] for p in e]), reverse=True))
4742
+
4743
+ melody_score = []
4744
+ for i, chord in enumerate(chordified_enhanced_score):
4745
+
4746
+ if melody_velocity > 0:
4747
+ vel = melody_velocity
4748
+ else:
4749
+ vel = chord[0][5]
4750
+
4751
+ melody_score.append(['note', chord[0][1], chord[0][2], melody_channel, stacked_melody_base_pitch+(stack_list([p % 12 for p in all_pitches_chords[i]]) % 12), vel, melody_patch])
4752
+
4753
+ else:
4754
+
4755
+ melody_score = copy.deepcopy([c[0] for c in chordified_enhanced_score if c[0][3] != 9])
4756
+
4757
+ for e in melody_score:
4758
+
4759
+ e[3] = melody_channel
4760
+
4761
+ if melody_velocity > 0:
4762
+ e[5] = melody_velocity
4763
+
4764
+ e[6] = melody_patch
4765
+
4766
+ if e[4] < melody_range[0]:
4767
+ e[4] = (e[4] % 12) + melody_range[0]
4768
+
4769
+ if e[4] >= melody_range[1]:
4770
+ e[4] = (e[4] % 12) + (melody_range[1]-12)
4771
 
4772
  return fix_monophonic_score_durations(melody_score)
4773
 
 
5004
 
5005
  ###################################################################################
5006
 
5007
+ def create_enhanced_monophonic_melody(monophonic_melody):
5008
+
5009
+ enhanced_monophonic_melody = []
5010
+
5011
+ for i, note in enumerate(monophonic_melody[:-1]):
5012
+
5013
+ enhanced_monophonic_melody.append(note)
5014
+
5015
+ if note[1]+note[2] < monophonic_melody[i+1][1]:
5016
+
5017
+ delta_time = monophonic_melody[i+1][1] - (note[1]+note[2])
5018
+ enhanced_monophonic_melody.append(['silence', note[1]+note[2], delta_time, note[3], 0, 0, note[6]])
5019
+
5020
+ enhanced_monophonic_melody.append(monophonic_melody[-1])
5021
+
5022
+ return enhanced_monophonic_melody
5023
+
5024
+ ###################################################################################
5025
+
5026
+ def frame_monophonic_melody(monophonic_melody, min_frame_time_threshold=10):
5027
+
5028
+ mzip = list(zip(monophonic_melody[:-1], monophonic_melody[1:]))
5029
+
5030
+ times_counts = Counter([(b[1]-a[1]) for a, b in mzip]).most_common()
5031
+
5032
+ mc_time = next((item for item, count in times_counts if item >= min_frame_time_threshold), min_frame_time_threshold)
5033
+
5034
+ times = [(b[1]-a[1]) // mc_time for a, b in mzip] + [monophonic_melody[-1][2] // mc_time]
5035
+
5036
+ framed_melody = []
5037
+
5038
+ for i, note in enumerate(monophonic_melody):
5039
+
5040
+ stime = note[1]
5041
+ count = times[i]
5042
+
5043
+ if count != 0:
5044
+ for j in range(count):
5045
+
5046
+ new_note = copy.deepcopy(note)
5047
+ new_note[1] = stime + (j * mc_time)
5048
+ new_note[2] = mc_time
5049
+ framed_melody.append(new_note)
5050
+
5051
+ else:
5052
+ framed_melody.append(note)
5053
+
5054
+ return [framed_melody, mc_time]
5055
+
5056
+ ###################################################################################
5057
+
5058
+ def delta_score_notes(score_notes,
5059
+ timings_clip_value=255,
5060
+ even_timings=False,
5061
+ compress_timings=False
5062
+ ):
5063
+
5064
+ delta_score = []
5065
+
5066
+ pe = score_notes[0]
5067
+
5068
+ for n in score_notes:
5069
+
5070
+ note = copy.deepcopy(n)
5071
+
5072
+ time = n[1] - pe[1]
5073
+ dur = n[2]
5074
+
5075
+ if even_timings:
5076
+ if time != 0 and time % 2 != 0:
5077
+ time += 1
5078
+ if dur % 2 != 0:
5079
+ dur += 1
5080
+
5081
+ time = max(0, min(timings_clip_value, time))
5082
+ dur = max(0, min(timings_clip_value, dur))
5083
+
5084
+ if compress_timings:
5085
+ time /= 2
5086
+ dur /= 2
5087
+
5088
+ note[1] = int(time)
5089
+ note[2] = int(dur)
5090
+
5091
+ delta_score.append(note)
5092
+
5093
+ pe = n
5094
+
5095
+ return delta_score
5096
+
5097
+ ###################################################################################
5098
+
5099
+ def check_and_fix_chords_in_chordified_score(chordified_score,
5100
+ channels_index=3,
5101
+ pitches_index=4
5102
+ ):
5103
+ fixed_chordified_score = []
5104
+
5105
+ bad_chords_counter = 0
5106
+
5107
+ for c in chordified_score:
5108
+
5109
+ tones_chord = sorted(set([t[pitches_index] % 12 for t in c if t[channels_index] != 9]))
5110
+
5111
+ if tones_chord:
5112
+
5113
+ if tones_chord not in ALL_CHORDS_SORTED:
5114
+ bad_chords_counter += 1
5115
+
5116
+ while tones_chord not in ALL_CHORDS_SORTED:
5117
+ tones_chord.pop(0)
5118
+
5119
+ new_chord = []
5120
+
5121
+ c.sort(key = lambda x: x[pitches_index], reverse=True)
5122
+
5123
+ for e in c:
5124
+ if e[channels_index] != 9:
5125
+ if e[pitches_index] % 12 in tones_chord:
5126
+ new_chord.append(e)
5127
+
5128
+ else:
5129
+ new_chord.append(e)
5130
+
5131
+ fixed_chordified_score.append(new_chord)
5132
+
5133
+ return fixed_chordified_score, bad_chords_counter
5134
+
5135
+ ###################################################################################
5136
+
5137
+ from itertools import combinations, groupby
5138
+
5139
+ ###################################################################################
5140
+
5141
+ def advanced_check_and_fix_chords_in_chordified_score(chordified_score,
5142
+ channels_index=3,
5143
+ pitches_index=4,
5144
+ patches_index=6,
5145
+ use_filtered_chords=True,
5146
+ remove_duplicate_pitches=True,
5147
+ skip_drums=False
5148
+ ):
5149
+ fixed_chordified_score = []
5150
+
5151
+ bad_chords_counter = 0
5152
+ duplicate_pitches_counter = 0
5153
+
5154
+ if use_filtered_chords:
5155
+ CHORDS = ALL_CHORDS_FILTERED
5156
+ else:
5157
+ CHORDS = ALL_CHORDS_SORTED
5158
+
5159
+ for c in chordified_score:
5160
+
5161
+ if remove_duplicate_pitches:
5162
+
5163
+ c.sort(key = lambda x: x[pitches_index], reverse=True)
5164
+
5165
+ seen = set()
5166
+ ddchord = []
5167
+
5168
+ for cc in c:
5169
+ if cc[channels_index] != 9:
5170
+
5171
+ if tuple([cc[pitches_index], cc[patches_index]]) not in seen:
5172
+ ddchord.append(cc)
5173
+ seen.add(tuple([cc[pitches_index], cc[patches_index]]))
5174
+ else:
5175
+ duplicate_pitches_counter += 1
5176
+
5177
+ else:
5178
+ ddchord.append(cc)
5179
+
5180
+ c = copy.deepcopy(ddchord)
5181
+
5182
+ tones_chord = sorted(set([t[pitches_index] % 12 for t in c if t[channels_index] != 9]))
5183
+
5184
+ if tones_chord:
5185
+
5186
+ if tones_chord not in CHORDS:
5187
+
5188
+ pitches_chord = sorted(set([p[pitches_index] for p in c if p[channels_index] != 9]), reverse=True)
5189
+
5190
+ if len(tones_chord) == 2:
5191
+ tones_counts = Counter([p % 12 for p in pitches_chord]).most_common()
5192
+
5193
+ if tones_counts[0][1] > 1:
5194
+ tones_chord = [tones_counts[0][0]]
5195
+ elif tones_counts[1][1] > 1:
5196
+ tones_chord = [tones_counts[1][0]]
5197
+ else:
5198
+ tones_chord = [pitches_chord[0] % 12]
5199
+
5200
+ else:
5201
+ tones_chord_combs = [list(comb) for i in range(len(tones_chord)-2, 0, -1) for comb in combinations(tones_chord, i+1)]
5202
+
5203
+ for co in tones_chord_combs:
5204
+ if co in CHORDS:
5205
+ tones_chord = co
5206
+ break
5207
+
5208
+ bad_chords_counter += 1
5209
+
5210
+ new_chord = []
5211
+
5212
+ c.sort(key = lambda x: x[pitches_index], reverse=True)
5213
+
5214
+ for e in c:
5215
+ if e[channels_index] != 9:
5216
+ if e[pitches_index] % 12 in tones_chord:
5217
+ new_chord.append(e)
5218
+
5219
+ else:
5220
+ if not skip_drums:
5221
+ new_chord.append(e)
5222
+
5223
+ fixed_chordified_score.append(new_chord)
5224
+
5225
+ return fixed_chordified_score, bad_chords_counter, duplicate_pitches_counter
5226
+
5227
+ ###################################################################################
5228
+
5229
+ def score_chord_to_tones_chord(chord,
5230
+ transpose_value=0,
5231
+ channels_index=3,
5232
+ pitches_index=4):
5233
+
5234
+ return sorted(set([(p[4]+transpose_value) % 12 for p in chord if p[channels_index] != 9]))
5235
+
5236
+ ###################################################################################
5237
+
5238
+ def grouped_set(seq):
5239
+ return [k for k, v in groupby(seq)]
5240
+
5241
+ ###################################################################################
5242
+
5243
+ def ordered_set(seq):
5244
+ dic = {}
5245
+ return [k for k, v in dic.fromkeys(seq).items()]
5246
+
5247
+ ###################################################################################
5248
+
5249
+ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
5250
+ melody_start_time=0,
5251
+ melody_start_chord=0,
5252
+ melody_notes_min_duration=-1,
5253
+ melody_notes_max_duration=255,
5254
+ melody_duration_overlap_tolerance=4,
5255
+ melody_avg_duration_divider=2,
5256
+ melody_base_octave=5,
5257
+ melody_channel=3,
5258
+ melody_patch=40,
5259
+ melody_max_velocity=110,
5260
+ acc_max_velocity=90,
5261
+ pass_drums=True
5262
+ ):
5263
+
5264
+ if pass_drums:
5265
+ score = copy.deepcopy(enhanced_score_notes)
5266
+ else:
5267
+ score = [e for e in copy.deepcopy(enhanced_score_notes) if e[3] !=9]
5268
+
5269
+ if melody_notes_min_duration > 0:
5270
+ min_duration = melody_notes_min_duration
5271
+ else:
5272
+ durs = [d[2] for d in score]
5273
+ min_duration = Counter(durs).most_common()[0][0]
5274
+
5275
+ adjust_score_velocities(score, acc_max_velocity)
5276
+
5277
+ cscore = chordify_score([1000, score])
5278
+
5279
+ melody_score = []
5280
+ acc_score = []
5281
+
5282
+ pt = melody_start_time
5283
+
5284
+ for c in cscore[:melody_start_chord]:
5285
+ acc_score.extend(c)
5286
+
5287
+ for c in cscore[melody_start_chord:]:
5288
+
5289
+ durs = [d[2] if d[3] != 9 else -1 for d in c]
5290
+
5291
+ if not all(d == -1 for d in durs):
5292
+ ndurs = [d for d in durs if d != -1]
5293
+ avg_dur = (sum(ndurs) / len(ndurs)) / melody_avg_duration_divider
5294
+ best_dur = min(durs, key=lambda x:abs(x-avg_dur))
5295
+ pidx = durs.index(best_dur)
5296
+
5297
+ cc = copy.deepcopy(c[pidx])
5298
+
5299
+ if c[0][1] >= pt - melody_duration_overlap_tolerance and best_dur >= min_duration:
5300
+
5301
+ cc[3] = melody_channel
5302
+ cc[4] = (c[pidx][4] % 24)
5303
+ cc[5] = 100 + ((c[pidx][4] % 12) * 2)
5304
+ cc[6] = melody_patch
5305
+
5306
+ melody_score.append(cc)
5307
+ acc_score.extend(c)
5308
+
5309
+ pt = c[0][1]+c[pidx][2]
5310
+
5311
+ else:
5312
+ acc_score.extend(c)
5313
+
5314
+ else:
5315
+ acc_score.extend(c)
5316
+
5317
+ values = [e[4] % 24 for e in melody_score]
5318
+ smoothed = [values[0]]
5319
+ for i in range(1, len(values)):
5320
+ if abs(smoothed[-1] - values[i]) >= 12:
5321
+ if smoothed[-1] < values[i]:
5322
+ smoothed.append(values[i] - 12)
5323
+ else:
5324
+ smoothed.append(values[i] + 12)
5325
+ else:
5326
+ smoothed.append(values[i])
5327
+
5328
+ smoothed_melody = copy.deepcopy(melody_score)
5329
+
5330
+ for i, e in enumerate(smoothed_melody):
5331
+ e[4] = (melody_base_octave * 12) + smoothed[i]
5332
+
5333
+ for i, m in enumerate(smoothed_melody[1:]):
5334
+ if m[1] - smoothed_melody[i][1] < melody_notes_max_duration:
5335
+ smoothed_melody[i][2] = m[1] - smoothed_melody[i][1]
5336
+
5337
+ adjust_score_velocities(smoothed_melody, melody_max_velocity)
5338
+
5339
+ final_score = sorted(smoothed_melody + acc_score, key=lambda x: (x[1], -x[4]))
5340
+
5341
+ return final_score
5342
+
5343
+ ###################################################################################
5344
+
5345
+ def find_paths(list_of_lists, path=[]):
5346
+ if not list_of_lists:
5347
+ return [path]
5348
+ return [p for sublist in list_of_lists[0] for p in find_paths(list_of_lists[1:], path+[sublist])]
5349
+
5350
+ ###################################################################################
5351
+
5352
+ def recalculate_score_timings(score, start_time=0):
5353
+
5354
+ rscore = copy.deepcopy(score)
5355
+
5356
+ pe = rscore[0]
5357
+
5358
+ abs_time = start_time
5359
+
5360
+ for e in rscore:
5361
+
5362
+ dtime = e[1] - pe[1]
5363
+ pe = copy.deepcopy(e)
5364
+ abs_time += dtime
5365
+ e[1] = abs_time
5366
+
5367
+ return rscore
5368
+
5369
+ ###################################################################################
5370
+
5371
+ WHITE_NOTES = [0, 2, 4, 5, 7, 9, 11]
5372
+ BLACK_NOTES = [1, 3, 6, 8, 10]
5373
+
5374
+ ###################################################################################
5375
+
5376
+ ALL_CHORDS_FILTERED = [[0], [0, 3], [0, 3, 5], [0, 3, 5, 8], [0, 3, 5, 9], [0, 3, 5, 10], [0, 3, 7],
5377
+ [0, 3, 7, 10], [0, 3, 8], [0, 3, 9], [0, 3, 10], [0, 4], [0, 4, 6],
5378
+ [0, 4, 6, 9], [0, 4, 6, 10], [0, 4, 7], [0, 4, 7, 10], [0, 4, 8], [0, 4, 9],
5379
+ [0, 4, 10], [0, 5], [0, 5, 8], [0, 5, 9], [0, 5, 10], [0, 6], [0, 6, 9],
5380
+ [0, 6, 10], [0, 7], [0, 7, 10], [0, 8], [0, 9], [0, 10], [1], [1, 4],
5381
+ [1, 4, 6], [1, 4, 6, 9], [1, 4, 6, 10], [1, 4, 6, 11], [1, 4, 7],
5382
+ [1, 4, 7, 10], [1, 4, 7, 11], [1, 4, 8], [1, 4, 8, 11], [1, 4, 9], [1, 4, 10],
5383
+ [1, 4, 11], [1, 5], [1, 5, 8], [1, 5, 8, 11], [1, 5, 9], [1, 5, 10],
5384
+ [1, 5, 11], [1, 6], [1, 6, 9], [1, 6, 10], [1, 6, 11], [1, 7], [1, 7, 10],
5385
+ [1, 7, 11], [1, 8], [1, 8, 11], [1, 9], [1, 10], [1, 11], [2], [2, 5],
5386
+ [2, 5, 8], [2, 5, 8, 11], [2, 5, 9], [2, 5, 10], [2, 5, 11], [2, 6], [2, 6, 9],
5387
+ [2, 6, 10], [2, 6, 11], [2, 7], [2, 7, 10], [2, 7, 11], [2, 8], [2, 8, 11],
5388
+ [2, 9], [2, 10], [2, 11], [3], [3, 5], [3, 5, 8], [3, 5, 8, 11], [3, 5, 9],
5389
+ [3, 5, 10], [3, 5, 11], [3, 7], [3, 7, 10], [3, 7, 11], [3, 8], [3, 8, 11],
5390
+ [3, 9], [3, 10], [3, 11], [4], [4, 6], [4, 6, 9], [4, 6, 10], [4, 6, 11],
5391
+ [4, 7], [4, 7, 10], [4, 7, 11], [4, 8], [4, 8, 11], [4, 9], [4, 10], [4, 11],
5392
+ [5], [5, 8], [5, 8, 11], [5, 9], [5, 10], [5, 11], [6], [6, 9], [6, 10],
5393
+ [6, 11], [7], [7, 10], [7, 11], [8], [8, 11], [9], [10], [11]]
5394
+
5395
+ ###################################################################################
5396
+
5397
+ def harmonize_enhanced_melody_score_notes(enhanced_melody_score_notes):
5398
+
5399
+ mel_tones = [e[4] % 12 for e in enhanced_melody_score_notes]
5400
+
5401
+ cur_chord = []
5402
+
5403
+ song = []
5404
+
5405
+ for i, m in enumerate(mel_tones):
5406
+ cur_chord.append(m)
5407
+ cc = sorted(set(cur_chord))
5408
+
5409
+ if cc in ALL_CHORDS_FILTERED:
5410
+ song.append(cc)
5411
+
5412
+ else:
5413
+ while sorted(set(cur_chord)) not in ALL_CHORDS_FILTERED:
5414
+ cur_chord.pop(0)
5415
+ cc = sorted(set(cur_chord))
5416
+ song.append(cc)
5417
+
5418
+ return song
5419
 
5420
  ###################################################################################
5421
+
5422
+ def split_melody(enhanced_melody_score_notes,
5423
+ split_time=-1,
5424
+ max_score_time=255
5425
+ ):
5426
+
5427
+ mel_chunks = []
5428
+
5429
+ if split_time == -1:
5430
+
5431
+ durs = [max(0, min(max_score_time, e[2])) for e in enhanced_melody_score_notes]
5432
+ stime = max(durs)
5433
+
5434
+ else:
5435
+ stime = split_time
5436
+
5437
+ pe = enhanced_melody_score_notes[0]
5438
+ chu = []
5439
+
5440
+ for e in enhanced_melody_score_notes:
5441
+ dtime = max(0, min(max_score_time, e[1]-pe[1]))
5442
+
5443
+ if dtime > max(durs):
5444
+ if chu:
5445
+ mel_chunks.append(chu)
5446
+ chu = []
5447
+ chu.append(e)
5448
+ else:
5449
+ chu.append(e)
5450
+
5451
+ pe = e
5452
+
5453
+ if chu:
5454
+ mel_chunks.append(chu)
5455
+
5456
+ return mel_chunks, [[m[0][1], m[-1][1]] for m in mel_chunks], len(mel_chunks)
5457
+
5458
+ ###################################################################################
5459
+
5460
+ def flatten(list_of_lists):
5461
+ return [x for y in list_of_lists for x in y]
5462
+
5463
+ ###################################################################################
5464
+
5465
+ def enhanced_delta_score_notes(enhanced_score_notes,
5466
+ start_time=0,
5467
+ max_score_time=255
5468
+ ):
5469
+
5470
+ delta_score = []
5471
+
5472
+ pe = ['note', max(0, enhanced_score_notes[0][1]-start_time)]
5473
+
5474
+ for e in enhanced_score_notes:
5475
+
5476
+ dtime = max(0, min(max_score_time, e[1]-pe[1]))
5477
+ dur = max(1, min(max_score_time, e[2]))
5478
+ cha = max(0, min(15, e[3]))
5479
+ ptc = max(1, min(127, e[4]))
5480
+ vel = max(1, min(127, e[5]))
5481
+ pat = max(0, min(128, e[6]))
5482
+
5483
+ delta_score.append([dtime, dur, cha, ptc, vel, pat])
5484
+
5485
+ pe = e
5486
+
5487
+ return delta_score
5488
+
5489
+ ###################################################################################
5490
+
5491
+ def basic_enhanced_delta_score_notes_tokenizer(enhanced_delta_score_notes,
5492
+ tokenize_start_times=True,
5493
+ tokenize_durations=True,
5494
+ tokenize_channels=True,
5495
+ tokenize_pitches=True,
5496
+ tokenize_velocities=True,
5497
+ tokenize_patches=True,
5498
+ score_timings_range=256,
5499
+ max_seq_len=-1,
5500
+ seq_pad_value=-1
5501
+ ):
5502
+
5503
+
5504
+
5505
+ score_tokens_ints_seq = []
5506
+
5507
+ tokens_shifts = [-1] * 7
5508
+
5509
+ for d in enhanced_delta_score_notes:
5510
+
5511
+ seq = []
5512
+ shift = 0
5513
+
5514
+ if tokenize_start_times:
5515
+ seq.append(d[0])
5516
+ tokens_shifts[0] = shift
5517
+ shift += score_timings_range
5518
+
5519
+ if tokenize_durations:
5520
+ seq.append(d[1]+shift)
5521
+ tokens_shifts[1] = shift
5522
+ shift += score_timings_range
5523
+
5524
+ if tokenize_channels:
5525
+ tokens_shifts[2] = shift
5526
+ seq.append(d[2]+shift)
5527
+ shift += 16
5528
+
5529
+ if tokenize_pitches:
5530
+ tokens_shifts[3] = shift
5531
+ seq.append(d[3]+shift)
5532
+ shift += 128
5533
+
5534
+ if tokenize_velocities:
5535
+ tokens_shifts[4] = shift
5536
+ seq.append(d[4]+shift)
5537
+ shift += 128
5538
+
5539
+ if tokenize_patches:
5540
+ tokens_shifts[5] = shift
5541
+ seq.append(d[5]+shift)
5542
+ shift += 129
5543
+
5544
+ tokens_shifts[6] = shift
5545
+ score_tokens_ints_seq.append(seq)
5546
+
5547
+ final_score_tokens_ints_seq = flatten(score_tokens_ints_seq)
5548
+
5549
+ if max_seq_len > -1:
5550
+ final_score_tokens_ints_seq = flat_score_tokens_ints_seq[:max_seq_len]
5551
+
5552
+ if seq_pad_value > -1:
5553
+ final_score_tokens_ints_seq += [seq_pad_value] * (max_seq_len - len(final_score_tokens_ints_seq))
5554
+
5555
+ return [score_tokens_ints_seq,
5556
+ final_score_tokens_ints_seq,
5557
+ tokens_shifts,
5558
+ seq_pad_value,
5559
+ max_seq_len,
5560
+ len(score_tokens_ints_seq),
5561
+ len(final_score_tokens_ints_seq)
5562
+ ]
5563
+
5564
+ ###################################################################################
5565
+
5566
+ def basic_enhanced_delta_score_notes_detokenizer(tokenized_seq,
5567
+ tokens_shifts,
5568
+ timings_multiplier=16
5569
+ ):
5570
+
5571
+ song_f = []
5572
+
5573
+ time = 0
5574
+ dur = 16
5575
+ channel = 0
5576
+ pitch = 60
5577
+ vel = 90
5578
+ pat = 0
5579
+
5580
+ note_seq_len = len([t for t in tokens_shifts if t > -1])-1
5581
+ tok_shifts_idxs = [i for i in range(len(tokens_shifts[:-1])) if tokens_shifts[i] > - 1]
5582
+
5583
+ song = []
5584
+
5585
+ for i in range(0, len(tokenized_seq), note_seq_len):
5586
+ note = tokenized_seq[i:i+note_seq_len]
5587
+ song.append(note)
5588
+
5589
+ for note in song:
5590
+ for i, idx in enumerate(tok_shifts_idxs):
5591
+ if idx == 0:
5592
+ time += (note[i]-tokens_shifts[0]) * timings_multiplier
5593
+ elif idx == 1:
5594
+ dur = (note[i]-tokens_shifts[1]) * timings_multiplier
5595
+ elif idx == 2:
5596
+ channel = (note[i]-tokens_shifts[2])
5597
+ elif idx == 3:
5598
+ pitch = (note[i]-tokens_shifts[3])
5599
+ elif idx == 4:
5600
+ vel = (note[i]-tokens_shifts[4])
5601
+ elif idx == 5:
5602
+ pat = (note[i]-tokens_shifts[5])
5603
+
5604
+ song_f.append(['note', time, dur, channel, pitch, vel, pat ])
5605
+
5606
+ return song_f
5607
+
5608
+ ###################################################################################
5609
+
5610
+ def enhanced_chord_to_chord_token(enhanced_chord,
5611
+ channels_index=3,
5612
+ pitches_index=4,
5613
+ use_filtered_chords=True
5614
+ ):
5615
+
5616
+ bad_chords_counter = 0
5617
+ duplicate_pitches_counter = 0
5618
+
5619
+ if use_filtered_chords:
5620
+ CHORDS = ALL_CHORDS_FILTERED
5621
+ else:
5622
+ CHORDS = ALL_CHORDS_SORTED
5623
+
5624
+ tones_chord = sorted(set([t[pitches_index] % 12 for t in enhanced_chord if t[channels_index] != 9]))
5625
+
5626
+ original_tones_chord = copy.deepcopy(tones_chord)
5627
+
5628
+ if tones_chord:
5629
+
5630
+ if tones_chord not in CHORDS:
5631
+
5632
+ pitches_chord = sorted(set([p[pitches_index] for p in enhanced_chord if p[channels_index] != 9]), reverse=True)
5633
+
5634
+ if len(tones_chord) == 2:
5635
+ tones_counts = Counter([p % 12 for p in pitches_chord]).most_common()
5636
+
5637
+ if tones_counts[0][1] > 1:
5638
+ tones_chord = [tones_counts[0][0]]
5639
+ elif tones_counts[1][1] > 1:
5640
+ tones_chord = [tones_counts[1][0]]
5641
+ else:
5642
+ tones_chord = [pitches_chord[0] % 12]
5643
+
5644
+ else:
5645
+ tones_chord_combs = [list(comb) for i in range(len(tones_chord)-2, 0, -1) for comb in combinations(tones_chord, i+1)]
5646
+
5647
+ for co in tones_chord_combs:
5648
+ if co in CHORDS:
5649
+ tones_chord = co
5650
+ break
5651
+
5652
+ if use_filtered_chords:
5653
+ chord_token = ALL_CHORDS_FILTERED.index(tones_chord)
5654
+ else:
5655
+ chord_token = ALL_CHORDS_SORTED.index(tones_chord)
5656
+
5657
+ return [chord_token, tones_chord, original_tones_chord, sorted(set(original_tones_chord) ^ set(tones_chord))]
5658
+
5659
+ ###################################################################################
5660
+
5661
+ def enhanced_chord_to_tones_chord(enhanced_chord):
5662
+ return sorted(set([t[4] % 12 for t in enhanced_chord if t[3] != 9]))
5663
+
5664
+ ###################################################################################
5665
+
5666
+ import hashlib
5667
+
5668
+ ###################################################################################
5669
+
5670
+ def md5_hash(file_path_or_data=None, original_md5_hash=None):
5671
+
5672
+ if type(file_path_or_data) == str:
5673
+
5674
+ with open(file_path_or_data, 'rb') as file_to_check:
5675
+ data = file_to_check.read()
5676
+
5677
+ if data:
5678
+ md5 = hashlib.md5(data).hexdigest()
5679
+
5680
+ else:
5681
+ if file_path_or_data:
5682
+ md5 = hashlib.md5(file_path_or_data).hexdigest()
5683
+
5684
+ if md5:
5685
+
5686
+ if original_md5_hash:
5687
+
5688
+ if md5 == original_md5_hash:
5689
+ check = True
5690
+ else:
5691
+ check = False
5692
+
5693
+ else:
5694
+ check = None
5695
+
5696
+ return [md5, check]
5697
+
5698
+ else:
5699
+
5700
+ md5 = None
5701
+ check = None
5702
+
5703
+ return [md5, check]
5704
+
5705
+ ###################################################################################
5706
+
5707
+ ALL_PITCHES_CHORDS_FILTERED = [[67], [64], [62], [69], [60], [65], [59], [70], [66], [63], [68], [61],
5708
+ [64, 60], [67, 64], [65, 62], [62, 59], [69, 65], [60, 57], [66, 62], [59, 55],
5709
+ [62, 57], [67, 62], [64, 59], [64, 60, 55], [60, 55], [65, 60], [64, 61],
5710
+ [69, 64], [66, 62, 57], [69, 66], [62, 59, 55], [64, 60, 57], [62, 58],
5711
+ [65, 60, 57], [70, 67], [67, 63], [64, 61, 57], [61, 57], [63, 60], [68, 64],
5712
+ [65, 62, 58], [65, 62, 57], [59, 56], [63, 58], [68, 65], [59, 54, 47, 35],
5713
+ [70, 65], [66, 61], [64, 59, 56], [65, 61], [64, 59, 55], [63, 59], [61, 58],
5714
+ [68, 63], [60, 56], [67, 63, 60], [67, 63, 58], [66, 62, 59], [61, 56],
5715
+ [70, 66], [67, 62, 58], [63, 60, 56], [65, 61, 56], [66, 61, 58], [66, 61, 57],
5716
+ [65, 60, 56], [65, 61, 58], [65, 59], [68, 64, 61], [66, 60], [64, 58],
5717
+ [62, 56], [63, 57], [61, 55], [66, 64], [60, 58], [65, 63], [63, 59, 56],
5718
+ [65, 62, 59], [61, 59], [66, 60, 57], [64, 61, 55], [64, 58, 55], [62, 59, 56],
5719
+ [64, 60, 58], [63, 60, 57], [64, 60, 58, 55], [65, 62, 56], [64, 61, 58],
5720
+ [66, 64, 59], [60, 58, 55], [65, 63, 60], [63, 57, 53], [65, 63, 60, 57],
5721
+ [65, 59, 56], [63, 60, 58, 55], [67, 61, 58], [64, 61, 57, 54], [64, 61, 59],
5722
+ [70, 65, 60], [68, 65, 63, 60], [63, 60, 58], [65, 63, 58], [69, 66, 64],
5723
+ [64, 60, 54], [64, 60, 57, 54], [66, 64, 61], [66, 61, 59], [67, 63, 59],
5724
+ [65, 61, 57], [68, 65, 63], [64, 61, 59, 56], [65, 61, 59], [66, 64, 61, 58],
5725
+ [64, 61, 58, 55], [64, 60, 56], [65, 61, 59, 56], [66, 62, 58], [61, 59, 56],
5726
+ [64, 58, 54], [63, 59, 53], [65, 62, 59, 56], [61, 59, 55], [64, 61, 59, 55],
5727
+ [68, 65, 63, 59], [70, 66, 60], [65, 63, 60, 58], [64, 61, 59, 54],
5728
+ [70, 64, 60, 54]]
5729
+
5730
+ ###################################################################################
5731
+
5732
+ ALL_PITCHES_CHORDS_SORTED = [[60], [62, 60], [63, 60], [64, 60], [64, 62, 60], [65, 60], [65, 62, 60],
5733
+ [65, 63, 60], [66, 60], [66, 62, 60], [66, 63, 60], [64, 60, 54],
5734
+ [64, 60, 54, 50], [60, 55], [67, 62, 60], [67, 63, 60], [64, 60, 55],
5735
+ [65, 60, 55], [64, 62, 60, 55], [67, 65, 62, 60], [67, 65, 63, 60], [60, 56],
5736
+ [62, 60, 56], [63, 60, 56], [64, 60, 56], [65, 60, 56], [66, 60, 56],
5737
+ [72, 68, 64, 62], [65, 62, 60, 56], [66, 62, 60, 56], [68, 65, 63, 60],
5738
+ [68, 66, 63, 60], [60, 44, 42, 40], [88, 80, 74, 66, 60, 56], [60, 57],
5739
+ [62, 60, 57], [63, 60, 57], [64, 60, 57], [65, 60, 57], [66, 60, 57],
5740
+ [67, 60, 57], [64, 62, 60, 57], [65, 62, 60, 57], [69, 66, 62, 60],
5741
+ [67, 62, 60, 57], [65, 63, 60, 57], [66, 63, 60, 57], [67, 63, 60, 57],
5742
+ [64, 60, 57, 54], [67, 64, 60, 57], [67, 65, 60, 57], [69, 64, 60, 54, 38],
5743
+ [67, 64, 62, 60, 57], [67, 65, 62, 60, 57], [67, 65, 63, 60, 57], [60, 58],
5744
+ [62, 60, 58], [63, 60, 58], [64, 60, 58], [70, 65, 60], [70, 66, 60],
5745
+ [60, 58, 55], [70, 60, 56], [74, 64, 60, 58], [65, 62, 60, 58],
5746
+ [70, 66, 62, 60], [62, 60, 58, 55], [72, 68, 62, 58], [65, 63, 60, 58],
5747
+ [70, 66, 63, 60], [63, 60, 58, 55], [70, 63, 60, 56], [70, 64, 60, 54],
5748
+ [64, 60, 58, 55], [68, 64, 60, 58], [65, 60, 58, 55], [70, 65, 60, 56],
5749
+ [70, 66, 60, 56], [78, 76, 74, 72, 70, 66], [67, 64, 62, 58, 36],
5750
+ [74, 68, 64, 58, 48], [65, 62, 58, 55, 36], [65, 62, 60, 56, 46],
5751
+ [72, 66, 62, 56, 46], [79, 65, 63, 58, 53, 36], [65, 60, 56, 51, 46, 41],
5752
+ [70, 66, 63, 60, 44], [68, 66, 64, 58, 56, 48],
5753
+ [94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58,
5754
+ 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24],
5755
+ [61], [63, 61], [64, 61], [65, 61], [65, 63, 61], [66, 61], [66, 63, 61],
5756
+ [66, 64, 61], [61, 55], [67, 63, 61], [64, 61, 55], [65, 61, 55],
5757
+ [65, 61, 55, 39], [61, 56], [63, 61, 56], [68, 64, 61], [65, 61, 56],
5758
+ [66, 61, 56], [68, 65, 63, 61], [54, 49, 44, 39], [68, 64, 61, 42], [61, 57],
5759
+ [63, 61, 57], [64, 61, 57], [65, 61, 57], [66, 61, 57], [67, 61, 57],
5760
+ [69, 65, 63, 61], [66, 63, 61, 57], [67, 63, 61, 57], [64, 61, 57, 54],
5761
+ [67, 64, 61, 57], [65, 61, 55, 45], [67, 65, 63, 61, 57], [61, 58],
5762
+ [63, 61, 58], [64, 61, 58], [65, 61, 58], [66, 61, 58], [67, 61, 58],
5763
+ [61, 58, 56], [65, 63, 61, 58], [66, 63, 61, 58], [67, 63, 61, 58],
5764
+ [63, 61, 58, 56], [66, 64, 61, 58], [64, 61, 58, 55], [68, 64, 61, 58],
5765
+ [65, 61, 58, 55], [65, 61, 58, 56], [58, 54, 49, 44], [70, 65, 61, 55, 39],
5766
+ [80, 68, 65, 63, 61, 58], [63, 58, 54, 49, 44, 39], [73, 68, 64, 58, 54],
5767
+ [61, 59], [63, 61, 59], [64, 61, 59], [65, 61, 59], [66, 61, 59], [61, 59, 55],
5768
+ [61, 59, 56], [61, 59, 57], [63, 59, 53, 49], [66, 63, 61, 59],
5769
+ [71, 67, 63, 61], [63, 61, 59, 56], [61, 57, 51, 47], [64, 61, 59, 54],
5770
+ [64, 61, 59, 55], [64, 61, 59, 56], [64, 61, 59, 57], [65, 61, 59, 55],
5771
+ [65, 61, 59, 56], [69, 65, 61, 59], [66, 61, 59, 56], [71, 66, 61, 57],
5772
+ [71, 67, 61, 57], [67, 63, 59, 53, 49], [68, 65, 63, 59, 37],
5773
+ [65, 63, 61, 59, 57], [66, 63, 61, 59, 56], [73, 69, 66, 63, 59],
5774
+ [79, 75, 73, 61, 59, 33], [61, 56, 52, 47, 42, 35], [76, 73, 69, 66, 35],
5775
+ [71, 67, 64, 61, 57], [73, 71, 69, 67, 65],
5776
+ [95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59,
5777
+ 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25],
5778
+ [62], [64, 62], [65, 62], [66, 62], [66, 64, 62], [67, 62], [67, 64, 62],
5779
+ [67, 65, 62], [62, 56], [68, 64, 62], [65, 62, 56], [66, 62, 56],
5780
+ [66, 62, 56, 52], [62, 57], [50, 45, 40], [65, 62, 57], [66, 62, 57],
5781
+ [55, 50, 45], [66, 64, 62, 57], [55, 50, 45, 40], [69, 67, 65, 62], [62, 58],
5782
+ [64, 62, 58], [65, 62, 58], [66, 62, 58], [67, 62, 58], [62, 58, 56],
5783
+ [66, 64, 62, 58], [67, 64, 62, 58], [64, 62, 58, 56], [65, 62, 58, 55],
5784
+ [65, 62, 58, 56], [66, 62, 58, 56], [66, 64, 58, 44, 38], [62, 59],
5785
+ [64, 62, 59], [65, 62, 59], [66, 62, 59], [62, 59, 55], [62, 59, 56],
5786
+ [62, 59, 57], [66, 64, 62, 59], [67, 64, 62, 59], [64, 62, 59, 56],
5787
+ [64, 62, 59, 57], [67, 65, 62, 59], [65, 62, 59, 56], [69, 65, 62, 59],
5788
+ [66, 62, 59, 56], [69, 66, 62, 59], [59, 55, 50, 45], [64, 62, 59, 56, 54],
5789
+ [69, 66, 62, 59, 40], [64, 59, 55, 50, 45, 40], [69, 65, 62, 59, 55], [63],
5790
+ [65, 63], [66, 63], [67, 63], [67, 65, 63], [68, 63], [68, 65, 63],
5791
+ [68, 66, 63], [63, 57], [63, 57, 53], [66, 63, 57], [67, 63, 57],
5792
+ [67, 63, 57, 53], [63, 58], [65, 63, 58], [66, 63, 58], [67, 63, 58],
5793
+ [68, 63, 58], [67, 65, 63, 58], [63, 58, 56, 53], [70, 68, 66, 63], [63, 59],
5794
+ [63, 59, 53], [66, 63, 59], [67, 63, 59], [63, 59, 56], [63, 59, 57],
5795
+ [63, 59, 55, 53], [68, 65, 63, 59], [69, 65, 63, 59], [66, 63, 59, 56],
5796
+ [66, 63, 59, 57], [67, 63, 59, 57], [67, 63, 59, 57, 41], [64], [66, 64],
5797
+ [67, 64], [68, 64], [68, 66, 64], [69, 64], [69, 66, 64], [69, 67, 64],
5798
+ [64, 58], [64, 58, 54], [64, 58, 55], [68, 64, 58], [68, 64, 58, 42], [64, 59],
5799
+ [66, 64, 59], [64, 59, 55], [64, 59, 56], [64, 59, 57], [64, 59, 56, 54],
5800
+ [64, 59, 57, 54], [69, 64, 59, 55], [65], [67, 65], [68, 65], [69, 65],
5801
+ [69, 67, 65], [70, 65], [65, 58, 55], [70, 68, 65], [65, 59], [65, 59, 55],
5802
+ [65, 59, 56], [59, 57, 53], [69, 65, 59, 55], [66], [68, 66], [69, 66],
5803
+ [70, 66], [80, 70, 54], [59, 54, 47, 35], [66, 59, 56], [71, 69, 66], [67],
5804
+ [69, 67], [70, 67], [59, 55], [71, 69, 67], [68], [70, 68], [59, 56], [69],
5805
+ [71, 69], [70], [59]]
5806
+
5807
+ ###################################################################################
5808
+
5809
+ def sort_list_by_other(list1, list2):
5810
+ return sorted(list1, key=lambda x: list2.index(x) if x in list2 else len(list2))
5811
+
5812
+ ###################################################################################
5813
+
5814
+ ALL_CHORDS_PAIRS_SORTED = [[[0], [0, 4, 7]], [[0, 2], [0, 4, 7]], [[0, 3], [0, 3, 7]],
5815
+ [[0, 4], [0, 4, 7]], [[0, 2, 4], [0, 2, 4, 7]], [[0, 5], [0, 5, 9]],
5816
+ [[0, 2, 5], [0, 2, 5, 9]], [[0, 3, 5], [0, 3, 5, 9]], [[0, 6], [0, 2, 6, 9]],
5817
+ [[0, 2, 6], [0, 2, 6, 9]], [[0, 3, 6], [0, 3, 6, 8]],
5818
+ [[0, 4, 6], [0, 4, 6, 9]], [[0, 2, 4, 6], [0, 2, 4, 6, 9]],
5819
+ [[0, 7], [0, 4, 7]], [[0, 2, 7], [0, 2, 4, 7]], [[0, 3, 7], [0, 3, 7, 10]],
5820
+ [[0, 4, 7], [0, 4, 7, 9]], [[0, 5, 7], [0, 5, 7, 9]],
5821
+ [[0, 2, 4, 7], [0, 2, 4, 7, 9]], [[0, 2, 5, 7], [0, 2, 5, 7, 9]],
5822
+ [[0, 3, 5, 7], [0, 3, 5, 7, 10]], [[0, 8], [0, 3, 8]],
5823
+ [[0, 2, 8], [0, 2, 5, 8]], [[0, 3, 8], [0, 3, 5, 8]],
5824
+ [[0, 4, 8], [2, 4, 8, 11]], [[0, 5, 8], [0, 3, 5, 8]],
5825
+ [[0, 6, 8], [0, 3, 6, 8]], [[0, 2, 4, 8], [0, 2, 4, 6, 8]],
5826
+ [[0, 2, 5, 8], [0, 2, 5, 8, 10]], [[0, 2, 6, 8], [0, 2, 6, 8, 10]],
5827
+ [[0, 3, 5, 8], [0, 3, 5, 8, 10]], [[0, 3, 6, 8], [0, 3, 6, 8, 10]],
5828
+ [[0, 4, 6, 8], [2, 4, 6, 8, 11]], [[0, 2, 4, 6, 8], [2, 4, 6, 8, 11]],
5829
+ [[0, 9], [0, 4, 9]], [[0, 2, 9], [0, 2, 6, 9]], [[0, 3, 9], [0, 3, 5, 9]],
5830
+ [[0, 4, 9], [0, 4, 7, 9]], [[0, 5, 9], [0, 2, 5, 9]],
5831
+ [[0, 6, 9], [0, 2, 6, 9]], [[0, 7, 9], [0, 4, 7, 9]],
5832
+ [[0, 2, 4, 9], [0, 2, 4, 7, 9]], [[0, 2, 5, 9], [0, 2, 5, 7, 9]],
5833
+ [[0, 2, 6, 9], [0, 2, 4, 6, 9]], [[0, 2, 7, 9], [0, 2, 4, 7, 9]],
5834
+ [[0, 3, 5, 9], [0, 3, 5, 7, 9]], [[0, 3, 6, 9], [0, 2, 4, 6, 9]],
5835
+ [[0, 3, 7, 9], [0, 3, 5, 7, 9]], [[0, 4, 6, 9], [0, 2, 4, 6, 9]],
5836
+ [[0, 4, 7, 9], [0, 2, 4, 7, 9]], [[0, 5, 7, 9], [0, 2, 5, 7, 9]],
5837
+ [[0, 2, 4, 6, 9], [2, 4, 6, 9, 11]], [[0, 2, 4, 7, 9], [2, 4, 7, 9, 11]],
5838
+ [[0, 2, 5, 7, 9], [2, 5, 7, 9, 11]], [[0, 3, 5, 7, 9], [2, 4, 6, 8, 11]],
5839
+ [[0, 10], [2, 5, 10]], [[0, 2, 10], [0, 2, 5, 10]],
5840
+ [[0, 3, 10], [0, 3, 7, 10]], [[0, 4, 10], [0, 4, 7, 10]],
5841
+ [[0, 5, 10], [0, 2, 5, 10]], [[0, 6, 10], [0, 3, 6, 10]],
5842
+ [[0, 7, 10], [0, 4, 7, 10]], [[0, 8, 10], [0, 3, 8, 10]],
5843
+ [[0, 2, 4, 10], [0, 2, 4, 7, 10]], [[0, 2, 5, 10], [0, 2, 5, 7, 10]],
5844
+ [[0, 2, 6, 10], [0, 2, 6, 8, 10]], [[0, 2, 7, 10], [0, 2, 5, 7, 10]],
5845
+ [[0, 2, 8, 10], [0, 2, 5, 8, 10]], [[0, 3, 5, 10], [0, 3, 5, 7, 10]],
5846
+ [[0, 3, 6, 10], [0, 3, 6, 8, 10]], [[0, 3, 7, 10], [0, 3, 5, 7, 10]],
5847
+ [[0, 3, 8, 10], [0, 3, 5, 8, 10]], [[0, 4, 6, 10], [0, 2, 4, 6, 10]],
5848
+ [[0, 4, 7, 10], [0, 2, 4, 7, 10]], [[0, 4, 8, 10], [0, 2, 4, 8, 10]],
5849
+ [[0, 5, 7, 10], [0, 3, 5, 7, 10]], [[0, 5, 8, 10], [0, 3, 5, 8, 10]],
5850
+ [[0, 6, 8, 10], [0, 3, 6, 8, 10]], [[0, 2, 4, 6, 10], [0, 2, 4, 8, 10]],
5851
+ [[0, 2, 4, 7, 10], [1, 3, 6, 9, 11]], [[0, 2, 4, 8, 10], [1, 3, 7, 9, 11]],
5852
+ [[0, 2, 5, 7, 10], [0, 3, 5, 7, 10]], [[0, 2, 5, 8, 10], [1, 4, 7, 9, 11]],
5853
+ [[0, 2, 6, 8, 10], [2, 4, 6, 8, 10]], [[0, 3, 5, 7, 10], [0, 2, 5, 7, 10]],
5854
+ [[0, 3, 5, 8, 10], [1, 3, 5, 8, 10]], [[0, 3, 6, 8, 10], [1, 3, 6, 8, 10]],
5855
+ [[0, 4, 6, 8, 10], [0, 2, 4, 6, 9]],
5856
+ [[0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9, 11]], [[1], [1, 8]], [[1, 3], [1, 5, 8]],
5857
+ [[1, 4], [1, 4, 9]], [[1, 5], [1, 5, 8]], [[1, 3, 5], [1, 3, 5, 10]],
5858
+ [[1, 6], [1, 6, 10]], [[1, 3, 6], [1, 3, 6, 10]], [[1, 4, 6], [1, 4, 6, 9]],
5859
+ [[1, 7], [1, 4, 7]], [[1, 3, 7], [1, 3, 7, 10]], [[1, 4, 7], [1, 4, 7, 9]],
5860
+ [[1, 5, 7], [1, 5, 7, 10]], [[1, 3, 5, 7], [1, 3, 5, 7, 10]],
5861
+ [[1, 8], [1, 5, 8]], [[1, 3, 8], [1, 3, 5, 8]], [[1, 4, 8], [1, 4, 8, 11]],
5862
+ [[1, 5, 8], [1, 5, 8, 10]], [[1, 6, 8], [1, 3, 6, 8]],
5863
+ [[1, 3, 5, 8], [1, 3, 5, 8, 10]], [[1, 3, 6, 8], [1, 3, 6, 8, 10]],
5864
+ [[1, 4, 6, 8], [1, 4, 6, 8, 11]], [[1, 9], [1, 4, 9]],
5865
+ [[1, 3, 9], [1, 3, 6, 9]], [[1, 4, 9], [1, 4, 6, 9]],
5866
+ [[1, 5, 9], [0, 3, 5, 9]], [[1, 6, 9], [1, 4, 6, 9]],
5867
+ [[1, 7, 9], [1, 4, 7, 9]], [[1, 3, 5, 9], [0, 3, 5, 7, 9]],
5868
+ [[1, 3, 6, 9], [1, 3, 6, 9, 11]], [[1, 3, 7, 9], [1, 3, 5, 7, 9]],
5869
+ [[1, 4, 6, 9], [1, 4, 6, 9, 11]], [[1, 4, 7, 9], [1, 4, 7, 9, 11]],
5870
+ [[1, 5, 7, 9], [1, 3, 7, 9, 11]], [[1, 3, 5, 7, 9], [2, 4, 6, 8, 11]],
5871
+ [[1, 10], [1, 5, 10]], [[1, 3, 10], [1, 3, 7, 10]],
5872
+ [[1, 4, 10], [1, 4, 6, 10]], [[1, 5, 10], [1, 5, 8, 10]],
5873
+ [[1, 6, 10], [1, 4, 6, 10]], [[1, 7, 10], [1, 3, 7, 10]],
5874
+ [[1, 8, 10], [1, 5, 8, 10]], [[1, 3, 5, 10], [1, 3, 5, 8, 10]],
5875
+ [[1, 3, 6, 10], [1, 3, 6, 8, 10]], [[1, 3, 7, 10], [1, 3, 5, 7, 10]],
5876
+ [[1, 3, 8, 10], [1, 3, 5, 8, 10]], [[1, 4, 6, 10], [1, 4, 6, 8, 10]],
5877
+ [[1, 4, 7, 10], [0, 2, 4, 7, 10]], [[1, 4, 8, 10], [1, 4, 6, 8, 10]],
5878
+ [[1, 5, 7, 10], [1, 3, 5, 7, 10]], [[1, 5, 8, 10], [1, 3, 5, 8, 10]],
5879
+ [[1, 6, 8, 10], [1, 3, 6, 8, 10]], [[1, 3, 5, 7, 10], [2, 4, 6, 8, 11]],
5880
+ [[1, 3, 5, 8, 10], [0, 3, 5, 8, 10]], [[1, 3, 6, 8, 10], [0, 3, 6, 8, 10]],
5881
+ [[1, 4, 6, 8, 10], [0, 3, 5, 7, 9]], [[1, 11], [2, 6, 11]],
5882
+ [[1, 3, 11], [1, 3, 6, 11]], [[1, 4, 11], [1, 4, 8, 11]],
5883
+ [[1, 5, 11], [1, 5, 8, 11]], [[1, 6, 11], [1, 4, 6, 11]],
5884
+ [[1, 7, 11], [1, 4, 7, 11]], [[1, 8, 11], [1, 4, 8, 11]],
5885
+ [[1, 9, 11], [1, 4, 9, 11]], [[1, 3, 5, 11], [1, 3, 5, 8, 11]],
5886
+ [[1, 3, 6, 11], [1, 3, 6, 8, 11]], [[1, 3, 7, 11], [1, 3, 7, 9, 11]],
5887
+ [[1, 3, 8, 11], [1, 3, 6, 8, 11]], [[1, 3, 9, 11], [1, 3, 6, 9, 11]],
5888
+ [[1, 4, 6, 11], [1, 4, 6, 9, 11]], [[1, 4, 7, 11], [1, 4, 7, 9, 11]],
5889
+ [[1, 4, 8, 11], [1, 4, 6, 8, 11]], [[1, 4, 9, 11], [1, 4, 6, 9, 11]],
5890
+ [[1, 5, 7, 11], [0, 4, 6, 8, 10]], [[1, 5, 8, 11], [1, 3, 5, 8, 11]],
5891
+ [[1, 5, 9, 11], [1, 5, 7, 9, 11]], [[1, 6, 8, 11], [1, 3, 6, 8, 11]],
5892
+ [[1, 6, 9, 11], [1, 4, 6, 9, 11]], [[1, 7, 9, 11], [1, 4, 7, 9, 11]],
5893
+ [[1, 3, 5, 7, 11], [0, 2, 4, 6, 8]], [[1, 3, 5, 8, 11], [0, 2, 4, 7, 10]],
5894
+ [[1, 3, 5, 9, 11], [1, 3, 7, 9, 11]], [[1, 3, 6, 8, 11], [1, 4, 6, 8, 11]],
5895
+ [[1, 3, 6, 9, 11], [0, 2, 5, 8, 10]], [[1, 3, 7, 9, 11], [1, 3, 6, 9, 11]],
5896
+ [[1, 4, 6, 8, 11], [1, 4, 6, 9, 11]], [[1, 4, 6, 9, 11], [2, 4, 6, 9, 11]],
5897
+ [[1, 4, 7, 9, 11], [2, 4, 7, 9, 11]], [[1, 5, 7, 9, 11], [2, 4, 7, 9, 11]],
5898
+ [[1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]], [[2], [2, 9]], [[2, 4], [2, 6, 9]],
5899
+ [[2, 5], [2, 5, 9]], [[2, 6], [2, 6, 9]], [[2, 4, 6], [2, 4, 6, 9]],
5900
+ [[2, 7], [2, 7, 11]], [[2, 4, 7], [2, 4, 7, 11]], [[2, 5, 7], [2, 5, 7, 11]],
5901
+ [[2, 8], [4, 8, 11]], [[2, 4, 8], [2, 4, 8, 11]], [[2, 5, 8], [2, 5, 8, 10]],
5902
+ [[2, 6, 8], [2, 6, 8, 11]], [[2, 4, 6, 8], [2, 4, 6, 8, 11]],
5903
+ [[2, 9], [2, 6, 9]], [[2, 4, 9], [2, 4, 6, 9]], [[2, 5, 9], [0, 2, 5, 9]],
5904
+ [[2, 6, 9], [2, 6, 9, 11]], [[2, 7, 9], [2, 7, 9, 11]],
5905
+ [[2, 4, 6, 9], [2, 4, 6, 9, 11]], [[2, 4, 7, 9], [2, 4, 7, 9, 11]],
5906
+ [[2, 5, 7, 9], [0, 2, 5, 7, 9]], [[2, 10], [2, 5, 10]],
5907
+ [[2, 4, 10], [2, 4, 7, 10]], [[2, 5, 10], [2, 5, 7, 10]],
5908
+ [[2, 6, 10], [1, 4, 6, 10]], [[2, 7, 10], [2, 5, 7, 10]],
5909
+ [[2, 8, 10], [2, 5, 8, 10]], [[2, 4, 6, 10], [0, 2, 4, 6, 10]],
5910
+ [[2, 4, 7, 10], [0, 2, 4, 7, 10]], [[2, 4, 8, 10], [2, 4, 7, 9, 11]],
5911
+ [[2, 5, 7, 10], [0, 2, 5, 7, 10]], [[2, 5, 8, 10], [0, 2, 5, 8, 10]],
5912
+ [[2, 6, 8, 10], [1, 3, 5, 7, 10]], [[2, 4, 6, 8, 10], [0, 2, 6, 8, 10]],
5913
+ [[2, 11], [2, 7, 11]], [[2, 4, 11], [2, 4, 8, 11]],
5914
+ [[2, 5, 11], [2, 5, 7, 11]], [[2, 6, 11], [2, 6, 9, 11]],
5915
+ [[2, 7, 11], [2, 4, 7, 11]], [[2, 8, 11], [2, 4, 8, 11]],
5916
+ [[2, 9, 11], [2, 6, 9, 11]], [[2, 4, 6, 11], [2, 4, 6, 9, 11]],
5917
+ [[2, 4, 7, 11], [2, 4, 7, 9, 11]], [[2, 4, 8, 11], [2, 4, 6, 8, 11]],
5918
+ [[2, 4, 9, 11], [2, 4, 7, 9, 11]], [[2, 5, 7, 11], [2, 5, 7, 9, 11]],
5919
+ [[2, 5, 8, 11], [1, 3, 5, 8, 11]], [[2, 5, 9, 11], [2, 5, 7, 9, 11]],
5920
+ [[2, 6, 8, 11], [2, 4, 6, 8, 11]], [[2, 6, 9, 11], [2, 4, 6, 9, 11]],
5921
+ [[2, 7, 9, 11], [2, 4, 7, 9, 11]], [[2, 4, 6, 8, 11], [2, 4, 6, 9, 11]],
5922
+ [[2, 4, 6, 9, 11], [2, 4, 7, 9, 11]], [[2, 4, 7, 9, 11], [0, 2, 4, 7, 9]],
5923
+ [[2, 5, 7, 9, 11], [2, 4, 7, 9, 11]], [[3], [3, 10]], [[3, 5], [3, 7, 10]],
5924
+ [[3, 6], [3, 6, 11]], [[3, 7], [3, 7, 10]], [[3, 5, 7], [3, 5, 7, 10]],
5925
+ [[3, 8], [0, 3, 8]], [[3, 5, 8], [0, 3, 5, 8]], [[3, 6, 8], [0, 3, 6, 8]],
5926
+ [[3, 9], [0, 3, 9]], [[3, 5, 9], [0, 3, 5, 9]], [[3, 6, 9], [3, 6, 9, 11]],
5927
+ [[3, 7, 9], [0, 3, 7, 9]], [[3, 5, 7, 9], [0, 3, 5, 7, 9]],
5928
+ [[3, 10], [3, 7, 10]], [[3, 5, 10], [3, 5, 7, 10]],
5929
+ [[3, 6, 10], [1, 3, 6, 10]], [[3, 7, 10], [0, 3, 7, 10]],
5930
+ [[3, 8, 10], [0, 3, 8, 10]], [[3, 5, 7, 10], [0, 3, 5, 7, 10]],
5931
+ [[3, 5, 8, 10], [0, 3, 5, 8, 10]], [[3, 6, 8, 10], [1, 3, 6, 8, 10]],
5932
+ [[3, 11], [3, 6, 11]], [[3, 5, 11], [3, 5, 8, 11]],
5933
+ [[3, 6, 11], [3, 6, 9, 11]], [[3, 7, 11], [2, 5, 7, 11]],
5934
+ [[3, 8, 11], [3, 6, 8, 11]], [[3, 9, 11], [3, 6, 9, 11]],
5935
+ [[3, 5, 7, 11], [3, 5, 7, 9, 11]], [[3, 5, 8, 11], [1, 3, 5, 8, 11]],
5936
+ [[3, 5, 9, 11], [3, 5, 7, 9, 11]], [[3, 6, 8, 11], [1, 3, 6, 8, 11]],
5937
+ [[3, 6, 9, 11], [1, 3, 6, 9, 11]], [[3, 7, 9, 11], [2, 4, 7, 9, 11]],
5938
+ [[3, 5, 7, 9, 11], [2, 5, 7, 9, 11]], [[4], [4, 11]], [[4, 6], [4, 7, 11]],
5939
+ [[4, 7], [0, 4, 7]], [[4, 8], [4, 8, 11]], [[4, 6, 8], [4, 6, 8, 11]],
5940
+ [[4, 9], [1, 4, 9]], [[4, 6, 9], [1, 4, 6, 9]], [[4, 7, 9], [1, 4, 7, 9]],
5941
+ [[4, 10], [4, 7, 10]], [[4, 6, 10], [1, 4, 6, 10]],
5942
+ [[4, 7, 10], [0, 4, 7, 10]], [[4, 8, 10], [1, 4, 8, 10]],
5943
+ [[4, 6, 8, 10], [1, 4, 6, 8, 10]], [[4, 11], [4, 8, 11]],
5944
+ [[4, 6, 11], [4, 6, 8, 11]], [[4, 7, 11], [2, 4, 7, 11]],
5945
+ [[4, 8, 11], [2, 4, 8, 11]], [[4, 9, 11], [2, 4, 9, 11]],
5946
+ [[4, 6, 8, 11], [1, 4, 6, 8, 11]], [[4, 6, 9, 11], [2, 4, 6, 9, 11]],
5947
+ [[4, 7, 9, 11], [2, 4, 7, 9, 11]], [[5], [0, 5, 9]], [[5, 7], [0, 4, 7]],
5948
+ [[5, 8], [0, 5, 8]], [[5, 9], [0, 5, 9]], [[5, 7, 9], [0, 4, 7, 9]],
5949
+ [[5, 10], [2, 5, 10]], [[5, 7, 10], [2, 5, 7, 10]],
5950
+ [[5, 8, 10], [2, 5, 8, 10]], [[5, 11], [0, 5, 9]], [[5, 7, 11], [2, 5, 7, 11]],
5951
+ [[5, 8, 11], [1, 5, 8, 11]], [[5, 9, 11], [2, 5, 9, 11]],
5952
+ [[5, 7, 9, 11], [2, 5, 7, 9, 11]], [[6], [1, 6]], [[6, 8], [1, 5, 8]],
5953
+ [[6, 9], [2, 6, 9]], [[6, 10], [1, 6, 10]], [[6, 8, 10], [1, 5, 8, 10]],
5954
+ [[6, 11], [3, 6, 11]], [[6, 8, 11], [3, 6, 8, 11]],
5955
+ [[6, 9, 11], [3, 6, 9, 11]], [[7], [2, 7, 11]], [[7, 9], [2, 6, 9]],
5956
+ [[7, 10], [2, 7, 10]], [[7, 11], [2, 7, 11]], [[7, 9, 11], [2, 7, 9, 11]],
5957
+ [[8], [3, 8]], [[8, 10], [3, 7, 10]], [[8, 11], [4, 8, 11]], [[9], [4, 9]],
5958
+ [[9, 11], [4, 8, 11]], [[10], [2, 5, 10]], [[11], [6, 11]]]
5959
+
5960
+ ###################################################################################
5961
+
5962
+ ALL_CHORDS_PAIRS_FILTERED = [[[0], [0, 4, 7]], [[0, 3], [0, 3, 7]], [[0, 3, 5], [0, 3, 5, 9]],
5963
+ [[0, 3, 5, 8], [0, 3, 7, 10]], [[0, 3, 5, 9], [0, 3, 7, 10]],
5964
+ [[0, 3, 5, 10], [0, 3, 5, 9]], [[0, 3, 7], [0, 3, 7, 10]],
5965
+ [[0, 3, 7, 10], [0, 3, 5, 9]], [[0, 3, 8], [0, 3, 5, 8]],
5966
+ [[0, 3, 9], [0, 3, 5, 9]], [[0, 3, 10], [0, 3, 7, 10]], [[0, 4], [0, 4, 7]],
5967
+ [[0, 4, 6], [0, 4, 6, 9]], [[0, 4, 6, 9], [1, 4, 6, 9]],
5968
+ [[0, 4, 6, 10], [0, 4, 7, 10]], [[0, 4, 7], [0, 4, 7, 10]],
5969
+ [[0, 4, 7, 10], [1, 4, 7, 10]], [[0, 4, 8], [0, 4, 7, 10]],
5970
+ [[0, 4, 9], [0, 4, 6, 9]], [[0, 4, 10], [0, 4, 7, 10]], [[0, 5], [0, 5, 9]],
5971
+ [[0, 5, 8], [0, 3, 5, 8]], [[0, 5, 9], [0, 3, 5, 9]],
5972
+ [[0, 5, 10], [0, 3, 5, 10]], [[0, 6], [0, 6, 9]], [[0, 6, 9], [0, 4, 6, 9]],
5973
+ [[0, 6, 10], [0, 4, 7, 10]], [[0, 7], [0, 4, 7]], [[0, 7, 10], [0, 4, 7, 10]],
5974
+ [[0, 8], [0, 3, 8]], [[0, 9], [0, 4, 9]], [[0, 10], [2, 5, 10]], [[1], [1, 8]],
5975
+ [[1, 4], [1, 4, 9]], [[1, 4, 6], [1, 4, 6, 9]], [[1, 4, 6, 9], [1, 4, 8, 11]],
5976
+ [[1, 4, 6, 10], [0, 3, 5, 9]], [[1, 4, 6, 11], [1, 4, 6, 9]],
5977
+ [[1, 4, 7], [1, 4, 7, 10]], [[1, 4, 7, 10], [0, 4, 7, 10]],
5978
+ [[1, 4, 7, 11], [1, 4, 6, 10]], [[1, 4, 8], [1, 4, 8, 11]],
5979
+ [[1, 4, 8, 11], [1, 4, 6, 9]], [[1, 4, 9], [1, 4, 6, 9]],
5980
+ [[1, 4, 10], [1, 4, 6, 10]], [[1, 4, 11], [1, 4, 8, 11]], [[1, 5], [1, 5, 8]],
5981
+ [[1, 5, 8], [1, 5, 8, 11]], [[1, 5, 8, 11], [2, 5, 8, 11]],
5982
+ [[1, 5, 9], [0, 3, 5, 9]], [[1, 5, 10], [0, 4, 7, 10]],
5983
+ [[1, 5, 11], [1, 5, 8, 11]], [[1, 6], [1, 6, 10]], [[1, 6, 9], [1, 4, 6, 9]],
5984
+ [[1, 6, 10], [1, 4, 6, 10]], [[1, 6, 11], [1, 4, 6, 11]], [[1, 7], [1, 4, 7]],
5985
+ [[1, 7, 10], [1, 4, 7, 10]], [[1, 7, 11], [1, 4, 7, 11]], [[1, 8], [1, 5, 8]],
5986
+ [[1, 8, 11], [1, 4, 8, 11]], [[1, 9], [1, 4, 9]], [[1, 10], [1, 5, 10]],
5987
+ [[1, 11], [2, 6, 11]], [[2], [2, 9]], [[2, 5], [2, 5, 9]],
5988
+ [[2, 5, 8], [2, 5, 8, 11]], [[2, 5, 8, 11], [1, 4, 7, 10]],
5989
+ [[2, 5, 9], [0, 3, 5, 9]], [[2, 5, 10], [0, 3, 5, 9]],
5990
+ [[2, 5, 11], [2, 5, 8, 11]], [[2, 6], [2, 6, 9]], [[2, 6, 9], [1, 4, 6, 9]],
5991
+ [[2, 6, 10], [1, 4, 6, 10]], [[2, 6, 11], [1, 4, 6, 10]], [[2, 7], [2, 7, 11]],
5992
+ [[2, 7, 10], [0, 4, 7, 10]], [[2, 7, 11], [1, 4, 6, 9]], [[2, 8], [4, 8, 11]],
5993
+ [[2, 8, 11], [2, 5, 8, 11]], [[2, 9], [2, 6, 9]], [[2, 10], [2, 5, 10]],
5994
+ [[2, 11], [2, 7, 11]], [[3], [3, 10]], [[3, 5], [3, 7, 10]],
5995
+ [[3, 5, 8], [0, 3, 5, 8]], [[3, 5, 8, 11], [2, 5, 8, 11]],
5996
+ [[3, 5, 9], [0, 3, 5, 9]], [[3, 5, 10], [0, 3, 5, 10]],
5997
+ [[3, 5, 11], [3, 5, 8, 11]], [[3, 7], [3, 7, 10]], [[3, 7, 10], [0, 3, 7, 10]],
5998
+ [[3, 7, 11], [0, 3, 7, 10]], [[3, 8], [0, 3, 8]], [[3, 8, 11], [3, 5, 8, 11]],
5999
+ [[3, 9], [0, 3, 9]], [[3, 10], [3, 7, 10]], [[3, 11], [3, 8, 11]],
6000
+ [[4], [4, 11]], [[4, 6], [4, 7, 11]], [[4, 6, 9], [1, 4, 6, 9]],
6001
+ [[4, 6, 10], [1, 4, 6, 10]], [[4, 6, 11], [1, 4, 6, 11]], [[4, 7], [0, 4, 7]],
6002
+ [[4, 7, 10], [0, 4, 7, 10]], [[4, 7, 11], [1, 4, 7, 11]], [[4, 8], [4, 8, 11]],
6003
+ [[4, 8, 11], [1, 4, 8, 11]], [[4, 9], [1, 4, 9]], [[4, 10], [4, 7, 10]],
6004
+ [[4, 11], [4, 8, 11]], [[5], [0, 5, 9]], [[5, 8], [0, 5, 8]],
6005
+ [[5, 8, 11], [1, 5, 8, 11]], [[5, 9], [0, 5, 9]], [[5, 10], [2, 5, 10]],
6006
+ [[5, 11], [0, 5, 9]], [[6], [1, 6]], [[6, 9], [2, 6, 9]],
6007
+ [[6, 10], [1, 6, 10]], [[6, 11], [2, 6, 11]], [[7], [2, 7, 11]],
6008
+ [[7, 10], [2, 7, 10]], [[7, 11], [2, 7, 11]], [[8], [3, 8]],
6009
+ [[8, 11], [4, 8, 11]], [[9], [4, 9]], [[10], [2, 5, 10]], [[11], [6, 11]]]
6010
+
6011
+ ###################################################################################
6012
+
6013
+ ALL_CHORDS_TRIPLETS_SORTED = [[[0], [0, 4, 7], [0]], [[0, 2], [0, 4, 7], [0]], [[0, 3], [0, 3, 7], [0]],
6014
+ [[0, 4], [0, 4, 7], [0, 4]], [[0, 2, 4], [0, 2, 4, 7], [0]],
6015
+ [[0, 5], [0, 5, 9], [0, 5]], [[0, 2, 5], [0, 2, 5, 9], [0, 2, 5]],
6016
+ [[0, 3, 5], [0, 3, 5, 9], [0, 3, 5]], [[0, 6], [0, 2, 6, 9], [2]],
6017
+ [[0, 2, 6], [0, 2, 6, 9], [0, 2, 6]], [[0, 3, 6], [0, 3, 6, 8], [0, 3, 6]],
6018
+ [[0, 4, 6], [0, 4, 6, 9], [0, 4, 6]],
6019
+ [[0, 2, 4, 6], [0, 2, 4, 6, 9], [0, 2, 4, 6]], [[0, 7], [0, 4, 7], [0, 7]],
6020
+ [[0, 2, 7], [0, 2, 4, 7], [0, 2, 7]], [[0, 3, 7], [0, 3, 7, 10], [0, 3, 7]],
6021
+ [[0, 4, 7], [0, 4, 7, 9], [0, 4, 7]], [[0, 5, 7], [0, 5, 7, 9], [0, 5, 7]],
6022
+ [[0, 2, 4, 7], [0, 2, 4, 7, 9], [0, 2, 4, 7]],
6023
+ [[0, 2, 5, 7], [0, 2, 5, 7, 9], [0, 2, 5, 7]],
6024
+ [[0, 3, 5, 7], [0, 3, 5, 7, 10], [0, 3, 5, 7]], [[0, 8], [0, 3, 8], [8]],
6025
+ [[0, 2, 8], [0, 2, 5, 8], [0, 2, 8]], [[0, 3, 8], [0, 3, 5, 8], [0, 3, 8]],
6026
+ [[0, 4, 8], [2, 4, 8, 11], [0, 4, 9]], [[0, 5, 8], [0, 3, 5, 8], [0, 5, 8]],
6027
+ [[0, 6, 8], [0, 3, 6, 8], [0, 6, 8]],
6028
+ [[0, 2, 4, 8], [0, 2, 4, 6, 8], [0, 2, 4, 8]],
6029
+ [[0, 2, 5, 8], [0, 2, 5, 8, 10], [0, 2, 5, 8]],
6030
+ [[0, 2, 6, 8], [0, 2, 6, 8, 10], [0, 2, 6, 8]],
6031
+ [[0, 3, 5, 8], [0, 3, 5, 8, 10], [0, 3, 5, 8]],
6032
+ [[0, 3, 6, 8], [0, 3, 6, 8, 10], [0, 3, 6, 8]],
6033
+ [[0, 4, 6, 8], [2, 4, 6, 8, 11], [2, 6, 8, 11]],
6034
+ [[0, 2, 4, 6, 8], [2, 4, 6, 8, 11], [2, 6, 8, 11]], [[0, 9], [0, 4, 9], [9]],
6035
+ [[0, 2, 9], [0, 2, 6, 9], [0, 2, 9]], [[0, 3, 9], [0, 3, 5, 9], [0, 3, 9]],
6036
+ [[0, 4, 9], [0, 4, 7, 9], [0, 4, 9]], [[0, 5, 9], [0, 2, 5, 9], [0, 5, 9]],
6037
+ [[0, 6, 9], [0, 2, 6, 9], [0, 6, 9]], [[0, 7, 9], [0, 4, 7, 9], [0, 7, 9]],
6038
+ [[0, 2, 4, 9], [0, 2, 4, 7, 9], [0, 2, 4, 9]],
6039
+ [[0, 2, 5, 9], [0, 2, 5, 7, 9], [0, 2, 5, 9]],
6040
+ [[0, 2, 6, 9], [0, 2, 4, 6, 9], [0, 2, 6, 9]],
6041
+ [[0, 2, 7, 9], [0, 2, 4, 7, 9], [0, 2, 7, 9]],
6042
+ [[0, 3, 5, 9], [0, 3, 5, 7, 9], [0, 3, 5, 9]],
6043
+ [[0, 3, 6, 9], [0, 2, 4, 6, 9], [4, 6, 9]],
6044
+ [[0, 3, 7, 9], [0, 3, 5, 7, 9], [0, 3, 7, 9]],
6045
+ [[0, 4, 6, 9], [0, 2, 4, 6, 9], [0, 4, 6, 9]],
6046
+ [[0, 4, 7, 9], [0, 2, 4, 7, 9], [0, 4, 7, 9]],
6047
+ [[0, 5, 7, 9], [0, 2, 5, 7, 9], [0, 5, 7, 9]],
6048
+ [[0, 2, 4, 6, 9], [2, 4, 6, 9, 11], [0, 2, 4, 6, 9]],
6049
+ [[0, 2, 4, 7, 9], [2, 4, 7, 9, 11], [0, 2, 4, 7, 9]],
6050
+ [[0, 2, 5, 7, 9], [2, 5, 7, 9, 11], [7]],
6051
+ [[0, 3, 5, 7, 9], [2, 4, 6, 8, 11], [1, 4, 6, 8, 10]],
6052
+ [[0, 10], [2, 5, 10], [10]], [[0, 2, 10], [0, 2, 5, 10], [10]],
6053
+ [[0, 3, 10], [0, 3, 7, 10], [0, 3, 10]],
6054
+ [[0, 4, 10], [0, 4, 7, 10], [0, 4, 10]],
6055
+ [[0, 5, 10], [0, 2, 5, 10], [0, 5, 10]],
6056
+ [[0, 6, 10], [0, 3, 6, 10], [0, 6, 10]],
6057
+ [[0, 7, 10], [0, 4, 7, 10], [0, 7, 10]], [[0, 8, 10], [0, 3, 8, 10], [8]],
6058
+ [[0, 2, 4, 10], [0, 2, 4, 7, 10], [0, 4, 10]],
6059
+ [[0, 2, 5, 10], [0, 2, 5, 7, 10], [0, 2, 5, 10]],
6060
+ [[0, 2, 6, 10], [0, 2, 6, 8, 10], [8]],
6061
+ [[0, 2, 7, 10], [0, 2, 5, 7, 10], [2, 7, 10]],
6062
+ [[0, 2, 8, 10], [0, 2, 5, 8, 10], [8, 10]],
6063
+ [[0, 3, 5, 10], [0, 3, 5, 7, 10], [0, 3, 5, 10]],
6064
+ [[0, 3, 6, 10], [0, 3, 6, 8, 10], [0, 3, 6, 10]],
6065
+ [[0, 3, 7, 10], [0, 3, 5, 7, 10], [0, 3, 7, 10]],
6066
+ [[0, 3, 8, 10], [0, 3, 5, 8, 10], [0, 3, 8, 10]],
6067
+ [[0, 4, 6, 10], [0, 2, 4, 6, 10], [2]],
6068
+ [[0, 4, 7, 10], [0, 2, 4, 7, 10], [0, 4, 7, 10]],
6069
+ [[0, 4, 8, 10], [0, 2, 4, 8, 10], [0, 4, 8, 10]],
6070
+ [[0, 5, 7, 10], [0, 3, 5, 7, 10], [0, 5, 7, 10]],
6071
+ [[0, 5, 8, 10], [0, 3, 5, 8, 10], [10]],
6072
+ [[0, 6, 8, 10], [0, 3, 6, 8, 10], [6]],
6073
+ [[0, 2, 4, 6, 10], [0, 2, 4, 8, 10], [0, 2, 6, 8, 10]],
6074
+ [[0, 2, 4, 7, 10], [1, 3, 6, 9, 11], [0, 2, 5, 8, 10]],
6075
+ [[0, 2, 4, 8, 10], [1, 3, 7, 9, 11], [0, 2, 6, 8, 10]],
6076
+ [[0, 2, 5, 7, 10], [0, 3, 5, 7, 10], [5, 10]],
6077
+ [[0, 2, 5, 8, 10], [1, 4, 7, 9, 11], [8]],
6078
+ [[0, 2, 6, 8, 10], [2, 4, 6, 8, 10], [0, 2, 6, 8, 10]],
6079
+ [[0, 3, 5, 7, 10], [0, 2, 5, 7, 10], [9]],
6080
+ [[0, 3, 5, 8, 10], [1, 3, 5, 8, 10], [0, 3, 5, 8, 10]],
6081
+ [[0, 3, 6, 8, 10], [1, 3, 6, 8, 10], [0, 3, 6, 8, 10]],
6082
+ [[0, 4, 6, 8, 10], [0, 2, 4, 6, 9], [1, 3, 5, 8, 10]],
6083
+ [[0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]],
6084
+ [[1], [1, 8], [1]], [[1, 3], [1, 5, 8], [1]], [[1, 4], [1, 4, 9], [9]],
6085
+ [[1, 5], [1, 5, 8], [1, 5]], [[1, 3, 5], [1, 3, 5, 10], [1, 3, 5]],
6086
+ [[1, 6], [1, 6, 10], [1, 6]], [[1, 3, 6], [1, 3, 6, 10], [1, 3, 6]],
6087
+ [[1, 4, 6], [1, 4, 6, 9], [1, 4, 6]], [[1, 7], [1, 4, 7], [1, 7]],
6088
+ [[1, 3, 7], [1, 3, 7, 10], [1, 3, 7]], [[1, 4, 7], [1, 4, 7, 9], [1, 4, 7]],
6089
+ [[1, 5, 7], [1, 5, 7, 10], [1, 5, 7]], [[1, 3, 5, 7], [1, 3, 5, 7, 10], [7]],
6090
+ [[1, 8], [1, 5, 8], [1, 8]], [[1, 3, 8], [1, 3, 5, 8], [1, 3, 8]],
6091
+ [[1, 4, 8], [1, 4, 8, 11], [1, 4, 8]], [[1, 5, 8], [1, 5, 8, 10], [1, 5, 8]],
6092
+ [[1, 6, 8], [1, 3, 6, 8], [1, 6, 8]],
6093
+ [[1, 3, 5, 8], [1, 3, 5, 8, 10], [1, 3, 5, 8]],
6094
+ [[1, 3, 6, 8], [1, 3, 6, 8, 10], [1, 3, 6, 8]],
6095
+ [[1, 4, 6, 8], [1, 4, 6, 8, 11], [1, 4, 6, 8]], [[1, 9], [1, 4, 9], [9]],
6096
+ [[1, 3, 9], [1, 3, 6, 9], [1, 3, 9]], [[1, 4, 9], [1, 4, 6, 9], [1, 4, 9]],
6097
+ [[1, 5, 9], [0, 3, 5, 9], [0, 5, 9]], [[1, 6, 9], [1, 4, 6, 9], [1, 6, 9]],
6098
+ [[1, 7, 9], [1, 4, 7, 9], [1, 7, 9]],
6099
+ [[1, 3, 5, 9], [0, 3, 5, 7, 9], [1, 5, 9]],
6100
+ [[1, 3, 6, 9], [1, 3, 6, 9, 11], [1, 3, 6, 9]],
6101
+ [[1, 3, 7, 9], [1, 3, 5, 7, 9], [1, 7]],
6102
+ [[1, 4, 6, 9], [1, 4, 6, 9, 11], [1, 4, 6, 9]],
6103
+ [[1, 4, 7, 9], [1, 4, 7, 9, 11], [1, 4, 7, 9]],
6104
+ [[1, 5, 7, 9], [1, 3, 7, 9, 11], [1, 5, 7, 9]],
6105
+ [[1, 3, 5, 7, 9], [2, 4, 6, 8, 11], [9]], [[1, 10], [1, 5, 10], [10]],
6106
+ [[1, 3, 10], [1, 3, 7, 10], [1, 3, 10]],
6107
+ [[1, 4, 10], [1, 4, 6, 10], [1, 4, 10]],
6108
+ [[1, 5, 10], [1, 5, 8, 10], [1, 5, 10]],
6109
+ [[1, 6, 10], [1, 4, 6, 10], [1, 6, 10]],
6110
+ [[1, 7, 10], [1, 3, 7, 10], [1, 7, 10]], [[1, 8, 10], [1, 5, 8, 10], [10]],
6111
+ [[1, 3, 5, 10], [1, 3, 5, 8, 10], [1, 3, 5, 10]],
6112
+ [[1, 3, 6, 10], [1, 3, 6, 8, 10], [1, 3, 6, 10]],
6113
+ [[1, 3, 7, 10], [1, 3, 5, 7, 10], [1, 3, 7, 10]],
6114
+ [[1, 3, 8, 10], [1, 3, 5, 8, 10], [1, 3, 8, 10]],
6115
+ [[1, 4, 6, 10], [1, 4, 6, 8, 10], [1, 4, 6, 10]],
6116
+ [[1, 4, 7, 10], [0, 2, 4, 7, 10], [0, 4, 7, 10]],
6117
+ [[1, 4, 8, 10], [1, 4, 6, 8, 10], [1, 4, 8, 10]],
6118
+ [[1, 5, 7, 10], [1, 3, 5, 7, 10], [1, 5, 7, 10]],
6119
+ [[1, 5, 8, 10], [1, 3, 5, 8, 10], [1, 5, 8, 10]],
6120
+ [[1, 6, 8, 10], [1, 3, 6, 8, 10], [1, 6, 8, 10]],
6121
+ [[1, 3, 5, 7, 10], [2, 4, 6, 8, 11], [0, 3, 5, 7, 9]],
6122
+ [[1, 3, 5, 8, 10], [0, 3, 5, 8, 10], [6, 8, 10]],
6123
+ [[1, 3, 6, 8, 10], [0, 3, 6, 8, 10], [8]],
6124
+ [[1, 4, 6, 8, 10], [0, 3, 5, 7, 9], [2, 4, 6, 8, 11]],
6125
+ [[1, 11], [2, 6, 11], [11]], [[1, 3, 11], [1, 3, 6, 11], [11]],
6126
+ [[1, 4, 11], [1, 4, 8, 11], [1]], [[1, 5, 11], [1, 5, 8, 11], [1, 5, 11]],
6127
+ [[1, 6, 11], [1, 4, 6, 11], [1, 6, 11]],
6128
+ [[1, 7, 11], [1, 4, 7, 11], [1, 7, 11]],
6129
+ [[1, 8, 11], [1, 4, 8, 11], [1, 8, 11]], [[1, 9, 11], [1, 4, 9, 11], [9]],
6130
+ [[1, 3, 5, 11], [1, 3, 5, 8, 11], [1, 3, 5, 11]],
6131
+ [[1, 3, 6, 11], [1, 3, 6, 8, 11], [1, 3, 6, 11]],
6132
+ [[1, 3, 7, 11], [1, 3, 7, 9, 11], [0]],
6133
+ [[1, 3, 8, 11], [1, 3, 6, 8, 11], [1, 3, 8, 11]],
6134
+ [[1, 3, 9, 11], [1, 3, 6, 9, 11], [1, 3, 9, 11]],
6135
+ [[1, 4, 6, 11], [1, 4, 6, 9, 11], [1, 4, 6, 11]],
6136
+ [[1, 4, 7, 11], [1, 4, 7, 9, 11], [1, 4, 7, 11]],
6137
+ [[1, 4, 8, 11], [1, 4, 6, 8, 11], [1, 4, 8, 11]],
6138
+ [[1, 4, 9, 11], [1, 4, 6, 9, 11], [1, 4, 9, 11]],
6139
+ [[1, 5, 7, 11], [0, 4, 6, 8, 10], [5, 7, 9, 11]],
6140
+ [[1, 5, 8, 11], [1, 3, 5, 8, 11], [1, 5, 8, 11]],
6141
+ [[1, 5, 9, 11], [1, 5, 7, 9, 11], [9]],
6142
+ [[1, 6, 8, 11], [1, 3, 6, 8, 11], [1, 6, 8, 11]],
6143
+ [[1, 6, 9, 11], [1, 4, 6, 9, 11], [1, 6, 9, 11]],
6144
+ [[1, 7, 9, 11], [1, 4, 7, 9, 11], [1, 7, 9, 11]],
6145
+ [[1, 3, 5, 7, 11], [0, 2, 4, 6, 8], [7, 9]],
6146
+ [[1, 3, 5, 8, 11], [0, 2, 4, 7, 10], [1, 3, 6, 9, 11]],
6147
+ [[1, 3, 5, 9, 11], [1, 3, 7, 9, 11], [0, 2, 6, 8, 10]],
6148
+ [[1, 3, 6, 8, 11], [1, 4, 6, 8, 11], [6, 8, 11]],
6149
+ [[1, 3, 6, 9, 11], [0, 2, 5, 8, 10], [1, 4, 7, 9, 11]],
6150
+ [[1, 3, 7, 9, 11], [1, 3, 6, 9, 11], [11]],
6151
+ [[1, 4, 6, 8, 11], [1, 4, 6, 9, 11], [9, 11]],
6152
+ [[1, 4, 6, 9, 11], [2, 4, 6, 9, 11], [1, 4, 6, 9, 11]],
6153
+ [[1, 4, 7, 9, 11], [2, 4, 7, 9, 11], [7, 9, 11]],
6154
+ [[1, 5, 7, 9, 11], [2, 4, 7, 9, 11], [5, 7, 9]],
6155
+ [[1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9, 11]],
6156
+ [[2], [2, 9], [2]], [[2, 4], [2, 6, 9], [2]], [[2, 5], [2, 5, 9], [2]],
6157
+ [[2, 6], [2, 6, 9], [2]], [[2, 4, 6], [2, 4, 6, 9], [2, 4, 6]],
6158
+ [[2, 7], [2, 7, 11], [2, 7]], [[2, 4, 7], [2, 4, 7, 11], [2, 4, 7]],
6159
+ [[2, 5, 7], [2, 5, 7, 11], [2, 5, 7]], [[2, 8], [4, 8, 11], [4]],
6160
+ [[2, 4, 8], [2, 4, 8, 11], [2, 4, 8]], [[2, 5, 8], [2, 5, 8, 10], [2, 5, 8]],
6161
+ [[2, 6, 8], [2, 6, 8, 11], [2, 6, 8]],
6162
+ [[2, 4, 6, 8], [2, 4, 6, 8, 11], [2, 4, 6, 8]], [[2, 9], [2, 6, 9], [2, 9]],
6163
+ [[2, 4, 9], [2, 4, 6, 9], [2, 4, 9]], [[2, 5, 9], [0, 2, 5, 9], [2, 5, 9]],
6164
+ [[2, 6, 9], [2, 6, 9, 11], [2, 6, 9]], [[2, 7, 9], [2, 7, 9, 11], [2, 7, 9]],
6165
+ [[2, 4, 6, 9], [2, 4, 6, 9, 11], [2, 4, 6, 9]],
6166
+ [[2, 4, 7, 9], [2, 4, 7, 9, 11], [2, 4, 7, 9]],
6167
+ [[2, 5, 7, 9], [0, 2, 5, 7, 9], [2, 5, 7, 9]], [[2, 10], [2, 5, 10], [10]],
6168
+ [[2, 4, 10], [2, 4, 7, 10], [2, 4, 10]],
6169
+ [[2, 5, 10], [2, 5, 7, 10], [2, 5, 10]],
6170
+ [[2, 6, 10], [1, 4, 6, 10], [1, 6, 10]],
6171
+ [[2, 7, 10], [2, 5, 7, 10], [2, 7, 10]],
6172
+ [[2, 8, 10], [2, 5, 8, 10], [2, 8, 10]],
6173
+ [[2, 4, 6, 10], [0, 2, 4, 6, 10], [2, 4, 6, 10]],
6174
+ [[2, 4, 7, 10], [0, 2, 4, 7, 10], [2, 4, 7, 10]],
6175
+ [[2, 4, 8, 10], [2, 4, 7, 9, 11], [2, 4, 7, 11]],
6176
+ [[2, 5, 7, 10], [0, 2, 5, 7, 10], [2, 5, 7, 10]],
6177
+ [[2, 5, 8, 10], [0, 2, 5, 8, 10], [2, 5, 8, 10]],
6178
+ [[2, 6, 8, 10], [1, 3, 5, 7, 10], [1, 7]],
6179
+ [[2, 4, 6, 8, 10], [0, 2, 6, 8, 10], [2, 4, 6, 8, 10]],
6180
+ [[2, 11], [2, 7, 11], [7]], [[2, 4, 11], [2, 4, 8, 11], [2, 4, 11]],
6181
+ [[2, 5, 11], [2, 5, 7, 11], [2, 5, 11]],
6182
+ [[2, 6, 11], [2, 6, 9, 11], [2, 6, 11]],
6183
+ [[2, 7, 11], [2, 4, 7, 11], [2, 7, 11]],
6184
+ [[2, 8, 11], [2, 4, 8, 11], [2, 8, 11]],
6185
+ [[2, 9, 11], [2, 6, 9, 11], [2, 9, 11]],
6186
+ [[2, 4, 6, 11], [2, 4, 6, 9, 11], [2, 4, 6, 11]],
6187
+ [[2, 4, 7, 11], [2, 4, 7, 9, 11], [2, 4, 7, 11]],
6188
+ [[2, 4, 8, 11], [2, 4, 6, 8, 11], [2, 4, 8, 11]],
6189
+ [[2, 4, 9, 11], [2, 4, 7, 9, 11], [2, 4, 9, 11]],
6190
+ [[2, 5, 7, 11], [2, 5, 7, 9, 11], [2, 5, 7, 11]],
6191
+ [[2, 5, 8, 11], [1, 3, 5, 8, 11], [1, 5, 8, 11]],
6192
+ [[2, 5, 9, 11], [2, 5, 7, 9, 11], [2, 5, 9, 11]],
6193
+ [[2, 6, 8, 11], [2, 4, 6, 8, 11], [2, 6, 8, 11]],
6194
+ [[2, 6, 9, 11], [2, 4, 6, 9, 11], [2, 6, 9, 11]],
6195
+ [[2, 7, 9, 11], [2, 4, 7, 9, 11], [2, 7, 9, 11]],
6196
+ [[2, 4, 6, 8, 11], [2, 4, 6, 9, 11], [2, 4, 6, 8, 11]],
6197
+ [[2, 4, 6, 9, 11], [2, 4, 7, 9, 11], [2, 7, 9]],
6198
+ [[2, 4, 7, 9, 11], [0, 2, 4, 7, 9], [11]],
6199
+ [[2, 5, 7, 9, 11], [2, 4, 7, 9, 11], [2, 7, 9, 11]], [[3], [3, 10], [3]],
6200
+ [[3, 5], [3, 7, 10], [3]], [[3, 6], [3, 6, 11], [11]],
6201
+ [[3, 7], [3, 7, 10], [3]], [[3, 5, 7], [3, 5, 7, 10], [3, 5, 7]],
6202
+ [[3, 8], [0, 3, 8], [3, 8]], [[3, 5, 8], [0, 3, 5, 8], [8]],
6203
+ [[3, 6, 8], [0, 3, 6, 8], [3, 6, 8]], [[3, 9], [0, 3, 9], [3, 9]],
6204
+ [[3, 5, 9], [0, 3, 5, 9], [3, 5, 9]], [[3, 6, 9], [3, 6, 9, 11], [3, 6, 9]],
6205
+ [[3, 7, 9], [0, 3, 7, 9], [3, 7, 9]],
6206
+ [[3, 5, 7, 9], [0, 3, 5, 7, 9], [0, 3, 5, 9]], [[3, 10], [3, 7, 10], [3, 10]],
6207
+ [[3, 5, 10], [3, 5, 7, 10], [3, 5, 10]],
6208
+ [[3, 6, 10], [1, 3, 6, 10], [3, 6, 10]],
6209
+ [[3, 7, 10], [0, 3, 7, 10], [3, 7, 10]],
6210
+ [[3, 8, 10], [0, 3, 8, 10], [3, 8, 10]],
6211
+ [[3, 5, 7, 10], [0, 3, 5, 7, 10], [3, 5, 7, 10]],
6212
+ [[3, 5, 8, 10], [0, 3, 5, 8, 10], [3, 5, 8, 10]],
6213
+ [[3, 6, 8, 10], [1, 3, 6, 8, 10], [3, 6, 8, 10]], [[3, 11], [3, 6, 11], [11]],
6214
+ [[3, 5, 11], [3, 5, 8, 11], [3, 5, 11]],
6215
+ [[3, 6, 11], [3, 6, 9, 11], [3, 6, 11]],
6216
+ [[3, 7, 11], [2, 5, 7, 11], [2, 7, 11]],
6217
+ [[3, 8, 11], [3, 6, 8, 11], [3, 8, 11]],
6218
+ [[3, 9, 11], [3, 6, 9, 11], [3, 9, 11]],
6219
+ [[3, 5, 7, 11], [3, 5, 7, 9, 11], [3, 5, 7, 11]],
6220
+ [[3, 5, 8, 11], [1, 3, 5, 8, 11], [3, 5, 8, 11]],
6221
+ [[3, 5, 9, 11], [3, 5, 7, 9, 11], [5, 7, 9, 11]],
6222
+ [[3, 6, 8, 11], [1, 3, 6, 8, 11], [3, 6, 8, 11]],
6223
+ [[3, 6, 9, 11], [1, 3, 6, 9, 11], [3, 6, 9, 11]],
6224
+ [[3, 7, 9, 11], [2, 4, 7, 9, 11], [7, 9, 11]],
6225
+ [[3, 5, 7, 9, 11], [2, 5, 7, 9, 11], [2, 5, 7, 11]], [[4], [4, 11], [4]],
6226
+ [[4, 6], [4, 7, 11], [4]], [[4, 7], [0, 4, 7], [0]], [[4, 8], [4, 8, 11], [4]],
6227
+ [[4, 6, 8], [4, 6, 8, 11], [4]], [[4, 9], [1, 4, 9], [4, 9]],
6228
+ [[4, 6, 9], [1, 4, 6, 9], [4, 6, 9]], [[4, 7, 9], [1, 4, 7, 9], [4, 7, 9]],
6229
+ [[4, 10], [4, 7, 10], [4, 10]], [[4, 6, 10], [1, 4, 6, 10], [4, 6, 10]],
6230
+ [[4, 7, 10], [0, 4, 7, 10], [4, 7, 10]], [[4, 8, 10], [1, 4, 8, 10], [1]],
6231
+ [[4, 6, 8, 10], [1, 4, 6, 8, 10], [6]], [[4, 11], [4, 8, 11], [4, 11]],
6232
+ [[4, 6, 11], [4, 6, 8, 11], [4, 6, 11]],
6233
+ [[4, 7, 11], [2, 4, 7, 11], [4, 7, 11]],
6234
+ [[4, 8, 11], [2, 4, 8, 11], [4, 8, 11]],
6235
+ [[4, 9, 11], [2, 4, 9, 11], [4, 9, 11]],
6236
+ [[4, 6, 8, 11], [1, 4, 6, 8, 11], [4, 6, 8, 11]],
6237
+ [[4, 6, 9, 11], [2, 4, 6, 9, 11], [4, 6, 9, 11]],
6238
+ [[4, 7, 9, 11], [2, 4, 7, 9, 11], [4, 7, 9, 11]], [[5], [0, 5, 9], [5]],
6239
+ [[5, 7], [0, 4, 7], [0]], [[5, 8], [0, 5, 8], [5]], [[5, 9], [0, 5, 9], [5]],
6240
+ [[5, 7, 9], [0, 4, 7, 9], [5]], [[5, 10], [2, 5, 10], [5, 10]],
6241
+ [[5, 7, 10], [2, 5, 7, 10], [7]], [[5, 8, 10], [2, 5, 8, 10], [5, 8, 10]],
6242
+ [[5, 11], [0, 5, 9], [5]], [[5, 7, 11], [2, 5, 7, 11], [5, 7, 11]],
6243
+ [[5, 8, 11], [1, 5, 8, 11], [5, 8, 11]],
6244
+ [[5, 9, 11], [2, 5, 9, 11], [5, 9, 11]],
6245
+ [[5, 7, 9, 11], [2, 5, 7, 9, 11], [5, 7, 9]], [[6], [1, 6], [6]],
6246
+ [[6, 8], [1, 5, 8], [8]], [[6, 9], [2, 6, 9], [2]], [[6, 10], [1, 6, 10], [6]],
6247
+ [[6, 8, 10], [1, 5, 8, 10], [6, 8, 10]], [[6, 11], [3, 6, 11], [6, 11]],
6248
+ [[6, 8, 11], [3, 6, 8, 11], [6, 8, 11]],
6249
+ [[6, 9, 11], [3, 6, 9, 11], [6, 9, 11]], [[7], [2, 7, 11], [7]],
6250
+ [[7, 9], [2, 6, 9], [2]], [[7, 10], [2, 7, 10], [7]],
6251
+ [[7, 11], [2, 7, 11], [7]], [[7, 9, 11], [2, 7, 9, 11], [7, 9, 11]],
6252
+ [[8], [3, 8], [8]], [[8, 10], [3, 7, 10], [3]], [[8, 11], [4, 8, 11], [4]],
6253
+ [[9], [4, 9], [9]], [[9, 11], [4, 8, 11], [4]], [[10], [2, 5, 10], [10]],
6254
+ [[11], [6, 11], [11]]]
6255
+
6256
+ ###################################################################################
6257
+
6258
+ ALL_CHORDS_TRIPLETS_FILTERED = [[[0], [0, 4, 7], [7]], [[0, 3], [0, 3, 7], [0]],
6259
+ [[0, 3, 5], [0, 3, 5, 9], [5]], [[0, 3, 5, 8], [0, 3, 7, 10], [0]],
6260
+ [[0, 3, 5, 9], [0, 3, 7, 10], [10]], [[0, 3, 5, 10], [0, 3, 5, 9], [5]],
6261
+ [[0, 3, 7], [0, 3, 7, 10], [0]], [[0, 3, 7, 10], [0, 3, 5, 9], [2, 5, 10]],
6262
+ [[0, 3, 8], [0, 3, 5, 8], [8]], [[0, 3, 9], [0, 3, 5, 9], [5]],
6263
+ [[0, 3, 10], [0, 3, 7, 10], [0]], [[0, 4], [0, 4, 7], [0]],
6264
+ [[0, 4, 6], [0, 4, 6, 9], [4]], [[0, 4, 6, 9], [1, 4, 6, 9], [9]],
6265
+ [[0, 4, 6, 10], [0, 4, 7, 10], [0, 4, 10]], [[0, 4, 7], [0, 4, 7, 10], [0]],
6266
+ [[0, 4, 7, 10], [1, 4, 7, 10], [0]], [[0, 4, 8], [0, 4, 7, 10], [0, 5, 8]],
6267
+ [[0, 4, 9], [0, 4, 6, 9], [9]], [[0, 4, 10], [0, 4, 7, 10], [0]],
6268
+ [[0, 5], [0, 5, 9], [5]], [[0, 5, 8], [0, 3, 5, 8], [5]],
6269
+ [[0, 5, 9], [0, 3, 5, 9], [5]], [[0, 5, 10], [0, 3, 5, 10], [10]],
6270
+ [[0, 6], [0, 6, 9], [9]], [[0, 6, 9], [0, 4, 6, 9], [6]],
6271
+ [[0, 6, 10], [0, 4, 7, 10], [10]], [[0, 7], [0, 4, 7], [0]],
6272
+ [[0, 7, 10], [0, 4, 7, 10], [0]], [[0, 8], [0, 3, 8], [8]],
6273
+ [[0, 9], [0, 4, 9], [9]], [[0, 10], [2, 5, 10], [10]], [[1], [1, 8], [8]],
6274
+ [[1, 4], [1, 4, 9], [9]], [[1, 4, 6], [1, 4, 6, 9], [6]],
6275
+ [[1, 4, 6, 9], [1, 4, 8, 11], [4]], [[1, 4, 6, 10], [0, 3, 5, 9], [5]],
6276
+ [[1, 4, 6, 11], [1, 4, 6, 9], [6]], [[1, 4, 7], [1, 4, 7, 10], [10]],
6277
+ [[1, 4, 7, 10], [0, 4, 7, 10], [0]],
6278
+ [[1, 4, 7, 11], [1, 4, 6, 10], [1, 6, 10]], [[1, 4, 8], [1, 4, 8, 11], [1]],
6279
+ [[1, 4, 8, 11], [1, 4, 6, 9], [1, 4, 9]], [[1, 4, 9], [1, 4, 6, 9], [9]],
6280
+ [[1, 4, 10], [1, 4, 6, 10], [6]], [[1, 4, 11], [1, 4, 8, 11], [1]],
6281
+ [[1, 5], [1, 5, 8], [1]], [[1, 5, 8], [1, 5, 8, 11], [1]],
6282
+ [[1, 5, 8, 11], [2, 5, 8, 11], [1]], [[1, 5, 9], [0, 3, 5, 9], [0, 5, 9]],
6283
+ [[1, 5, 10], [0, 4, 7, 10], [0]], [[1, 5, 11], [1, 5, 8, 11], [11]],
6284
+ [[1, 6], [1, 6, 10], [6]], [[1, 6, 9], [1, 4, 6, 9], [6]],
6285
+ [[1, 6, 10], [1, 4, 6, 10], [6]], [[1, 6, 11], [1, 4, 6, 11], [11]],
6286
+ [[1, 7], [1, 4, 7], [4]], [[1, 7, 10], [1, 4, 7, 10], [4]],
6287
+ [[1, 7, 11], [1, 4, 7, 11], [7]], [[1, 8], [1, 5, 8], [1]],
6288
+ [[1, 8, 11], [1, 4, 8, 11], [1]], [[1, 9], [1, 4, 9], [9]],
6289
+ [[1, 10], [1, 5, 10], [10]], [[1, 11], [2, 6, 11], [11]], [[2], [2, 9], [9]],
6290
+ [[2, 5], [2, 5, 9], [2]], [[2, 5, 8], [2, 5, 8, 11], [2]],
6291
+ [[2, 5, 8, 11], [1, 4, 7, 10], [0, 3, 8]],
6292
+ [[2, 5, 9], [0, 3, 5, 9], [2, 5, 10]], [[2, 5, 10], [0, 3, 5, 9], [2, 10]],
6293
+ [[2, 5, 11], [2, 5, 8, 11], [8]], [[2, 6], [2, 6, 9], [2]],
6294
+ [[2, 6, 9], [1, 4, 6, 9], [1, 4, 9]], [[2, 6, 10], [1, 4, 6, 10], [1, 6, 10]],
6295
+ [[2, 6, 11], [1, 4, 6, 10], [1, 6, 10]], [[2, 7], [2, 7, 11], [7]],
6296
+ [[2, 7, 10], [0, 4, 7, 10], [0]], [[2, 7, 11], [1, 4, 6, 9], [1, 4, 9]],
6297
+ [[2, 8], [4, 8, 11], [4]], [[2, 8, 11], [2, 5, 8, 11], [4]],
6298
+ [[2, 9], [2, 6, 9], [2]], [[2, 10], [2, 5, 10], [10]],
6299
+ [[2, 11], [2, 7, 11], [7]], [[3], [3, 10], [10]], [[3, 5], [3, 7, 10], [3]],
6300
+ [[3, 5, 8], [0, 3, 5, 8], [8]], [[3, 5, 8, 11], [2, 5, 8, 11], [2]],
6301
+ [[3, 5, 9], [0, 3, 5, 9], [5]], [[3, 5, 10], [0, 3, 5, 10], [5, 10]],
6302
+ [[3, 5, 11], [3, 5, 8, 11], [5]], [[3, 7], [3, 7, 10], [3]],
6303
+ [[3, 7, 10], [0, 3, 7, 10], [10]], [[3, 7, 11], [0, 3, 7, 10], [3, 7, 10]],
6304
+ [[3, 8], [0, 3, 8], [8]], [[3, 8, 11], [3, 5, 8, 11], [11]],
6305
+ [[3, 9], [0, 3, 9], [9]], [[3, 10], [3, 7, 10], [3]],
6306
+ [[3, 11], [3, 8, 11], [8]], [[4], [4, 11], [11]], [[4, 6], [4, 7, 11], [4]],
6307
+ [[4, 6, 9], [1, 4, 6, 9], [9]], [[4, 6, 10], [1, 4, 6, 10], [6]],
6308
+ [[4, 6, 11], [1, 4, 6, 11], [11]], [[4, 7], [0, 4, 7], [0]],
6309
+ [[4, 7, 10], [0, 4, 7, 10], [0]], [[4, 7, 11], [1, 4, 7, 11], [11]],
6310
+ [[4, 8], [4, 8, 11], [4]], [[4, 8, 11], [1, 4, 8, 11], [4]],
6311
+ [[4, 9], [1, 4, 9], [9]], [[4, 10], [4, 7, 10], [7]],
6312
+ [[4, 11], [4, 8, 11], [4]], [[5], [0, 5, 9], [0]], [[5, 8], [0, 5, 8], [5]],
6313
+ [[5, 8, 11], [1, 5, 8, 11], [1]], [[5, 9], [0, 5, 9], [5]],
6314
+ [[5, 10], [2, 5, 10], [10]], [[5, 11], [0, 5, 9], [5]], [[6], [1, 6], [1]],
6315
+ [[6, 9], [2, 6, 9], [2]], [[6, 10], [1, 6, 10], [6]],
6316
+ [[6, 11], [2, 6, 11], [11]], [[7], [2, 7, 11], [2]],
6317
+ [[7, 10], [2, 7, 10], [7]], [[7, 11], [2, 7, 11], [7]], [[8], [3, 8], [3]],
6318
+ [[8, 11], [4, 8, 11], [4]], [[9], [4, 9], [4]], [[10], [2, 5, 10], [5]],
6319
+ [[11], [6, 11], [6]]]
6320
+
6321
+ ###################################################################################
6322
+
6323
+ def pitches_to_tones(pitches):
6324
+ return [p % 12 for p in pitches]
6325
+
6326
+ ###################################################################################
6327
+
6328
+ def tones_to_pitches(tones, base_octave=5):
6329
+ return [(base_octave * 12) + t for t in tones]
6330
+
6331
+ ###################################################################################
6332
+
6333
+ def find_closest_value(lst, val):
6334
+
6335
+ closest_value = min(lst, key=lambda x: abs(val - x))
6336
+ closest_value_indexes = [i for i in range(len(lst)) if lst[i] == closest_value]
6337
+
6338
+ return [closest_value, abs(val - closest_value), closest_value_indexes]
6339
+
6340
+ ###################################################################################
6341
+
6342
+ def transpose_tones_chord(tones_chord, transpose_value=0):
6343
+ return sorted([((60+t)+transpose_value) % 12 for t in sorted(set(tones_chord))])
6344
+
6345
+ ###################################################################################
6346
+
6347
+ def transpose_tones(tones, transpose_value=0):
6348
+ return [((60+t)+transpose_value) % 12 for t in tones]
6349
+
6350
+ ###################################################################################
6351
+
6352
+ def transpose_pitches_chord(pitches_chord, transpose_value=0):
6353
+ return [max(1, min(127, p+transpose_value)) for p in sorted(set(pitches_chord), reverse=True)]
6354
+
6355
+ ###################################################################################
6356
+
6357
+ def transpose_pitches(pitches, transpose_value=0):
6358
+ return [max(1, min(127, p+transpose_value)) for p in pitches]
6359
+
6360
+ ###################################################################################
6361
+
6362
+ # This is the end of the TMIDI X Python module
6363
+
6364
+ ###################################################################################