From aba7cda8e963c3398a9c034bd487b270bdbd5ade Mon Sep 17 00:00:00 2001 From: Casey Tucker Date: Fri, 15 Mar 2024 00:34:38 -0700 Subject: [PATCH] tweaks after testing with capture device --- bridge/bridge.py | 2 +- bridge/capture.py | 14 +++++++------- bridge/view.py | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bridge/bridge.py b/bridge/bridge.py index bc3bad7..fcd9465 100755 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -108,7 +108,7 @@ def check_connections(client, port): pass capture.disconnect() - log("Done.") + view.cursor_release() if __name__ == '__main__': main() diff --git a/bridge/capture.py b/bridge/capture.py index 298e863..5097509 100644 --- a/bridge/capture.py +++ b/bridge/capture.py @@ -1,3 +1,4 @@ +from time import sleep from view import log from bindings.capmix import capmix, Type @@ -7,8 +8,7 @@ def __init__(self, name='STUDIO-CAPTURE MIDI 2'): self.name = name self.ok = False - @classmethod - def listener(cls, event): + def listener(self, event): value = event.value() self.model.set_cache(event.addr, value) @@ -19,27 +19,27 @@ def listener(cls, event): ch = ((event.addr & 0x0f00) >> 8) + 1 mon = self.model.monitors[(event.addr & 0xf000) >> 12] mute = value.unpacked.discrete - mutes[ch][mon] = mute + self.model.mutes[ch][mon] = mute #self.model.queue.put([ord(mon) - ord('a'), ch, 0 if mute == 0 else 127]) if mon == 'd': # TODO may not be needed self.model.queue.put([int((ch-1)/2), 82, 0 if mute == 0 else 127]) elif '.stereo' in addr: ch = ((event.addr & 0x0f00) >> 8) + 1 - stereo[ch] = value.unpacked.discrete + self.model.stereo[ch] = value.unpacked.discrete elif '.pan' in addr: ch = ((event.addr & 0x0f00) >> 8) + 1 - pans[ch] = value #capmix.format_type(Type.Pan, value.unpacked) #.unpacked.discrete >> 24 + self.model.pans[ch] = value #capmix.format_type(Type.Pan, value.unpacked) #.unpacked.discrete >> 24 #log("addr=%x=%s type=%s v=%s" % (event.addr, addr, event.type_name(), value)) def connect(self): - self.ok = capmix.connect(Capture.listener) + self.ok = capmix.connect(self.listener) if not self.ok: log("Unable to connect to STUDIO-CAPTURE") return False self.view.dim(False) - time.sleep(1) + sleep(1) self.get_mixer_data() self.ok = True return True diff --git a/bridge/view.py b/bridge/view.py index e4d9f5a..89f8d54 100644 --- a/bridge/view.py +++ b/bridge/view.py @@ -111,9 +111,12 @@ def print_pan(self, ch): #size = os.get_terminal_size() def cursor_to_log(self): - height = 17 if not self.compact else 9 + height = 17 if not self.compact else 10 print("\033[%d;%dr\033[%d;1f\033[?25h" % (height, self.size.lines, self.size.lines-1)) + def cursor_release(self): + print("\n\033[r\033[%d;1f\033[?25h" % (self.size.lines), end='') + def print_monitor_mutes(self): compact = self.compact #print("\033[r",end='')