-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathview.py
50 lines (39 loc) · 2.83 KB
/
view.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
from functools import partial
from typing import Optional, Tuple, Any
from .handler import AbletonOSCHandler
class ViewHandler(AbletonOSCHandler):
def __init__(self, manager):
super().__init__(manager)
self.class_identifier = "view"
def init_api(self):
def get_selected_scene(params: Optional[Tuple] = ()):
return (list(self.song.scenes).index(self.song.view.selected_scene),)
def get_selected_track(params: Optional[Tuple] = ()):
return (list(self.song.tracks).index(self.song.view.selected_track),)
def get_selected_clip(params: Optional[Tuple] = ()):
return (get_selected_track()[0], get_selected_scene()[0])
def get_selected_device(params: Optional[Tuple] = ()):
return (get_selected_track()[0], list(self.song.view.selected_track.devices).index(self.song.view.selected_track.view.selected_device))
def set_selected_scene(params: Optional[Tuple] = ()):
self.song.view.selected_scene = self.song.scenes[params[0]]
def set_selected_track(params: Optional[Tuple] = ()):
self.song.view.selected_track = self.song.tracks[params[0]]
def set_selected_clip(params: Optional[Tuple] = ()):
set_selected_track((params[0],))
set_selected_scene((params[1],))
def set_selected_device(params: Optional[Tuple] = ()):
device = self.song.tracks[params[0]].devices[params[1]]
self.song.view.select_device(device)
return params[0], params[1]
self.osc_server.add_handler("/live/view/get/selected_scene", get_selected_scene)
self.osc_server.add_handler("/live/view/get/selected_track", get_selected_track)
self.osc_server.add_handler("/live/view/get/selected_clip", get_selected_clip)
self.osc_server.add_handler("/live/view/get/selected_device", get_selected_device)
self.osc_server.add_handler("/live/view/set/selected_scene", set_selected_scene)
self.osc_server.add_handler("/live/view/set/selected_track", set_selected_track)
self.osc_server.add_handler("/live/view/set/selected_clip", set_selected_clip)
self.osc_server.add_handler("/live/view/set/selected_device", set_selected_device)
self.osc_server.add_handler('/live/view/start_listen/selected_scene', partial(self._start_listen, self.song.view, "selected_scene", getter=get_selected_scene))
self.osc_server.add_handler('/live/view/start_listen/selected_track', partial(self._start_listen, self.song.view, "selected_track", getter=get_selected_track))
self.osc_server.add_handler('/live/view/stop_listen/selected_scene', partial(self._stop_listen, self.song.view, "selected_scene"))
self.osc_server.add_handler('/live/view/stop_listen/selected_track', partial(self._stop_listen, self.song.view, "selected_track"))