Ports
MultiPort
MultiPort(
uid: str,
input_ports: Input | Sequence[Input],
output_ports: Output | Sequence[Output],
)
Bases: Port
Multiport wrapper class. Combines Input
and Output
ports to a single i/o port.
Parameters:
-
uid
(str
) –Port's unique ID
-
input_ports
(Input | Sequence[Input]
) –input ports to wrap
-
output_ports
(Output | Sequence[Output]
) –output ports to wrap
subscribe
subscribe(
*msg_matches_args: None | Container[Any] | Any,
**msg_matches_kwargs: (str, None | Container[Any] | Any)
) -> Callable
Decorator to subscribe a callable to all the wrapped inputs' messages.
Decorator without arguments subscribes a callable to all the input's messages.
Decorator with arguments subscribes a callable to the input's messages
that match conditions set by arguments.
It works the same way as message's matches
method:
-
If condition is
None
or omitted it matches anything. -
If condition equals the message's attribute value it matches the attribute.
-
If condition is a container (list, tuple) and contains the message's attribute value, it matches the attribute.
Examples
- Calls function for all MIDI port's messages:
- Calls function for OSC messages from specific address:
- Call object instance method for MIDI port's "note on" and "note off" messages:
Returns:
-
Callable
–Subscribed callable.
send
Input
Bases: Subscribable
, Port
Input port base class
subscribe
subscribe(
*msg_matches_args: None | Container[Any] | Any,
**msg_matches_kwargs: (str, None | Container[Any] | Any)
) -> Callable
Decorator to subscribe a callable to the input's messages.
Decorator without arguments subscribes a callable to all the input's messages.
Decorator with arguments subscribes a callable to the input's messages
that match conditions set by arguments.
It works the same way as message's matches
method:
-
If condition is
None
or omitted it matches anything. -
If condition equals the message's attribute value it matches the attribute.
-
If condition is a container (list, tuple) and contains the message's attribute value, it matches the attribute.
Examples
- Calls function for all MIDI port's messages:
- Calls function for OSC messages from specific address:
- Call object instance method for MIDI port's "note on" and "note off" messages:
Returns:
-
Callable
–Subscribed callable.
Output
Bases: Port
Output port base class
Parameters:
-
uid
(Hashable | None
, default:None
) –Port's unique ID
send
Send message using the output port.
Parameters:
-
msg
(Msg
) –Message to send.
Notes
Supposed to be overridden in subclasses.
Should use self._validate_msg_send(msg)
before sending
and log._msg_sent(self, msg)
after.