Re: [Alsa-user] MIDI subscription

2018-01-02 Thread Clemens Ladisch via Alsa-user
Paul D. DeRocco wrote:
> Under "Subscription", it says "subscription is a connection between two
> sequencer ports." The snd_seq_subscribe_port() function takes a
> snd_seq_port_subscribe_t which specifies a sender and a receiver. But the
> explanation always seems to refer to subscribing "to" a port, rather than
> subscribing "between" two ports.

In most cases, the receiver is your own port.  But in the general case,
all subscriptions are between two ports.

> [...] And then it says "There is another subscription type for opposite
> direction". But if subscription is a connection between a source and
> a destination, what are the two types of subscription?

There are not really two types.  But if you want connections in both
directions, you need to make two subscriptions, with opposite "from"/"to"
ports.

> Later, under "Permissions", it speaks of READ and WRITE permissions being
> needed to send events to or receive events from other ports. Then, it
> speaks of SUBS_READ and SUBS_WRITE permissions, which are needed for
> subscription, implying that subscription isn't the same thing as merely
> passing events from one port to another.

All events have a destination port, which can be a specific port, or
"all subscribers".  A program like aplaymidi sends events to a specific
destination and does not allow subscriptions.

> It then says that these SUBS flags aren't necessary "if the client
> subscribes itself to the specified port". Since a client is just an
> object, not a program or a piece of code, how does a client subscribe
> itself to something, or do anything at all?

All accesses to the ALSA sequencer are done through a client object, so
for practical purposes, a client indeed is a program or a piece of code.

The permission bits allow other clients to do something with the port;
a client is always allowed to do everything with its own ports.

So if you want to subscribe from or to your own port, the other port
needs to allow this; if you subscribe between two other ports, both need
to allow this.

(Please note that events are always sent by the source port, so it is not
possible to read events from another client's port without a subscription,
so the READ bit is pointless without SUBS_READ.)


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Alsa-user] MIDI subscription

2017-12-28 Thread Paul D. DeRocco
I'm reading seq.html, and trying to understand how MIDI events are passed
around, but it doesn't make sense to me.

Under "Subscription", it says "subscription is a connection between two
sequencer ports." The snd_seq_subscribe_port() function takes a
snd_seq_port_subscribe_t which specifies a sender and a receiver. But the
explanation always seems to refer to subscribing "to" a port, rather than
subscribing "between" two ports. Indeed, under "Subscription", it says
"this program must subscribe itself to the MIDI port", and then says
events from that port are "automatically sent to this program". And then
it says "There is another subscription type for opposite direction". But
if subscription is a connection between a source and a destination, what
are the two types of subscription? It implies that when port X is
connected to port Y, only one of them is being "subscribed to", and that
the other is somehow doing the "subscribing".

Later, under "Permissions", it speaks of READ and WRITE permissions being
needed to send events to or receive events from other ports. Then, it
speaks of SUBS_READ and SUBS_WRITE permissions, which are needed for
subscription, implying that subscription isn't the same thing as merely
passing events from one port to another. It then says that these SUBS
flags aren't necessary "if the client subscribes itself to the specified
port". Since a client is just an object, not a program or a piece of code,
how does a client subscribe itself to something, or do anything at all?
And in a couple more places, it talks of a "third client" subscribing to
ports, if BOTH ports have the SUBS permission flags.

So we've had mention of a program subscribing to a port, and a client
subscribing itself to a port, and a third client subscribing to two ports.
What do these mean? And why are SUBS permission bits needed in some cases
but not others? In short, what IS "subscription"?

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user