50% change try to continue with next clip in sequence

This commit is contained in:
j 2023-10-28 11:58:07 +02:00
parent 198934e465
commit 4058ac84c1

View file

@ -35,6 +35,16 @@ def random_choice(seq, items, pop=False):
def chance(seq, chance): def chance(seq, chance):
return (seq() / 10) >= chance return (seq() / 10) >= chance
def get_clip_by_seqid(clips, seqid):
selected = None
for i, clip in enumerate(clips):
if clip['seqid'] == seqid:
selected = i
break
if selected is not None:
return clips.pop(i)
return None
def compose(clips, target=150, base=1024, voice_over=None): def compose(clips, target=150, base=1024, voice_over=None):
length = 0 length = 0
@ -80,8 +90,17 @@ def compose(clips, target=150, base=1024, voice_over=None):
for vo in voice_overs: for vo in voice_overs:
scene['audio']['A3'].append(vo) scene['audio']['A3'].append(vo)
clip = None
while target - length > 0 and clips: while target - length > 0 and clips:
clip = random_choice(seq, clips, True) # coin flip which site is visible (50% chance)
if clip:
if chance(seq, 0.5):
next_seqid = clip['seqid'] + 1
clip = get_clip_by_seqid(clips, next_seqid)
else:
clip = None
if not clip:
clip = random_choice(seq, clips, True)
if not clips: if not clips:
clips = [c for c in all_clips if c != clip] clips = [c for c in all_clips if c != clip]
if not clips: if not clips: