Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
|
@@ -5168,6 +5168,7 @@ def advanced_check_and_fix_chords_in_chordified_score(chordified_score,
|
|
| 5168 |
use_filtered_chords=False,
|
| 5169 |
use_full_chords=True,
|
| 5170 |
remove_duplicate_pitches=True,
|
|
|
|
| 5171 |
skip_drums=False
|
| 5172 |
):
|
| 5173 |
fixed_chordified_score = []
|
|
@@ -5262,32 +5263,34 @@ def advanced_check_and_fix_chords_in_chordified_score(chordified_score,
|
|
| 5262 |
new_chord.add(tuple(e))
|
| 5263 |
pipa.append([e[pitches_index], e[patches_index]])
|
| 5264 |
|
| 5265 |
-
|
| 5266 |
|
| 5267 |
-
|
| 5268 |
-
|
| 5269 |
-
|
| 5270 |
-
if e[
|
| 5271 |
-
bad_chord.add(tuple(e))
|
| 5272 |
-
|
| 5273 |
-
elif (e[pitches_index]+1) % 12 not in tones_chord:
|
| 5274 |
-
bad_chord.add(tuple(e))
|
| 5275 |
-
|
| 5276 |
-
elif (e[pitches_index]-1) % 12 not in tones_chord:
|
| 5277 |
-
bad_chord.add(tuple(e))
|
| 5278 |
|
| 5279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5280 |
|
| 5281 |
-
|
| 5282 |
|
| 5283 |
-
|
| 5284 |
|
| 5285 |
-
|
| 5286 |
|
| 5287 |
-
|
| 5288 |
-
|
| 5289 |
-
|
| 5290 |
-
|
| 5291 |
|
| 5292 |
if not skip_drums:
|
| 5293 |
for e in c:
|
|
@@ -7457,7 +7460,8 @@ def harmonize_enhanced_melody_score_notes_to_ms_SONG(escore_notes,
|
|
| 7457 |
def check_and_fix_pitches_chord(pitches_chord,
|
| 7458 |
remove_duplicate_pitches=True,
|
| 7459 |
use_filtered_chords=False,
|
| 7460 |
-
use_full_chords=True
|
|
|
|
| 7461 |
):
|
| 7462 |
|
| 7463 |
if remove_duplicate_pitches:
|
|
@@ -7524,30 +7528,32 @@ def check_and_fix_pitches_chord(pitches_chord,
|
|
| 7524 |
new_chord.add(tuple([e]))
|
| 7525 |
pipa.append(e)
|
| 7526 |
|
| 7527 |
-
|
| 7528 |
|
| 7529 |
-
|
| 7530 |
-
|
| 7531 |
-
|
| 7532 |
-
bad_chord.add(tuple([e]))
|
| 7533 |
-
|
| 7534 |
-
elif (e+1) % 12 not in tones_chord:
|
| 7535 |
-
bad_chord.add(tuple([e]))
|
| 7536 |
|
| 7537 |
-
|
| 7538 |
-
|
| 7539 |
-
|
| 7540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7541 |
|
| 7542 |
-
|
| 7543 |
|
| 7544 |
-
|
| 7545 |
|
| 7546 |
-
|
| 7547 |
|
| 7548 |
-
|
| 7549 |
-
|
| 7550 |
-
|
| 7551 |
|
| 7552 |
new_pitches_chord = [e[0] for e in new_chord]
|
| 7553 |
|
|
|
|
| 5168 |
use_filtered_chords=False,
|
| 5169 |
use_full_chords=True,
|
| 5170 |
remove_duplicate_pitches=True,
|
| 5171 |
+
fix_bad_pitches=False,
|
| 5172 |
skip_drums=False
|
| 5173 |
):
|
| 5174 |
fixed_chordified_score = []
|
|
|
|
| 5263 |
new_chord.add(tuple(e))
|
| 5264 |
pipa.append([e[pitches_index], e[patches_index]])
|
| 5265 |
|
| 5266 |
+
if fix_bad_pitches:
|
| 5267 |
|
| 5268 |
+
bad_chord = set()
|
| 5269 |
+
|
| 5270 |
+
for e in chord:
|
| 5271 |
+
if e[channels_index] != 9:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5272 |
|
| 5273 |
+
if e[pitches_index] % 12 not in tones_chord:
|
| 5274 |
+
bad_chord.add(tuple(e))
|
| 5275 |
+
|
| 5276 |
+
elif (e[pitches_index]+1) % 12 not in tones_chord:
|
| 5277 |
+
bad_chord.add(tuple(e))
|
| 5278 |
+
|
| 5279 |
+
elif (e[pitches_index]-1) % 12 not in tones_chord:
|
| 5280 |
+
bad_chord.add(tuple(e))
|
| 5281 |
+
|
| 5282 |
+
for bc in bad_chord:
|
| 5283 |
|
| 5284 |
+
bc = list(bc)
|
| 5285 |
|
| 5286 |
+
tone = find_closest_tone(tones_chord, bc[pitches_index] % 12)
|
| 5287 |
|
| 5288 |
+
new_pitch = ((bc[pitches_index] // 12) * 12) + tone
|
| 5289 |
|
| 5290 |
+
if [new_pitch, bc[patches_index]] not in pipa:
|
| 5291 |
+
bc[pitches_index] = new_pitch
|
| 5292 |
+
new_chord.add(tuple(bc))
|
| 5293 |
+
pipa.append([[new_pitch], bc[patches_index]])
|
| 5294 |
|
| 5295 |
if not skip_drums:
|
| 5296 |
for e in c:
|
|
|
|
| 7460 |
def check_and_fix_pitches_chord(pitches_chord,
|
| 7461 |
remove_duplicate_pitches=True,
|
| 7462 |
use_filtered_chords=False,
|
| 7463 |
+
use_full_chords=True,
|
| 7464 |
+
fix_bad_pitches=False,
|
| 7465 |
):
|
| 7466 |
|
| 7467 |
if remove_duplicate_pitches:
|
|
|
|
| 7528 |
new_chord.add(tuple([e]))
|
| 7529 |
pipa.append(e)
|
| 7530 |
|
| 7531 |
+
if fix_bad_pitches:
|
| 7532 |
|
| 7533 |
+
bad_chord = set()
|
| 7534 |
+
|
| 7535 |
+
for e in chord:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7536 |
|
| 7537 |
+
if e % 12 not in tones_chord:
|
| 7538 |
+
bad_chord.add(tuple([e]))
|
| 7539 |
+
|
| 7540 |
+
elif (e+1) % 12 not in tones_chord:
|
| 7541 |
+
bad_chord.add(tuple([e]))
|
| 7542 |
+
|
| 7543 |
+
elif (e-1) % 12 not in tones_chord:
|
| 7544 |
+
bad_chord.add(tuple([e]))
|
| 7545 |
+
|
| 7546 |
+
for bc in bad_chord:
|
| 7547 |
|
| 7548 |
+
bc = list(bc)
|
| 7549 |
|
| 7550 |
+
tone = find_closest_tone(tones_chord, bc[0] % 12)
|
| 7551 |
|
| 7552 |
+
new_pitch = ((bc[0] // 12) * 12) + tone
|
| 7553 |
|
| 7554 |
+
if new_pitch not in pipa:
|
| 7555 |
+
new_chord.add(tuple([new_pitch]))
|
| 7556 |
+
pipa.append(new_pitch)
|
| 7557 |
|
| 7558 |
new_pitches_chord = [e[0] for e in new_chord]
|
| 7559 |
|