10
10
# This list is the "source of truth" for your MIDI setup.
11
11
# Use the format "Client Name:Port Name" or "Client Number:Port Number".
12
12
DESIRED_CONNECTIONS = [
13
- ("Midi Through :Midi Through Port-0 " , "Pure Data:Pure Data Midi-In 1" ),
13
+ ("a2j :Midi Through" , "Midi Fighter Twister:Midi Fighter Twister MIDI 1" ),
14
14
# Example: ("20:0", "128:0"),
15
15
]
16
16
@@ -63,7 +63,17 @@ class snd_seq_event(ctypes.Structure):
63
63
SND_SEQ_PORT_TYPE_APPLICATION = 1
64
64
65
65
# Event types that trigger a reconciliation
66
- RELEVANT_EVENTS = {60 , 61 , 62 , 63 , 64 , 65 , 66 , 67 }
66
+ # Include client/port creation, deletion, and change events
67
+ RELEVANT_EVENTS = {
68
+ 60 , # SND_SEQ_EVENT_CLIENT_START
69
+ 61 , # SND_SEQ_EVENT_CLIENT_EXIT
70
+ 62 , # SND_SEQ_EVENT_CLIENT_CHANGE
71
+ 63 , # SND_SEQ_EVENT_PORT_START
72
+ 64 , # SND_SEQ_EVENT_PORT_EXIT
73
+ 65 , # SND_SEQ_EVENT_PORT_CHANGE
74
+ 66 , # SND_SEQ_EVENT_PORT_SUBSCRIBED
75
+ 67 , # SND_SEQ_EVENT_PORT_UNSUBSCRIBED
76
+ }
67
77
68
78
# --- ALSA Function Prototypes ---
69
79
# Suppress the default ALSA error handler
@@ -402,6 +412,7 @@ class pollfd(ctypes.Structure):
402
412
while alsalib .snd_seq_event_input (seq , ctypes .byref (event_ptr )) >= 0 :
403
413
event = event_ptr .contents
404
414
if event and event .type in RELEVANT_EVENTS :
415
+ print (f" [EVENT] Received ALSA event type { event .type } " )
405
416
reconciliation_needed = True
406
417
407
418
if reconciliation_needed :
@@ -415,11 +426,4 @@ class pollfd(ctypes.Structure):
415
426
416
427
417
428
if __name__ == "__main__" :
418
- # # Define a no-op handler to suppress ALSA's default error messages
419
- # @SND_ERROR_HANDLER_T
420
- # def py_error_handler(filename, line, function, err, fmt):
421
- # pass
422
-
423
- # alsalib.snd_lib_error_set_handler(py_error_handler)
424
-
425
429
main ()
0 commit comments