lpminimk3 package

Module contents

Subpackages

Submodules

lpminimk3.components module

Components that make up the Launchpad Mini MK3.

class lpminimk3.components.Button(launchpad, layout, button_names, *, x=-1, y=-1, name='', button_id=-1)

Bases: object

A button on the Launchpad.

property id

Unique ID of button.

property launchpad

Launchpad reference.

property layout

Button layout.

property led

LED of button.

property midi_value

MIDI value of button.

property name

Name of button.

property parent

Parent of button, either ‘grid’ or ‘panel’.

property x

X position of button.

property y

Y position of button.

class lpminimk3.components.ButtonFace

Bases: object

A button face.

A button face is the marking placed on the top of some Launchpad buttons.

DOWN = 'down'
DRUMS = 'drums'
KEYS = 'keys'
LEFT = 'left'
RIGHT = 'right'
SCENE_LAUNCH_1 = 'scene_launch_1'
SCENE_LAUNCH_2 = 'scene_launch_2'
SCENE_LAUNCH_3 = 'scene_launch_3'
SCENE_LAUNCH_4 = 'scene_launch_4'
SCENE_LAUNCH_5 = 'scene_launch_5'
SCENE_LAUNCH_6 = 'scene_launch_6'
SCENE_LAUNCH_7 = 'scene_launch_7'
SESSION = 'session'
STOP_SOLO_MUTE = 'stop_solo_mute'
UP = 'up'
USER = 'user'
class lpminimk3.components.ButtonGroup(launchpad, layout, button_names, args)

Bases: object

A group of buttons.

clear_event_queue(*, interface='midi')

Clears event queue.

Parameters:

interface (str) – Interface to clear.

Raises:
  • ValueError – If interface is invalid.

  • RuntimeError – If device is closed.

See also

Interface

property launchpad

Launchpad reference.

property names

Names of buttons in group.

poll_for_event(*, interface='midi', timeout=None, type='press_release')

Polls for MIDI events of buttons specified in this group. If timeout is None, this function will wait indefinitely until a ButtonEvent is received. If no event is received, None is returned.

Parameters:
  • interface (str) – Interface to which to send message.

  • timeout (float or None) – Duration in seconds to wait for event to occur.

  • type (str) – Event type. (Possible values: ‘press’, ‘release’, ‘press|release’)

Returns:

ButtonEvent

Return type:

Button event.

See also

Interface, ButtonEvent

class lpminimk3.components.FlipAxis

Bases: object

Flip axis.

X = 'x'
XY = 'xy'
Y = 'y'
class lpminimk3.components.Grid(launchpad)

Bases: Matrix

Grid of Launchpad.

The grid represents the 8x8 grid of translucent, faceless buttons of the Launchpad.

CUSTOM = 'custom'
PROG = 'prog'
buttons(*args, layout='prog')

Returns a ButtonGroup.

Parameters:
  • args (list) – Button names, button IDs or button XY-pairs.

  • layout (Layout, optional) – Layout of buttons.

Returns:

ButtonGroup

Return type:

Button group.

property height

Max Y.

property launchpad

Launchpad reference.

led(x=-1, y=-1, *, name='', layout='prog', mode='static')

Returns an LED.

Parameters:
  • x (int) – X position of LED, or index of LED if y=-1.

  • y (int, optional) – Y position of LED.

  • name (str, optional) – Name of LED.

  • layout (Layout, optional) – Layout of buttons.

  • mode (str, optional) – Lighting mode.

Returns:

Led

Return type:

An LED.

led_range(*, layout='prog', mode='static', rotation=0, flip_axis='', region=None)

Returns an immutable sequence of LEDs.

Parameters:
  • layout (Layout, optional) – Layout of buttons.

  • mode (str, optional) – Lighting mode.

  • rotation (int, optional) – Rotation angle in degrees. (Possible values: 0, 90, 180, 270, -90)

  • region (Region or None, optional) – Region of LEDs on the matrix.

Yields:

Led – Sequence of LEDs.

property max_id

Max ID.

property max_x

Max X.

property max_y

Max Y.

property width

Max X.

class lpminimk3.components.Led(*, launchpad, button_names, layout, x=-1, y=-1, name='', mode='static')

Bases: object

An LED on the Launchpad.

FLASH = 'flash'
OFF = 'off'
PULSE = 'pulse'
STATIC = 'static'
property color

Color. Retrieving the set color is not supported.

property id

Unique, nonzero ID.

property launchpad

Launchpad reference.

property midi_value

MIDI value.

property name

Name.

reset()

Turns LED off.

property x

X position.

property y

Y position.

class lpminimk3.components.Matrix

Bases: ABC

A matrix of pad buttons/LEDs on the surface of the Launchpad.

property height

Height of matrix.

property launchpad

Launchpad reference.

led_range()

LED range.

property max_x

Max X.

property max_y

Max Y.

render(renderable)

Render renderable on matrix.

property width

Width of matrix.

class lpminimk3.components.Panel(launchpad)

Bases: Matrix

Panel of Launchpad.

The panel represents the 9x9 matrix of pad buttons on the surface of the Launchpad.

CUSTOM = 'custom'
PROG = 'prog'
buttons(*args, layout='prog')

Returns a ButtonGroup.

Parameters:
  • args (list) – Button names, button IDs or button XY-pairs.

  • layout (Layout, optional) – Layout of buttons.

Returns:

ButtonGroup

Return type:

Button group.

property height

Max Y.

property launchpad

Launchpad reference.

led(x=-1, y=-1, *, name='', layout='prog', mode='static')

Returns an LED.

Parameters:
  • x (int) – X position of LED, or index of LED if y=-1.

  • y (int, optional) – Y position of LED.

  • name (str, optional) – Name of LED.

  • layout (Layout, optional) – Layout of buttons.

  • mode (str, optional) – Lighting mode.

Returns:

Led

Return type:

An LED.

led_range(*, layout='prog', mode='static', rotation=0, flip_axis='', region=None)

Returns an immutable sequence of LEDs.

Parameters:
  • layout (Layout, optional) – Layout of buttons.

  • mode (str, optional) – Lighting mode.

  • rotation (int, optional) – Rotation angle in degrees. (Possible values: 0, 90, 180, 270, -90)

  • region (Region or None, optional) – Region of LEDs on the matrix.

Yields:

Led – Sequence of LEDs.

property max_id

Max ID.

property max_x

Max X.

property max_y

Max Y.

property width

Max X.

lpminimk3.device module

lpminimk3.match module

Collection of classes for matching MIDI messages with incoming MIDI events.

class lpminimk3.match.ButtonMatch(buttons, type)

Bases: Match

A set of rules for filtering button events.

contains(message)

Returns True if message message is a valid button message, otherwise returns False.

Returns:

True if provided message is a valid button message, otherwise False.

Return type:

Boolean

class lpminimk3.match.Match

Bases: ABC

A set of rules for filtering MIDI events.

contains(message)

lpminimk3.midi_messages module

MIDI messages for the Launchpad Mini MK3.

class lpminimk3.midi_messages.Colorspec(*fragments)

Bases: MidiMessage

Colorspec MIDI message.

append(fragment)

Append fragment to colorspec.

Parameters:

fragment (ColorspecFragment) – Colorspec fragment.

property data

Data.

class lpminimk3.midi_messages.ColorspecFragment(lighting_type, led_index, *lighting_data)

Bases: object

Colorspec fragment.

append(lighting_data)

Append lighting data lighting_data.

Parameters:

lighting_data (list of int) – Lighting data.

property data

Data.

class lpminimk3.midi_messages.Constants

Bases: object

Constants.

DEFAULT_COLOR_ID = 9
class LightingMode

Bases: object

FLASH = 145
OFF = 128
STATIC = 144
class LightingType

Bases: object

FLASH = 1
PULSE = 2
RGB = 3
STATIC = 0
MIDI_MAX_VALUE = 127
MIDI_MIN_VALUE = 0
class MidiWord

Bases: object

CC_HEADER = 176
NOTE_HEADER = 144
class lpminimk3.midi_messages.Lighting(lighting_mode, midi_value, color_id)

Bases: MidiMessage

Lighting MIDI message.

property color_id

Color ID.

property data

Data.

property lighting_mode

Lighting mode.

property midi_value

MIDI value.

class lpminimk3.midi_messages.MidiMessage

Bases: ABC

MIDI message.

property data

Data.

class lpminimk3.midi_messages.SysExMessages

Bases: object

SysEx messages.

DEVICE_INQUIRY = [240, 126, 231, 240, 6, 1, 247]
class Interfaces

Bases: object

SysEx Interface messages.

DAW = [240, 0, 32, 41, 2, 13, 16, 0, 247]
MIDI = [240, 0, 32, 41, 2, 13, 16, 1, 247]
READBACK = [240, 0, 32, 41, 2, 13, 16, 247]
class Layouts

Bases: object

SysEx Layout messages.

CUSTOM_1 = [240, 0, 32, 41, 2, 13, 0, 4, 247]
CUSTOM_2 = [240, 0, 32, 41, 2, 13, 0, 5, 247]
CUSTOM_3 = [240, 0, 32, 41, 2, 13, 0, 6, 247]
DAW_FADERS = [240, 0, 32, 41, 2, 13, 0, 13, 247]
PROG = [240, 0, 32, 41, 2, 13, 0, 127, 247]
READBACK = [240, 0, 32, 41, 2, 13, 0, 247]
SESSION = [240, 0, 32, 41, 2, 13, 0, 0, 247]
class Modes

Bases: object

SysEx Mode messages.

LIVE = [240, 0, 32, 41, 2, 13, 14, 0, 247]
PROG = [240, 0, 32, 41, 2, 13, 14, 1, 247]
READBACK = [240, 0, 32, 41, 2, 13, 14, 247]

lpminimk3.region module

Region of LEDs on a matrix.

class lpminimk3.region.Labeled

Bases: Region

All labeled buttons on a panel.

property button_names

Button names for labeled region.

class lpminimk3.region.Region

Bases: ABC

A collection of LEDs on a matrix.

property button_names

Button names for region.

lpminimk3.utils module

Utility classes for Launchpad Mini MK3.

class lpminimk3.utils.ButtonEvent(midi_event, buttons)

Bases: object

A button event.

A button event is received every time a button on the Launchpad is pushed.

PRESS = 'press'
PRESS_RELEASE = 'press_release'
RELEASE = 'release'
property button

Button.

property deltatime

Deltatime.

property message

Message.

property type

Type.

class lpminimk3.utils.Interface(midi_event)

Bases: object

Interface of the launchpad.

DAW = 'daw'
MIDI = 'midi'
class MidiWord(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

DAW = 0
MIDI = 1
READBACK_POSITION = 7
property midi_event

MIDI event.

class lpminimk3.utils.Layout(midi_event)

Bases: object

A Launchpad layout.

CUSTOM_1 = 'custom_1'
CUSTOM_2 = 'custom_2'
CUSTOM_3 = 'custom_3'
DAW_FADERS = 'daw_faders'
class MidiWord(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

CUSTOM_1 = 4
CUSTOM_2 = 5
CUSTOM_3 = 6
DAW_FADERS = 13
PROG = 127
SESSION = 0
PROG = 'prog'
READBACK_POSITION = 7
SESSION = 'session'
property midi_event

Midi event.

class lpminimk3.utils.MidiClient(client_name, client_number)

Bases: object

A MIDI client.

append_in_port(port)

Appends in port port.

Parameters:

port (MidiPort) – Port to append.

See also

MidiPort

append_out_port(port)

Appends out port port.

Parameters:

port (MidiPort) – Port to append.

See also

MidiPort

property client_name

Client name.

property client_number

Client number.

close()

Closes MIDI ports.

property daw_in_port

DAW in port.

property daw_out_port

DAW out port.

property in_ports

In ports.

is_open()

Checks if ports all ports are open.

Returns:

True if all ports are open, otherwise False.

Return type:

bool

property midi_in_port

MIDI in port.

property midi_out_port

MIDI out port.

open(interface='midi')

Opens a MIDI port for interface interface.

Parameters:

interface (str, optional) – Interface to open.

See also

Interface

property out_ports

Out ports.

property ports

Ports.

class lpminimk3.utils.MidiEvent(message, deltatime=0)

Bases: object

A MIDI event.

A MIDI event is received every time the Launchpad’s MIDI port is read.

property deltatime

Deltatime.

property message

Message.

class lpminimk3.utils.MidiPort(port_name, port_number, port_index, system_port_name, *, direction, midi_in=None, midi_out=None, virtual=False)

Bases: object

A MIDI port.

DEFAULT_CLIENT_NAME = 'lpminimk3'
IN = 'in'
OUT = 'out'
clear_event_queue(*, read_delay=0.001)
close()

Closes MIDI port.

is_open()

Checks to see if port is open.

Returns:

True if port is open, otherwise False.

Return type:

bool

property midi_in_handle

MIDI IN handle.

property midi_out_handle

MIDI OUT handle.

open()

Opens MIDI port.

poll_for_event(*, timeout=5, match=None, read_delay=0.001)

Polls for button event.

Parameters:
  • timeout (int) – Timeout in seconds.

  • match (Match or None) – Button match.

  • read_delay (float) – Delay duration between reads.

Returns:

Received event.

Return type:

ButtonEvent or None

See also

Match

property port_index

Port index.

property port_name

Port name.

property port_number

Port number.

send_message(message)

Sends raw MIDI message to Launchpad.

Parameters:

message (list of str) – Message of raw integers to send to Launchpad.

property system_port_name

System port name.

class lpminimk3.utils.Mode(midi_event)

Bases: object

A Launchpad mode.

LIVE = 'live'
class MidiWord(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

LIVE = 0
PROG = 1
PROG = 'prog'
READBACK_POSITION = 7
property midi_event

MIDI event.

class lpminimk3.utils.SystemMidiPortParser(in_ports, out_ports)

Bases: object

System-specific way of parsing MIDI port names.

property found_clients

Found clients.