-
Notifications
You must be signed in to change notification settings - Fork 82
/
SpecialProSessionRecordingComponent.py
63 lines (49 loc) · 2.54 KB
/
SpecialProSessionRecordingComponent.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
# imported from https://github.com/poltow/Launchpad97
import Live
from _Framework.ClipCreator import ClipCreator
from _Framework.SessionRecordingComponent import SessionRecordingComponent, track_playing_slot, track_is_recording
_Q = Live.Song.Quantization
class SpecialProSessionRecordingComponent(SessionRecordingComponent):
def __init__(self, target_track_component, control_surface, *a, **k):
self._control_surface = control_surface
self._target_track_component = target_track_component
super(SpecialProSessionRecordingComponent, self).__init__(ClipCreator(), True, *a, **k)
self._is_record_mode = False
def _set_parent(self, parent):
self._parent = parent
def set_record_mode(self, record_mode):
self._is_record_mode = record_mode
def _is_fixed_length_on(self):
return self._parent._is_fixed_length_on()
def set_enabled(self, enable):
super(SpecialProSessionRecordingComponent, self).set_enabled(enable)
def _get_fixed_length(self):
return self._parent._get_fixed_length()
def _get_launch_quant(self):
return self._parent._get_launch_quant()
def _on_record_button_value(self):
if self.is_enabled():
if self._is_record_mode:
self._handle_pro_mode_record_behavior()
else:
if not self._stop_recording():
self._start_recording()
self._control_surface.show_message("SESSION RECORD ON")
else:
self._control_surface.show_message("SESSION RECORD OFF")
def _handle_pro_mode_record_behavior(self):
track = self._target_track_component.target_track #Selected Track
status = self.song().session_record_status
was_recording = status != Live.Song.SessionRecordStatus.off or self.song().session_record
if self._track_can_record(track) and not was_recording:
if self._is_fixed_length_on():
self.song().trigger_session_record(self._get_fixed_length())
else:
self.song().trigger_session_record()
elif not self._stop_recording():
self._start_recording()
self._control_surface.show_message("SESSION RECORD ON")
else:
self._control_surface.show_message("SESSION RECORD OFF")
def _track_can_record(self, track):
return track.can_be_armed and (track.arm or track.implicit_arm) and track in self.song().tracks