Skip to contentSkip to conversation

Detecting new alsa sequencer clients (with some event loop) so that i can subscribe them

DISCUSSION R. Dresens 2 participants 3 messages Mar 31, 2008 – Apr 1, 2008

lore
Share & tools
lore

R. Dresens

author
#0 lore raw

Hello,

I'm currently writing an application that will be able to 'auto subscribe' itself to a certain sequencer client when that client becomes available to the system. I want (for example) to be able to plug in a USB MIDI interface, and when I do that then my application detects this and does a subscription on it, just like aconnect would do.

A possible solution is polling; every second or so, i could generate a list of clients with snd_seq_query_next_client and look for a certain client name (libpcre comes to mind here;), but I was wondering if there is a better solution? ..in other words, is it possible to get such events from the system in a similar way like one would receive regular MIDI events?

http://www.alsa-project.org/alsa-doc/alsa-lib/structsnd__seq__event.html
list all the events; an interesting one could be snd_seq_connect_t for monitoring connections on my own ports, but that's not what I'm looking for. I can't seem to find an event related to this functionality. Is there something what I'm currently overlooking?

Such functionality may be usefull for GUI versions of aconnect. I looked in the source of qjackctl (it has an alsa patchbay), but I haven't found nothing usefull yet since it seems to me that this software also does polling/refresh on a certain interval.

Has anyone a usefull tip for me?

Thanks in advance,

Greetings,

Raymond Dresens.

#1 lore raw
Quoted 7 lines · R. Dresens

I'm currently writing an application that will be able to 'auto subscribe' itself to a certain sequencer client when that client becomes available to the system. I want (for example) to be able to plug in a USB MIDI interface, and when I do that then my application detects this and does a subscription on it, just like aconnect would do.

Quoted 6 lines

A possible solution is polling; every second or so, i could generate a list of clients with snd_seq_query_next_client and look for a certain client name (libpcre comes to mind here;), but I was wondering if there is a better solution? ..in other words, is it possible to get such events from the system in a similar way like one would receive regular MIDI events?

Subscribe to SND_SEQ_CLIENT_SYSTEM:SND_SEQ_PORT_SYSTEM_ANNOUNCE. Try "aseqdump -p 0:1" to see what events you get.

HTH
Clemens

author
#2 lore raw
Quoted 9 lines · On Tue, 01 Apr 2008 09:01:50 +0200 Clemens Ladisch <[email protected]> wrote:
Quoted 6 lines

A possible solution is polling; every second or so, i could generate a list of clients with snd_seq_query_next_client and look for a certain client name (libpcre comes to mind here;), but I was wondering if there is a better solution? ..in other words, is it possible to get such events from the system in a similar way like one would receive regular MIDI events?

Subscribe to SND_SEQ_CLIENT_SYSTEM:SND_SEQ_PORT_SYSTEM_ANNOUNCE. Try "aseqdump -p 0:1" to see what events you get.

Yes, that did the trick: this is exactly what I'm looking for.

Thanks for your help!

Greetings,

Raymond Dresens.