Skip to content

Commit

Permalink
commit before flashing rpi3b+
Browse files Browse the repository at this point in the history
  • Loading branch information
dctucker committed Mar 9, 2024
1 parent e39dc26 commit fe06354
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all: $(BINARIES)
tests: $(TESTS)

%.o: %.c %.h
$(CC) $(CFLAGS) -c -o $(OBJDIR)/$@ $< $(CFLAGS) -fPIC
$(CC) $(CFLAGS) $(LIBS) -c -o $(OBJDIR)/$@ $< $(CFLAGS) -fPIC

test/%.o: test/%.c test/%.h
$(CC) -c -o $(OBJDIR)/$@ $< $(CFLAGS)
Expand Down
5 changes: 5 additions & 0 deletions bindings/capmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ def __init__(self, ty, unp):
def __str__(self):
return str(capmix.format_type(self.type, self.unpacked))

@classmethod
def parse(cls, ty, str):
ret = Value(ty, capmix.parse_type(ty, str.encode()))
return ret

34 changes: 20 additions & 14 deletions bridge/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,28 @@
"""

logged = False

def print_monitor_mutes():
global logged
size = os.get_terminal_size()
print("\033[r",end='')

#print("\0337",end='')
print("\033[H\033[2K ", end='')
for ch in range(0, 16):
s = '/' if stereo[ch+1] else ' '
print("%2d %s" % (ch+1, s), end='')
print("%2d %s " % (ch+1, s), end='')
print()
print("\033[2K", end='')
for ch in range(0, 16, 2):
st = "LINK" if stereo[ch+1] else ""
print("\033[36m %6s\033[0m" % st, end='')
print("\033[36m %7s\033[0m" % st, end='')
print()
print(' ',end='')
print("\033[2K ", end='')
for ch in range(0, 16):
pan = pans[ch+1]
print("\033[33m%4s" % str(pan), end='')
print("\033[33m%5s" % str(pan), end='')
print()

for mon in monitors:
Expand All @@ -77,26 +79,28 @@ def print_monitor_mutes():
for ch in range(0, 16):
value = mutes[ch+1][mon]
if value == 0:
msg = "---"
msg = "----"
color = "\033[1;33m"
else:
msg = "M "
msg = "MU "
color = "\033[4;7;2;31m"
print("%s%3s\033[0m " % (color,msg), end='')
print()
print("\033[2K")
print("\033[2K ",end='')
for label in labels:
print(" %6s" % label, end='')
print(" %7s " % label, end='')
print()
print("\033[2K")
#print("\0338", end='')

print("\033[10;%dr\033[%d;1f" % (size.lines, size.lines-1))
logged = False

def log(*msg):
global logged
logged = True
print(*msg)
print_monitor_mutes()

nrpn_msb = 0
nrpn_lsb = 0
Expand All @@ -109,7 +113,6 @@ def control_listener(event):
elif isinstance(event, SysExEvent):
control_ok = True
log(repr(event))
print_monitor_mutes()
return
if event.channel != 15:
return
Expand All @@ -121,7 +124,6 @@ def control_listener(event):
handle_nrpn(nrpn_msb, nrpn_lsb, event.value)

log(repr(event))
print_monitor_mutes()

def capmix_send(param, value):
capmix.put(capmix.parse_addr(param), value)
Expand Down Expand Up @@ -167,14 +169,17 @@ def __init__(self, ch):
self.knob = 0

def listener(self, event):
global logged
logged = True
k = super().listener(event)
if k == 'arm':
self.do_arm(event.value)
log(repr(self))
elif k == 'fader':
self.do_fader(event.value)
elif k == 'knob':
self.do_knob(event.value)
log(repr(self))
#log(repr(self))

def mixer_channel(self):
return 1 + (self.channel * 2)
Expand Down Expand Up @@ -296,7 +301,6 @@ def listener(self, event):
elif isinstance(event, SysExEvent):
control_ok = True
log(repr(event))
print_monitor_mutes()
return
if event.channel == 15:
self.transport.listener(event)
Expand All @@ -313,7 +317,6 @@ def send_nrpn(self, ch, msb, lsb, val):
self.client.event_output(event3, port=self.port)

log(repr(event1), repr(event2), repr(event3))
print_monitor_mutes()
self.client.drain_output()

def sync(self):
Expand Down Expand Up @@ -344,7 +347,6 @@ def listener(cls, event):
pans[ch] = value #capmix.format_type(TPan, value.unpacked) #.unpacked.discrete >> 24

log("addr=%x=%s type=%s v=%s" % (event.addr, addr, event.type_name(), value))
print_monitor_mutes()

def connect(self):
capmix_ok = capmix.connect(Capture.listener)
Expand All @@ -364,6 +366,8 @@ def get_mixer_data(self):
capmix.get(capmix.parse_addr("input_monitor.a.channel.{}.pan".format(ch+1)))

def main():
global logged

capture = Capture()
control = Control()

Expand Down Expand Up @@ -418,6 +422,8 @@ def check_connections(client, port):
if now - last_ok > 5:
control_ok, capmix_ok = check_connections(client, port)
last_ok = now
if logged:
print_monitor_mutes()

except KeyboardInterrupt:
pass
Expand Down
4 changes: 2 additions & 2 deletions lib/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "comm.h"

#ifndef DOXYGEN_SKIP
#define TRY_SEQ(X, MSG) if( (err = X) < 0 ){ warn( MSG ": %s\n", snd_strerror(err) ); return 0; }
#define TRY_SEQ(X, MSG) if( (err = X) < 0 ){ warn( MSG ": %s\n", snd_strerror(err) ); snd_seq_close(seq); return 0; }
#define MIDI_BYTES_PER_SEC (31250 / (1 + 8 + 2))
#endif

Expand Down Expand Up @@ -73,7 +73,7 @@ int capmix_setup_midi( capmix_listener_t *listener )
n_descriptors = snd_seq_poll_descriptors_count(seq, POLLIN);
descriptors = malloc(sizeof(*descriptors) * n_descriptors);

capmix_listener = listener;
capmix_listener = listener;
warn("Opened %s (%d,%d)\n", port_name, port_in, port_out);
return 1;
}
Expand Down
2 changes: 2 additions & 0 deletions test/test_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from bindings.capmix import capmix, EVENT

def main():
capmix.set_model(4)

def listener(event):
#value = capmix.format_type(event.type(), event.unpacked)
value = event.value()
Expand Down

0 comments on commit fe06354

Please sign in to comment.