-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgolive.py
75 lines (57 loc) · 2.29 KB
/
golive.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from user_interaction import *
import live
import os
import time
import traceback
import sys
def go_live_ableton(song, load_in_ableton=True, show_visuals=True):
short = False
try:
if show_visuals:
ap, app = show_song_info(0,
song.times,
song.beat,
song.tempo,
song.key,
song.karaoke_bars,
song.pitch_labels,
song.scale_mode)
if load_in_ableton:
os.system('all_params='
+ str(song.preset)
+ ' osascript as_open.scpt')
time.sleep(1)
set = live.Set()
set.scan(scan_devices=True)
set.tempo = song.tempo
# play all tracks
for t in set.tracks:
t.clips[0].play()
# wait for song to finish playing: complete or 5 seconds only
if not short:
bar_karaoke = 0
chords_sequence = 0
for bar in range(0+1, song.num_bars+1):
delay_of_timer = 0
if show_visuals:
ap, app, delay_of_timer = update_chords_label(ap, app, bar,
song.num_bars,
song.karaoke_chords[chords_sequence],
bar_karaoke,
song.karaoke_roles[chords_sequence])
time.sleep((song.get_song_duration() / song.num_bars)-delay_of_timer)
bar_karaoke += 1
if bar_karaoke == 12 and chords_sequence < len(song.karaoke_chords)-1:
chords_sequence += 1
bar_karaoke = 0
else:
time.sleep(2)
if load_in_ableton:
os.system('osascript as_focus.scpt')
for t in set.tracks:
t.clips[0].stop()
return True
except Exception as error:
print('ERROR: {}'.format(traceback.format_exc()))
sys.exit()
#time.sleep(1)