Skip to main content

launchkey-lights

Control the pad LEDs on a Novation Launchkey Mini MK4 programmatically.

This is unreviewed AI-generated code.

Motivation

I want to make a small drum machine using a launchkey mk4. This involves controlling lighting; I decided to separate this into a separate program for modularity and to make debugging different.

I may generalise this daemon to other devices, or use the same protocol for other daemons specialised for interfaces.

Alternatives and prior work

There do not seem to be that many midi devices which have programmable control over their pad's light settings. Some Akai devices support this. Novation Launchpad devices support this. The cheapest device is likely an old launchpad mini. I bought a launchkey device because I wanted a device immediately and already owned launchpad devices which were in another location. The launchkey trades off fewer pads for the presence of encoders and keys and pressure sensitivity of pads.

You could directly use the MIDI messages to control the lights yourself but this might impair readability in your code. The values here are taken from Novation's Launchkey MK3 Programmer's Reference, and confirmed working on MK4 hardware: the DAW mode handshake, the pad note numbers and the colour palette all carried over unchanged.

How it works

Two things are needed before a pad will light:

  1. LED commands go to the device's second port, the "DAW" port, not the port the keys and pads send on.
  2. The device must be put into DAW mode first, with a handshake. Without it the DAW port ignores LED commands.

Once in DAW mode, a pad is lit by sending a note-on to its note number, with the velocity selecting a color from a palette. The channel selects the lighting style rather than any sound: static, flashing or pulsing.

Usage

launchkey-lights ports              # list MIDI ports
launchkey-lights on 0               # light the first pad
launchkey-lights on 0 --color 21
launchkey-lights on 0 --style pulsing
launchkey-lights off 0

If nothing lights up, the note numbers are probably wrong. Find them:

launchkey-lights probe --start 96 --end 111

which lights each note in turn and prints it, so you can watch the device and see which range corresponds to the pads.

OSC support

OSC is a message protocol from the computer music world. It is not an extension of MIDI and shares no wire format with it, but it does support string arguments, variable length argument lists, and hierarchical addresses with pattern matching.

launchkey-lights can run as a daemon which receives OSC messages to update lighting. I wrote this so that I could control lighting from a separate drum machine program.

launchkey-lights daemon                     # TCP on 127.0.0.1:9000
launchkey-lights daemon --transport udp     # what more music tools speak

/launchkey/pad/<n>/color   s|i        name or palette index
/launchkey/pad/<n>/style   s          static | flashing | pulsing
/launchkey/grid            16 x s|i   whole grid, row major
/launchkey/rect            x y w h, then w*h colours
/launchkey/all/color       s|i

Pads are registered individually, so client side patterns match: /launchkey/pad/*/color.

Grids

The pads are a 2x8 grid numbered 0-15 in reading order. /launchkey/grid takes sixteen colours; /launchkey/rect takes x, y, width, height and then width*height colours, to update part of the grid without disturbing the rest. Colours can be separate arguments or one whitespace separated string:

/launchkey/grid "red orange yellow lime green cyan blue violet off off off off off off off off"

Installation

pipx install launchkey-lights

Metadata

Release files for launchkey-lights 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for launchkey-lights 0.1.0
File Size Uploaded
launchkey_lights-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for launchkey-lights 0.1.0
File Interpreter ABI Platform
launchkey_lights-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / launchkey_lights-0.1.0.tar.gz

Download URL launchkey_lights-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2e47beaa4ac22185161dc8d0af8ec8fadef86b21357b06d323488ed7742eeafb
BLAKE2b-256 checksum
How to use checksums
3e862d9a90fb8558711f7b4a2a4211f2f1cabfaa44ff74065efae58ce68fd952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / launchkey_lights-0.1.0-py3-none-any.whl

Download URL launchkey_lights-0.1.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8eba45c1e1a196efbcd26f3cd71aaec5aec3255f74c89f12d157d483c47ba26
BLAKE2b-256 checksum
How to use checksums
9812a2bfef2fa038ae3590ea79ef2e32edd0f2efba328513af76e90770202d82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page