Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
@@ -4690,7 +4690,8 @@ def augment_enhanced_score_notes(enhanced_score_notes,
|
|
4690 |
pitch_shift=0,
|
4691 |
ceil_timings=False,
|
4692 |
round_timings=False,
|
4693 |
-
legacy_timings=True
|
|
|
4694 |
):
|
4695 |
|
4696 |
esn = copy.deepcopy(enhanced_score_notes)
|
@@ -4740,6 +4741,9 @@ def augment_enhanced_score_notes(enhanced_score_notes,
|
|
4740 |
esn.sort(key=lambda x: x[6])
|
4741 |
esn.sort(key=lambda x: x[4], reverse=True)
|
4742 |
esn.sort(key=lambda x: x[1])
|
|
|
|
|
|
|
4743 |
|
4744 |
return esn
|
4745 |
|
@@ -9256,6 +9260,127 @@ def find_highest_density_escore_notes_chunk(escore_notes, max_chunk_time=512):
|
|
9256 |
|
9257 |
return chunk_escore
|
9258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9259 |
###################################################################################
|
9260 |
#
|
9261 |
# This is the end of the TMIDI X Python module
|
|
|
4690 |
pitch_shift=0,
|
4691 |
ceil_timings=False,
|
4692 |
round_timings=False,
|
4693 |
+
legacy_timings=True,
|
4694 |
+
sort_drums_last=False
|
4695 |
):
|
4696 |
|
4697 |
esn = copy.deepcopy(enhanced_score_notes)
|
|
|
4741 |
esn.sort(key=lambda x: x[6])
|
4742 |
esn.sort(key=lambda x: x[4], reverse=True)
|
4743 |
esn.sort(key=lambda x: x[1])
|
4744 |
+
|
4745 |
+
if sort_drums_last:
|
4746 |
+
esn.sort(key=lambda x: (x[1], -x[4], x[6]) if x[6] != 128 else (x[1], x[6], -x[4]))
|
4747 |
|
4748 |
return esn
|
4749 |
|
|
|
9260 |
|
9261 |
return chunk_escore
|
9262 |
|
9263 |
+
###################################################################################
|
9264 |
+
|
9265 |
+
def advanced_add_drums_to_escore_notes(escore_notes,
|
9266 |
+
main_beat_min_dtime=5,
|
9267 |
+
main_beat_dtime_thres=1,
|
9268 |
+
drums_durations_value=2,
|
9269 |
+
drums_pitches_velocities=[(36, 100),
|
9270 |
+
(38, 100),
|
9271 |
+
(41, 125)],
|
9272 |
+
recalculate_score_timings=True,
|
9273 |
+
intro_drums_count=4,
|
9274 |
+
intro_drums_time_k=4,
|
9275 |
+
intro_drums_pitch_velocity=[37, 110]
|
9276 |
+
):
|
9277 |
+
|
9278 |
+
#===========================================================
|
9279 |
+
|
9280 |
+
new_dscore = delta_score_notes(escore_notes)
|
9281 |
+
|
9282 |
+
times = [d[1] for d in new_dscore if d[1] != 0]
|
9283 |
+
|
9284 |
+
time = [c[0] for c in Counter(times).most_common() if c[0] >= main_beat_min_dtime][0]
|
9285 |
+
|
9286 |
+
#===========================================================
|
9287 |
+
|
9288 |
+
if intro_drums_count > 0:
|
9289 |
+
|
9290 |
+
drums_score = []
|
9291 |
+
|
9292 |
+
for i in range(intro_drums_count):
|
9293 |
+
|
9294 |
+
if i == 0:
|
9295 |
+
dtime = 0
|
9296 |
+
|
9297 |
+
else:
|
9298 |
+
dtime = time
|
9299 |
+
|
9300 |
+
drums_score.append(['note',
|
9301 |
+
dtime * intro_drums_time_k,
|
9302 |
+
drums_durations_value,
|
9303 |
+
9,
|
9304 |
+
intro_drums_pitch_velocity[0],
|
9305 |
+
intro_drums_pitch_velocity[1],
|
9306 |
+
128]
|
9307 |
+
)
|
9308 |
+
|
9309 |
+
new_dscore[0][1] = time * intro_drums_time_k
|
9310 |
+
|
9311 |
+
new_dscore = drums_score + new_dscore
|
9312 |
+
|
9313 |
+
#===========================================================
|
9314 |
+
|
9315 |
+
for e in new_dscore:
|
9316 |
+
|
9317 |
+
if abs(e[1] - time) == main_beat_dtime_thres:
|
9318 |
+
e[1] = time
|
9319 |
+
|
9320 |
+
if recalculate_score_timings:
|
9321 |
+
|
9322 |
+
if e[1] % time != 0 and e[1] > time:
|
9323 |
+
if e[1] % time < time // 2:
|
9324 |
+
e[1] -= e[1] % time
|
9325 |
+
|
9326 |
+
else:
|
9327 |
+
e[1] += time - (e[1] % time)
|
9328 |
+
|
9329 |
+
#===========================================================
|
9330 |
+
|
9331 |
+
drums_score = []
|
9332 |
+
|
9333 |
+
dtime = 0
|
9334 |
+
|
9335 |
+
idx = 0
|
9336 |
+
|
9337 |
+
for i, e in enumerate(new_dscore):
|
9338 |
+
|
9339 |
+
drums_score.append(e)
|
9340 |
+
|
9341 |
+
dtime += e[1]
|
9342 |
+
|
9343 |
+
if e[1] != 0:
|
9344 |
+
idx += 1
|
9345 |
+
|
9346 |
+
if i >= intro_drums_count:
|
9347 |
+
|
9348 |
+
if (e[1] % time == 0 and e[1] != 0) or i == 0:
|
9349 |
+
|
9350 |
+
if idx % 2 == 0 and e[1] != 0:
|
9351 |
+
drums_score.append(['note',
|
9352 |
+
0,
|
9353 |
+
drums_durations_value,
|
9354 |
+
9,
|
9355 |
+
drums_pitches_velocities[0][0],
|
9356 |
+
drums_pitches_velocities[0][1],
|
9357 |
+
128]
|
9358 |
+
)
|
9359 |
+
|
9360 |
+
if idx % 2 != 0 and e[1] != 0:
|
9361 |
+
drums_score.append(['note',
|
9362 |
+
0,
|
9363 |
+
drums_durations_value,
|
9364 |
+
9,
|
9365 |
+
drums_pitches_velocities[1][0],
|
9366 |
+
drums_pitches_velocities[1][1],
|
9367 |
+
128]
|
9368 |
+
)
|
9369 |
+
|
9370 |
+
if idx % 4 == 0 and e[1] != 0:
|
9371 |
+
drums_score.append(['note',
|
9372 |
+
0,
|
9373 |
+
drums_durations_value,
|
9374 |
+
9,
|
9375 |
+
drums_pitches_velocities[2][0],
|
9376 |
+
drums_pitches_velocities[2][1],
|
9377 |
+
128]
|
9378 |
+
)
|
9379 |
+
|
9380 |
+
#===========================================================
|
9381 |
+
|
9382 |
+
return delta_score_to_abs_score(drums_score)
|
9383 |
+
|
9384 |
###################################################################################
|
9385 |
#
|
9386 |
# This is the end of the TMIDI X Python module
|