refactor: 3-module pd architecture + viz non-blocking fix

- midi-in.pd: netreceive -> route -> unpack -> pitch/velocity outlets
- audio-out.pd: inlet~ -> dac~ abstraction
- synth.pd: consumer patch wiring midi-in -> voice -> audio-out
- led-matrix-viz.py: router socket non-blocking, registered with poller
- pd.rego: skip outlet/abstraction false positives in validation
This commit is contained in:
2026-06-24 02:08:57 -07:00
parent 242c74236f
commit 3cc497f632
5 changed files with 64 additions and 47 deletions
+11 -10
View File
@@ -26,9 +26,10 @@ def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("0.0.0.0", VIZ_PORT))
sock.setblocking(False)
router = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
router.settimeout(2)
router.setblocking(False)
router.connect(ROUTER_SOCK)
packer = msgpack.Packer()
@@ -38,9 +39,11 @@ def main():
msg_id = 0
frame_interval = 1.0 / FPS
next_frame = time.monotonic()
router_buf = b""
poller = select.poll()
poller.register(sock, select.POLLIN)
poller.register(router, select.POLLIN)
while True:
timeout = max(0, int((next_frame - time.monotonic()) * 1000))
@@ -70,6 +73,12 @@ def main():
except BlockingIOError:
pass
if fd == router.fileno() and flags & select.POLLIN:
try:
router_buf += router.recv(4096)
except BlockingIOError:
pass
if time.monotonic() >= next_frame:
next_frame = time.monotonic() + frame_interval
@@ -92,16 +101,8 @@ def main():
req = packer.pack([0, msg_id, "draw_frame", params])
try:
router.sendall(req)
router.settimeout(0.3)
router.recv(128)
router.settimeout(2)
except socket.timeout:
except BlockingIOError:
pass
except OSError:
router.close()
router = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
router.settimeout(2)
router.connect(ROUTER_SOCK)
last_frame = frame
if __name__ == "__main__":