Spaces:
Running
Running
asigalov61
commited on
Commit
•
b70aa28
1
Parent(s):
5301c38
Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
@@ -5192,10 +5192,11 @@ def advanced_check_and_fix_chords_in_chordified_score(chordified_score,
|
|
5192 |
###################################################################################
|
5193 |
|
5194 |
def score_chord_to_tones_chord(chord,
|
|
|
5195 |
channels_index=3,
|
5196 |
pitches_index=4):
|
5197 |
|
5198 |
-
return sorted(set([p[4] % 12 for p in chord if p[channels_index] != 9]))
|
5199 |
|
5200 |
###################################################################################
|
5201 |
|
@@ -5215,6 +5216,8 @@ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
|
|
5215 |
melody_start_chord=0,
|
5216 |
melody_notes_min_duration=-1,
|
5217 |
melody_notes_max_duration=255,
|
|
|
|
|
5218 |
melody_base_octave=5,
|
5219 |
melody_channel=3,
|
5220 |
melody_patch=40,
|
@@ -5252,13 +5255,13 @@ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
|
|
5252 |
|
5253 |
if not all(d == -1 for d in durs):
|
5254 |
ndurs = [d for d in durs if d != -1]
|
5255 |
-
avg_dur = (sum(ndurs) / len(ndurs)) /
|
5256 |
best_dur = min(durs, key=lambda x:abs(x-avg_dur))
|
5257 |
pidx = durs.index(best_dur)
|
5258 |
|
5259 |
cc = copy.deepcopy(c[pidx])
|
5260 |
|
5261 |
-
if c[0][1] >= pt -
|
5262 |
|
5263 |
cc[3] = melody_channel
|
5264 |
cc[4] = (c[pidx][4] % 24)
|
@@ -5293,8 +5296,8 @@ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
|
|
5293 |
e[4] = (melody_base_octave * 12) + smoothed[i]
|
5294 |
|
5295 |
for i, m in enumerate(smoothed_melody[1:]):
|
5296 |
-
if m[1] - smoothed_melody[i][1]
|
5297 |
-
smoothed_melody[i][2] = m[1] - smoothed_melody[i][1]
|
5298 |
|
5299 |
adjust_score_velocities(smoothed_melody, melody_max_velocity)
|
5300 |
|
|
|
5192 |
###################################################################################
|
5193 |
|
5194 |
def score_chord_to_tones_chord(chord,
|
5195 |
+
transpose_value=0,
|
5196 |
channels_index=3,
|
5197 |
pitches_index=4):
|
5198 |
|
5199 |
+
return sorted(set([(p[4]+transpose_value) % 12 for p in chord if p[channels_index] != 9]))
|
5200 |
|
5201 |
###################################################################################
|
5202 |
|
|
|
5216 |
melody_start_chord=0,
|
5217 |
melody_notes_min_duration=-1,
|
5218 |
melody_notes_max_duration=255,
|
5219 |
+
melody_duration_overlap_tolerance=4,
|
5220 |
+
melody_avg_duration_divider=2,
|
5221 |
melody_base_octave=5,
|
5222 |
melody_channel=3,
|
5223 |
melody_patch=40,
|
|
|
5255 |
|
5256 |
if not all(d == -1 for d in durs):
|
5257 |
ndurs = [d for d in durs if d != -1]
|
5258 |
+
avg_dur = (sum(ndurs) / len(ndurs)) / melody_avg_duration_divider
|
5259 |
best_dur = min(durs, key=lambda x:abs(x-avg_dur))
|
5260 |
pidx = durs.index(best_dur)
|
5261 |
|
5262 |
cc = copy.deepcopy(c[pidx])
|
5263 |
|
5264 |
+
if c[0][1] >= pt - melody_duration_overlap_tolerance and best_dur >= min_duration:
|
5265 |
|
5266 |
cc[3] = melody_channel
|
5267 |
cc[4] = (c[pidx][4] % 24)
|
|
|
5296 |
e[4] = (melody_base_octave * 12) + smoothed[i]
|
5297 |
|
5298 |
for i, m in enumerate(smoothed_melody[1:]):
|
5299 |
+
if m[1] - smoothed_melody[i][1] < melody_notes_max_duration:
|
5300 |
+
smoothed_melody[i][2] = m[1] - smoothed_melody[i][1]
|
5301 |
|
5302 |
adjust_score_velocities(smoothed_melody, melody_max_velocity)
|
5303 |
|