Jajcus / python-alsa-midi

Python interface for ALSA MIDI sequencer
MIT License
13 stars 2 forks source link

Not receiving MIDI port events #4

Closed redraw closed 2 years ago

redraw commented 2 years ago

Hi, I'm trying to intercept PORT_* events, but my code hangs polling.

I'm connecting/disconnecting USB MIDI devices so that they announce/disappear from ALSA seq, not sure if that's expected to happen, but that's what I need to listen.

Testing with example from the docs,

from alsa_midi import SequencerClient

client = SequencerClient("monitor")

while True:
    event = client.event_input()
    print(repr(event))
Jajcus commented 2 years ago

You need to create a client port and connect it to the SYSTEM_ANNOUNCE port to get all port events from the system.

from alsa_midi import SequencerClient, WRITE_PORT, SYSTEM_ANNOUNCE

client = SequencerClient("monitor")
port = client.create_port("in", WRITE_PORT)
port.connect_from(SYSTEM_ANNOUNCE)

while True:
    event = client.event_input()
    print(repr(event))
redraw commented 2 years ago

thanks!