fix long vocals

This commit is contained in:
j 2017-03-01 10:20:49 +01:00
parent e99cfb7bdf
commit e80e6baf43

View file

@ -45,7 +45,7 @@ if not os.path.exists('MUSIC.json'):
'duration': ox.avinfo(path)['duration'] 'duration': ox.avinfo(path)['duration']
}) })
with open('MUSIC.json', 'w') as fd: with open('MUSIC.json', 'w') as fd:
json.dump(MUSIC, fd, indent=2) json.dump(MUSIC, fd, indent=2, sort_keys=True)
else: else:
MUSIC = json.load(open('MUSIC.json')) MUSIC = json.load(open('MUSIC.json'))
@ -59,7 +59,7 @@ if not os.path.exists('VOCALS.json'):
'duration': ox.avinfo(path)['duration'] 'duration': ox.avinfo(path)['duration']
}) })
with open('VOCALS.json', 'w') as fd: with open('VOCALS.json', 'w') as fd:
json.dump(VOCALS, fd, indent=2) json.dump(VOCALS, fd, indent=2, sort_keys=True)
else: else:
VOCALS = json.load(open('VOCALS.json')) VOCALS = json.load(open('VOCALS.json'))
@ -263,7 +263,7 @@ def sequence(seq, letter):
n = seq() n = seq()
clip = MUSIC[letter][n] clip = MUSIC[letter][n]
position += clip['duration'] position += clip['duration']
if position > duration \ if result[track] and position > duration \
and result[track][-1].get('blank') \ and result[track][-1].get('blank') \
and result[track][-1]['duration'] > clip['duration']: and result[track][-1]['duration'] > clip['duration']:
result[track][-1]['duration'] -= (position-duration) result[track][-1]['duration'] -= (position-duration)
@ -289,7 +289,7 @@ def sequence(seq, letter):
n = seq() n = seq()
clip = VOCALS[letter][n] clip = VOCALS[letter][n]
position += clip['duration'] position += clip['duration']
if position > duration \ if result[track] and position > duration \
and result[track][-1].get('blank') \ and result[track][-1].get('blank') \
and result[track][-1]['duration'] > clip['duration']: and result[track][-1]['duration'] > clip['duration']:
result[track][-1]['duration'] -= (position-duration) result[track][-1]['duration'] -= (position-duration)
@ -300,7 +300,6 @@ def sequence(seq, letter):
position -= clip['duration'] position -= clip['duration']
break break
if position < duration: if position < duration:
print('padding', track, duration, position)
position += add_blank(result[track], duration - position) position += add_blank(result[track], duration - position)
''' '''
if letter in VOCALS: if letter in VOCALS: