Ports

class alsa_midi.Port(client, port_id)[source]

Sequencer port.

Variables
  • client – the client object this port belongs to

  • client_id – client identifier

  • port_id – port identifier

Parameters
close()[source]

Close the port, freeing any resources.

Wraps snd_seq_delete_simple_port().

connect_from(src)[source]

Connect another port to this one.

Parameters

src (Union[Address, Port, PortInfo, Tuple[int, int]]) – source port

Wraps snd_seq_connect_from().

connect_to(dest)[source]

Connect port to another one.

Parameters

dest (Union[Address, Port, PortInfo, Tuple[int, int]]) – destination port

Wraps snd_seq_connect_to().

disconnect_from(src)[source]

Disconnect another port from this one.

Parameters

src (Union[Address, Port, PortInfo, Tuple[int, int]]) – source port

Wraps snd_seq_disconnect_from().

disconnect_to(dest)[source]

Disconnect port from another one.

Parameters

dest (Union[Address, Port, PortInfo, Tuple[int, int]]) – destination port

Wraps snd_seq_disconnect_to().

get_info()[source]

Get information about the port.

Wraps snd_seq_get_port_info().

Return type

PortInfo

list_subscribers(type=None)[source]

Lists subscribers accessing a port.

Wraps snd_seq_query_port_subscribers().

Parameters

type (SubscriptionQueryType) – limit query to the specific type

Return type

List[SubscriptionQuery]

set_info(info)[source]

Update information about the port.

Wraps snd_seq_set_port_info().

Parameters

info (PortInfo) –

class alsa_midi.PortInfo(client_id=0, port_id=None, name='', capability=PortCaps._NONE, type=PortType.ANY, midi_channels=0, midi_voices=0, synth_voices=0, read_use=0, write_use=0, port_specified=None, timestamping=False, timestamp_real=False, timestamp_queue_id=0)[source]

Sequencer port information.

Variables
  • client_id – client identifier

  • port_id – port identifier

  • name – port name

  • capability – port capabilities

  • type – port type

  • midi_channels – number of MIDI channels

  • midi_voices – number of MIDI voices

  • synth_voices – number of synth voices

  • read_use – number of readers

  • write_use – number of writers

  • timestamping – enable time stamping

  • timestamp_real – use real time (not MIDI ticks) for time stamping

  • timestamp_queue_id – queue used for timestamping

  • client_name – client name. Set only when list_ports() was used to obtain this information.

Parameters
  • client_id (int) –

  • port_id (Optional[int]) –

  • name (str) –

  • capability (PortCaps) –

  • type (PortType) –

  • midi_channels (int) –

  • midi_voices (int) –

  • synth_voices (int) –

  • read_use (int) –

  • write_use (int) –

  • port_specified (dataclasses.InitVar[Optional[bool]]) –

  • timestamping (bool) –

  • timestamp_real (bool) –

  • timestamp_queue_id (int) –

Return type

None

Represents snd_seq_port_info_t with extra optional client_name attribute added when created by list_ports().

class alsa_midi.PortCaps(value)[source]

Port capability flags.

DUPLEX = 16
NO_EXPORT = 128
READ = 1
SUBS_READ = 32
SUBS_WRITE = 64
SYNC_READ = 4
SYNC_WRITE = 8
WRITE = 2
alsa_midi.READ_PORT = PortCaps.READ | PortCaps.SUBS_READ

Port capability flags.

alsa_midi.WRITE_PORT = PortCaps.WRITE | PortCaps.SUBS_WRITE

Port capability flags.

alsa_midi.RW_PORT = PortType.MIDI_GENERIC | PortType.SOFTWARE

Port capability flags.

class alsa_midi.PortType(value)[source]

Port type flags.

ANY = 0
APPLICATION = 1048576
DIRECT_SAMPLE = 2048
HARDWARE = 65536
MIDI_GENERIC = 2
MIDI_GM = 4
MIDI_GM2 = 64
MIDI_GS = 8
MIDI_MT32 = 32
MIDI_XG = 16
PORT = 524288
SAMPLE = 4096
SOFTWARE = 131072
SPECIFIC = 1
SYNTH = 1024
SYNTHESIZER = 262144
class alsa_midi.SubscriptionQuery(root=Address(client_id=0, port_id=0), type=SubscriptionQueryType.READ, index=0, num_subs=0, addr=Address(client_id=0, port_id=0), queue_id=0, exclusive=False, time_update=False, time_real=False)[source]

Port subscription (connection) information.

Represents data from snd_seq_query_subscribe_t

Parameters
Variables
  • root – address of the port queried

  • type – either SubscriptionQueryType.READ or SubscriptionQueryType.WRITE

  • index – subscription index inside query result

  • num_subs – number of subscription in query result

  • addr – address of the subscriber

  • queue_id – queue id

  • exclusive – exclusive access

  • time_update – time update enabled

  • time_real – user real time stamps

Return type

None

class alsa_midi.SubscriptionQueryType(value)[source]

An enumeration.

READ = 0
WRITE = 1