Spaces:
Runtime error
Runtime error
Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
@@ -5215,7 +5215,7 @@ 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 |
-
|
5219 |
melody_channel=3,
|
5220 |
melody_patch=40,
|
5221 |
melody_max_velocity=110,
|
@@ -5261,7 +5261,7 @@ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
|
|
5261 |
if c[0][1] >= pt - 4 and best_dur >= min_duration:
|
5262 |
|
5263 |
cc[3] = melody_channel
|
5264 |
-
cc[4] = (
|
5265 |
cc[5] = 100 + ((c[pidx][4] % 12) * 2)
|
5266 |
cc[6] = melody_patch
|
5267 |
|
@@ -5276,12 +5276,28 @@ def add_melody_to_enhanced_score_notes(enhanced_score_notes,
|
|
5276 |
else:
|
5277 |
acc_score.extend(c)
|
5278 |
|
5279 |
-
for
|
5280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5281 |
|
5282 |
-
adjust_score_velocities(
|
5283 |
|
5284 |
-
final_score = sorted(
|
5285 |
|
5286 |
return final_score
|
5287 |
|
|
|
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,
|
5221 |
melody_max_velocity=110,
|
|
|
5261 |
if c[0][1] >= pt - 4 and best_dur >= min_duration:
|
5262 |
|
5263 |
cc[3] = melody_channel
|
5264 |
+
cc[4] = (c[pidx][4] % 24)
|
5265 |
cc[5] = 100 + ((c[pidx][4] % 12) * 2)
|
5266 |
cc[6] = melody_patch
|
5267 |
|
|
|
5276 |
else:
|
5277 |
acc_score.extend(c)
|
5278 |
|
5279 |
+
values = [e[4] % 24 for e in melody_score]
|
5280 |
+
smoothed = [values[0]]
|
5281 |
+
for i in range(1, len(values)):
|
5282 |
+
if abs(smoothed[-1] - values[i]) >= 12:
|
5283 |
+
if smoothed[-1] < values[i]:
|
5284 |
+
smoothed.append(values[i] - 12)
|
5285 |
+
else:
|
5286 |
+
smoothed.append(values[i] + 12)
|
5287 |
+
else:
|
5288 |
+
smoothed.append(values[i])
|
5289 |
+
|
5290 |
+
smoothed_melody = copy.deepcopy(melody_score)
|
5291 |
+
|
5292 |
+
for i, e in enumerate(smoothed_melody):
|
5293 |
+
e[4] = (melody_base_octave * 12) + smoothed[i]
|
5294 |
+
|
5295 |
+
for i, m in enumerate(smoothed_melody[1:]):
|
5296 |
+
smoothed_melody[i][2] = min(melody_notes_max_duration, m[1] - smoothed_melody[i][1] - 1)
|
5297 |
|
5298 |
+
adjust_score_velocities(smoothed_melody, melody_max_velocity)
|
5299 |
|
5300 |
+
final_score = sorted(smoothed_melody + acc_score, key=lambda x: (x[1], -x[4]))
|
5301 |
|
5302 |
return final_score
|
5303 |
|