Midi Module

class squishbox.midi.SquishBoxMidi[source]

Bases: object

ALSA sequencer wrapper for SquishBox

  • Automatically connects devices specified in midi_connections

  • Provides methods for querying ports, sending messages

  • Can wrap other device/synth ports for filtering MIDI messages

close()[source]

Cleanly free SquishBox port and any wrappers

ports(**kwargs)[source]

List all MIDI ports currently available on the system

Parameters:

**kwargs (dict) – Options passed to alsa_midi.SequencerClient().list_ports()

Returns:

A dictionary of ports keyed by port info string

refresh()[source]

Enforce MIDI connection graph

  • Connects ports as described in CONFIG[“midi_connections”]

  • Removes all other connections

  • Funnels connections through wrappers for wrapped ports

send(evt)[source]

Send a MIDI message triggered by a SquishBox button/control

Parameters:

evt (alsa_midi.Event()) – the MIDI event to send

wrap(portname)[source]

Wrap a port with a hidden sequencer client

Parameters:

portname (str) – The port to wrap as given by ports()

Returns:

An object for handling messages to

the wrapped port

Return type:

SquishBoxMidiWrapper

class squishbox.midi.SquishBoxMidiWrapper(port)[source]

Bases: object

A container for a hidden ALSA client with in/out ports

close()[source]
receive(**kwargs)[source]

Receive MIDI messages destined for the wrapped port

Parameters:

**kwargs (dict) – Options passed to alsa_midi.SequencerClient().event_input()

Returns:

alsa_midi.Event() or None if timed out

send(evt)[source]

Send a MIDI message to the wrapped port

Parameters:

evt (alsa_midi.Event()) – the MIDI event to send