Skip to content

Commit

Permalink
Add zoom rotary encoder for waveform view
Browse files Browse the repository at this point in the history
Again, we have to resort to osascript. Yuck!
  • Loading branch information
samsta committed May 25, 2022
1 parent c4489be commit a5f9f38
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions xone.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,26 @@ def handle_encoder_turn(self, value):

self._application.view.scroll_view(nav, 'Browser', False)

class WaveformZoom(DynamicEncoder):
def __init__(self, application, song):
super(WaveformZoom, self).__init__(None, None)
self._application = application
self._song = song

def handle_button(self, value):
if (value > 64):
self._song.view.follow_song = True

def handle_encoder_turn(self, value):
self._application.view.show_view('Detail/Clip')
self._application.view.focus_view('Detail/Clip')
if value < 64:
# zoom in yuckily
os.system("osascript -e 'tell application \"System Events\" to tell process \"Live\" to key code 24'")
else:
# zoom out yuckily
os.system("osascript -e 'tell application \"System Events\" to tell process \"Live\" to key code 27'")


class GlobalStopButton(ButtonElement):
def __init__(self, button_cc, song):
Expand Down Expand Up @@ -631,7 +651,7 @@ def __init__(self, instance):

with self.component_guard():
self._set_suppress_rebuild_requests(True)
self.shift_button = MultiShiftButton(BUTTON_LL, 3)
self.shift_button = MultiShiftButton(BUTTON_LL, 4)

self.init_session()
self.init_mixer()
Expand All @@ -648,7 +668,8 @@ def init_session(self):
[
TempoEncoder(self.transport),
DynamicEncoder(None, self.song().master_track.mixer_device.cue_volume),
BrowserScroller(self.application(), BrowserScroller.HORIZONTAL)
BrowserScroller(self.application(), BrowserScroller.HORIZONTAL),
WaveformZoom(self.application(), self.song())
],
self.shift_button, ENCODER_LL, PUSH_ENCODER_LL)

Expand Down

0 comments on commit a5f9f38

Please sign in to comment.