-
Notifications
You must be signed in to change notification settings - Fork 16
/
synth_single_media.py
57 lines (46 loc) · 1.32 KB
/
synth_single_media.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import glob
import time
import datetime
import threading
from rearender.utils import traverse_dir, render_media
from rearender.autogui import close_project
# start
program_start_time = time.time()
# config
tolerance_sec = 20
# IO folders
# [!] full path recommended
path_indir = '/Users/username/.../data/signle_media/midi'
path_outdir = '/Users/username/.../data/signle_media/audio'
# list files
filelist = traverse_dir(
path_indir,
is_pure=True,
is_sort=True)
num_files = len(filelist)
print('num files:', num_files)
# list files
for fidx in range(num_files):
time.sleep(0.5)
song_start_time = time.time()
# set file
filename = filelist[fidx]
ext = filename.split('.')[-1]
path_midi = os.path.join(path_indir, filename)
path_audio = os.path.join(path_outdir, filename[:-len(ext)-1])
# print
print('({}/{}) - {}'.format(fidx, num_files, filename))
print(' > audio:', path_audio)
# synthesis
render_media(path_midi, path_audio, bpm=120)
# runtime
runtime = time.time() - song_start_time
print(' > runtime', runtime)
if runtime > tolerance_sec:
# reopen project
close_project(reopen=True)
# finished
print('\n===== Finished =====')
runtime = time.time() - program_start_time
print('Elapsed time:', str(datetime.timedelta(seconds=runtime)))