Skip to content

Commit

Permalink
improve initial loading experience, polygon pans
Browse files Browse the repository at this point in the history
  • Loading branch information
dctucker committed Mar 28, 2024
1 parent 88f098a commit 9bc1826
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
6 changes: 3 additions & 3 deletions bridge/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def listener(self, event):
mute = value.unpacked.discrete
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
if mon == 'd': # TODO may not be needed
self.model.queue.put([int((ch-1)/2), 82, 0 if mute == 0 else 127])
elif '.solo' in addr:
ch = addr_channel(event.addr)
Expand Down Expand Up @@ -64,6 +63,7 @@ def listen(self):

def query(self, name):
capmix.get(capmix.parse_addr(name))
self.listen()

def get_mixer_data(self):
for ch in range(0,16,2):
Expand All @@ -72,6 +72,6 @@ def get_mixer_data(self):
for mon in self.model.monitors:
self.query("input_monitor.{}.channel.{}.mute".format(mon, ch+1))
self.query("input_monitor.{}.channel.{}.solo".format(mon, ch+1))
self.query("input_monitor.{}.channel.{}.volume".format(mon, ch+1))
self.query("input_monitor.a.channel.{}.pan".format(ch+1))
self.query("input_monitor.{}.channel.{}.volume".format(mon, ch+1))

11 changes: 7 additions & 4 deletions bridge/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ def do_solo(self, down):
ch = self.mixer_channel()
if down == 0: return

val = self.model.value('input_monitor.a.channel.%d.solo' % (ch))
v = 0 if val.unpacked.discrete == 1 else 1
if self.armed:
self.model.mix('input_monitor.%s.channel.%d.solo' % (self.last_monitor, ch), v)
mon = self.last_monitor
else:
self.model.mix('input_monitor.%s.channel.%d.solo' % ('d', ch), v)
mon = 'd'

val = self.model.value('input_monitor.%s.channel.%d.solo' % (mon, ch))
v = 0 if val.unpacked.discrete == 1 else 1

self.model.mix('input_monitor.%s.channel.%d.solo' % (mon, ch), v)
self.soloed = (v == 1)

def do_fader(self, val):
Expand Down
5 changes: 4 additions & 1 deletion bridge/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def mix(self, param, value):

def flush(self):
for k,v in self.capture_hash.items():
capmix.put(k, v)
if v is None:
capmix.query(k)
else:
capmix.put(k, v)
self.capture_hash = {}

def get_cache(self, k):
Expand Down
28 changes: 25 additions & 3 deletions bridge/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
from model import Model

import sys
import math
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

model = Model(create=False)
labels = [
' Mic ',
'Guitar',
'Deluge',
'Opsix',
'Phatty',
' SM10 ',
'Circuit',
' JUNO ',
]

class GLWidget(QOpenGLWidget):
def __init__(self, parent=None):
Expand Down Expand Up @@ -41,6 +52,11 @@ def repaint(self):
left = ch * col_width
top = row_height

painter.setPen(QPen(QColor(192,192,192)))
rect = QRect(left, top, col_width * 2, 20)
painter.drawText(rect, Qt.AlignHCenter, labels[ch//2])
top += row_height

if model.stereo[ch+1] > 0:
color = self.stereo_on
rect = QRect(left+2*col_spacing, top, col_width * 2 - 2*col_spacing, 20)
Expand All @@ -61,11 +77,17 @@ def repaint(self):

for ch in range(0, 16):
left = ch * col_width
center = left + col_width // 2
center = col_spacing // 2 + left + col_width // 2
top = 3 * row_height
p = int((col_width - col_spacing) * model.pans[ch+1]['a'] / 200.0)
painter.fillRect(QRect(center-1, top, 3, 20), self.pan_brush)
painter.fillRect(QRect(center, top, p, 20), self.pan_brush)
painter.fillRect(QRect(left+col_spacing, top, col_width-col_spacing, 20), self.button_off)
#painter.fillRect(QRect(center-1, top, 3, 20), self.pan_brush)
pan_top = int(top+20-7 - abs(p / math.tan(math.radians(60))))
poly = QPolygon((QPoint(center, top+20), QPoint(center+p, top+20), QPoint(center+p, pan_top)))
painter.setBrush(self.pan_brush)
painter.setPen(QPen(self.pan_brush.color()))
painter.drawPolygon(poly)
#painter.fillRect(QRect(center, top, p, 20), self.pan_brush)

for i, m in enumerate(model.monitors):
top = 5 * row_height + i * row_height
Expand Down
12 changes: 6 additions & 6 deletions bridge/view.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from time import strftime
logged = False
def log(*msg):
import os
from time import strftime

logged = False

def log(*msg):
global logged
now = strftime("%H:%M:%S")
logged = True
Expand Down

0 comments on commit 9bc1826

Please sign in to comment.