asigalov61 commited on
Commit
49823aa
·
verified ·
1 Parent(s): f4c7996

Upload TMIDIX.py

Browse files
Files changed (1) hide show
  1. TMIDIX.py +21 -2
TMIDIX.py CHANGED
@@ -5225,15 +5225,34 @@ def advanced_check_and_fix_chords_in_chordified_score(chordified_score,
5225
 
5226
  c.sort(key = lambda x: x[pitches_index], reverse=True)
5227
 
 
 
5228
  for e in c:
5229
  if e[channels_index] != 9:
5230
  if e[pitches_index] % 12 in tones_chord:
5231
  new_chord.append(e)
 
5232
 
5233
- else:
5234
- if not skip_drums:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5235
  new_chord.append(e)
5236
 
 
 
5237
  fixed_chordified_score.append(new_chord)
5238
 
5239
  return fixed_chordified_score, bad_chords_counter, duplicate_pitches_counter
 
5225
 
5226
  c.sort(key = lambda x: x[pitches_index], reverse=True)
5227
 
5228
+ pipa = []
5229
+
5230
  for e in c:
5231
  if e[channels_index] != 9:
5232
  if e[pitches_index] % 12 in tones_chord:
5233
  new_chord.append(e)
5234
+ pipa.append([e[pitches_index], e[patches_index]])
5235
 
5236
+ bad_chord = [p for p in c if p[3] != 9 and p[4] % 12 not in tones_chord]
5237
+
5238
+ for bc in bad_chord:
5239
+
5240
+ tone = find_closest_tone(tones_chord, bc[4] % 12)
5241
+
5242
+ new_pitch = ((bc[4] // 12) * 12) + tone
5243
+
5244
+ if [new_pitch, bc[patches_index]] not in pipa:
5245
+ bc[4] = new_pitch
5246
+ new_chord.append(bc)
5247
+ pipa.append([[new_pitch], bc[patches_index]])
5248
+
5249
+ if not skip_drums:
5250
+ for e in c:
5251
+ if e[channels_index] == 9:
5252
  new_chord.append(e)
5253
 
5254
+ new_chord.sort(key = lambda x: (-x[pitches_index], x[patches_index]))
5255
+
5256
  fixed_chordified_score.append(new_chord)
5257
 
5258
  return fixed_chordified_score, bad_chords_counter, duplicate_pitches_counter