This commit is contained in:
j 2017-03-15 11:23:43 +01:00
parent 146c1ee9e7
commit 934f0c4086

View file

@ -70,6 +70,20 @@ if not os.path.exists('VOCALS.json'):
else: else:
VOCALS = json.load(open('VOCALS.json')) VOCALS = json.load(open('VOCALS.json'))
if not os.path.exists('DRONES.json'):
DRONES = defaultdict(list)
for letter in os.listdir('drones'):
for fn in sorted(os.listdir(os.path.join('drones', letter))):
path = os.path.join('drones', letter, fn)
DRONES[letter[0]].append({
'path': path,
'duration': ox.avinfo(path)['duration']
})
with open('DRONES.json', 'w') as fd:
json.dump(DRONES, fd, indent=2, sort_keys=True)
else:
DRONES = json.load(open('DRONES.json'))
def get_path(id): def get_path(id):
global PATHS global PATHS
if id not in PATHS: if id not in PATHS:
@ -191,6 +205,8 @@ def sequence(seq, letter):
'text': [], 'text': [],
'vocals': [], 'vocals': [],
'music': [], 'music': [],
'drones0': [],
'drones1': [],
} }
duration = 0 duration = 0
MAX_DURATION = 60 * 2 + 5 MAX_DURATION = 60 * 2 + 5
@ -334,6 +350,29 @@ def sequence(seq, letter):
blank = {'blank': True, 'duration': silence - silence_start} blank = {'blank': True, 'duration': silence - silence_start}
result['vocals'].append(blank) result['vocals'].append(blank)
''' '''
# drones
if letter in DRONES:
for track in ('drones0', 'drones1'):
position = 0
while position < duration:
n = seq()
if n == 9:
position += add_blank(result[track], min(3.141, duration - position))
else:
clip = DRONES[letter][n]
position += clip['duration']
if result[track] and position > duration \
and result[track][-1].get('blank') \
and result[track][-1]['duration'] > clip['duration']:
result[track][-1]['duration'] -= (position-duration)
position = duration
if position <= duration:
result[track].append(clip)
else:
position -= clip['duration']
break
if position < duration:
position += add_blank(result[track], duration - position)
for track in result: for track in result:
if result[track]: if result[track]: