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 (Address | Port | PortInfo | tuple[int, int]) – source port

Wraps snd_seq_connect_from().

connect_to(dest)[source]

Connect port to another one.

Parameters:

dest (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 (Address | Port | PortInfo | tuple[int, int]) – source port

Wraps snd_seq_disconnect_from().

disconnect_to(dest)[source]

Disconnect port from another one.

Parameters:

dest (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: 0>, type=<PortType.ANY: 0>, 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:

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

class alsa_midi.PortCaps(*values)[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(*values)[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=(0, 0), type=SubscriptionQueryType.READ, index=0, num_subs=0, addr=(0, 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

class alsa_midi.SubscriptionQueryType(*values)[source]
READ = 0
WRITE = 1