drones
This commit is contained in:
parent
146c1ee9e7
commit
934f0c4086
1 changed files with 39 additions and 0 deletions
39
render.py
39
render.py
|
@ -70,6 +70,20 @@ if not os.path.exists('VOCALS.json'):
|
|||
else:
|
||||
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):
|
||||
global PATHS
|
||||
if id not in PATHS:
|
||||
|
@ -191,6 +205,8 @@ def sequence(seq, letter):
|
|||
'text': [],
|
||||
'vocals': [],
|
||||
'music': [],
|
||||
'drones0': [],
|
||||
'drones1': [],
|
||||
}
|
||||
duration = 0
|
||||
MAX_DURATION = 60 * 2 + 5
|
||||
|
@ -334,6 +350,29 @@ def sequence(seq, letter):
|
|||
blank = {'blank': True, 'duration': silence - silence_start}
|
||||
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:
|
||||
if result[track]:
|
||||
|
|
Loading…
Reference in a new issue