Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
@@ -51,7 +51,7 @@ r'''############################################################################
|
|
51 |
|
52 |
###################################################################################
|
53 |
|
54 |
-
__version__ = "25.
|
55 |
|
56 |
print('=' * 70)
|
57 |
print('TMIDIX Python module')
|
@@ -11380,39 +11380,39 @@ def create_files_list(datasets_paths=['./'],
|
|
11380 |
print('Processing', dataset_addr)
|
11381 |
print('=' * 70)
|
11382 |
|
11383 |
-
|
11384 |
-
|
11385 |
-
if randomize_dir_files:
|
11386 |
-
random.shuffle(filenames)
|
11387 |
-
|
11388 |
-
if max_num_files_per_dir > 0:
|
11389 |
-
max_num_files = max_num_files_per_dir
|
11390 |
-
|
11391 |
-
else:
|
11392 |
-
max_num_files = len(filenames)
|
11393 |
|
11394 |
-
|
11395 |
-
|
11396 |
-
|
|
|
|
|
|
|
|
|
|
|
11397 |
|
11398 |
-
|
11399 |
-
|
11400 |
-
|
11401 |
-
|
11402 |
-
|
11403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11404 |
else:
|
11405 |
-
|
|
|
11406 |
|
|
|
|
|
11407 |
else:
|
11408 |
-
|
11409 |
-
|
11410 |
-
|
11411 |
-
else:
|
11412 |
-
dupes_list.append(os.path.join(dirpath, file))
|
11413 |
-
else:
|
11414 |
-
fpath = os.path.join(dirpath, file)
|
11415 |
-
filez_set[fpath] = fpath
|
11416 |
|
11417 |
filez = list(filez_set.values())
|
11418 |
|
@@ -12976,9 +12976,10 @@ def merge_melody_notes(escore_notes, pitches_idx=4, max_dur=255):
|
|
12976 |
|
12977 |
def add_expressive_melody_to_enhanced_score_notes(escore_notes,
|
12978 |
melody_start_chord=0,
|
12979 |
-
melody_notes_max_duration=255,
|
12980 |
melody_channel=3,
|
12981 |
melody_patch=40,
|
|
|
|
|
12982 |
melody_max_velocity=120,
|
12983 |
acc_max_velocity=90,
|
12984 |
return_melody=False
|
@@ -13025,6 +13026,11 @@ def add_expressive_melody_to_enhanced_score_notes(escore_notes,
|
|
13025 |
song_f.extend(c)
|
13026 |
|
13027 |
song_f.extend(cscore[-1])
|
|
|
|
|
|
|
|
|
|
|
13028 |
|
13029 |
adjust_score_velocities(mel_f, melody_max_velocity)
|
13030 |
|
|
|
51 |
|
52 |
###################################################################################
|
53 |
|
54 |
+
__version__ = "25.5.2"
|
55 |
|
56 |
print('=' * 70)
|
57 |
print('TMIDIX Python module')
|
|
|
11380 |
print('Processing', dataset_addr)
|
11381 |
print('=' * 70)
|
11382 |
|
11383 |
+
for dirpath, dirnames, filenames in tqdm.tqdm(os.walk(dataset_addr), disable=not verbose):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11384 |
|
11385 |
+
if randomize_dir_files:
|
11386 |
+
random.shuffle(filenames)
|
11387 |
+
|
11388 |
+
if max_num_files_per_dir > 0:
|
11389 |
+
max_num_files = max_num_files_per_dir
|
11390 |
+
|
11391 |
+
else:
|
11392 |
+
max_num_files = len(filenames)
|
11393 |
|
11394 |
+
for file in filenames[:max_num_files]:
|
11395 |
+
if file.endswith(files_exts):
|
11396 |
+
if check_for_dupes:
|
11397 |
+
|
11398 |
+
if use_md5_hashes:
|
11399 |
+
md5_hash = hashlib.md5(open(os.path.join(dirpath, file), 'rb').read()).hexdigest()
|
11400 |
+
|
11401 |
+
if md5_hash not in filez_set:
|
11402 |
+
filez_set[md5_hash] = os.path.join(dirpath, file)
|
11403 |
+
|
11404 |
+
else:
|
11405 |
+
dupes_list.append(os.path.join(dirpath, file))
|
11406 |
+
|
11407 |
else:
|
11408 |
+
if file not in filez_set:
|
11409 |
+
filez_set[file] = os.path.join(dirpath, file)
|
11410 |
|
11411 |
+
else:
|
11412 |
+
dupes_list.append(os.path.join(dirpath, file))
|
11413 |
else:
|
11414 |
+
fpath = os.path.join(dirpath, file)
|
11415 |
+
filez_set[fpath] = fpath
|
|
|
|
|
|
|
|
|
|
|
|
|
11416 |
|
11417 |
filez = list(filez_set.values())
|
11418 |
|
|
|
12976 |
|
12977 |
def add_expressive_melody_to_enhanced_score_notes(escore_notes,
|
12978 |
melody_start_chord=0,
|
|
|
12979 |
melody_channel=3,
|
12980 |
melody_patch=40,
|
12981 |
+
melody_notes_max_duration=255,
|
12982 |
+
medley_max_min_durs=[],
|
12983 |
melody_max_velocity=120,
|
12984 |
acc_max_velocity=90,
|
12985 |
return_melody=False
|
|
|
13026 |
song_f.extend(c)
|
13027 |
|
13028 |
song_f.extend(cscore[-1])
|
13029 |
+
|
13030 |
+
if medley_max_min_durs:
|
13031 |
+
for e in mel_f:
|
13032 |
+
if e[2] >= medley_max_min_durs[0]:
|
13033 |
+
e[2] = medley_max_min_durs[1]
|
13034 |
|
13035 |
adjust_score_velocities(mel_f, melody_max_velocity)
|
13036 |
|