Skip to content

Instantly share code, notes, and snippets.

@llimllib
Last active February 10, 2023 23:45
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save llimllib/13a391bc52aea9af3c8e81a315647240 to your computer and use it in GitHub Desktop.
Save llimllib/13a391bc52aea9af3c8e81a315647240 to your computer and use it in GitHub Desktop.
Setting pad colors on the Novation LaunchKey Mini MK3
# This file demonstrates how to use midi codes to control the color of the
# keypads on a Novation LaunchKey mini; There is no official documentation of
# it as far as I can tell
#
# the LaunchKey MK2 Programmer's guide is useful, though not accurate to
# details on the MK3 mini:
# https://customer.novationmusic.com/sites/customer/files/novation/downloads/10535/launchkey-mk2-programmers-reference-guide.pdf
import random
import time
# pip install mido (https://mido.readthedocs.io)
# has several backends, I tested it with python-rtmidi: `pip install python-rtmidi`
import mido
# when communicating with the novation, "note" is used to represent the pad
# you're changing (or "12" for control codes). Velocity is used for the color
# to set the pad, and channel is the type of color to use. 9 = solid color, 10
# = blink, 11 = pulse
def sendNote(port, channel, note, velocity):
port.send(mido.Message("note_on", channel=channel, note=note, velocity=velocity))
# useful in interactive prompt
def reset(port):
# exit extended mode
sendNote(port, 15, 12, 0)
# enter extended mode
sendNote(port, 15, 12, 127)
# the key codes ("notes") for the bottom and top drum pad rows
toprow = [40, 41, 42, 43, 48, 49, 50, 51]
botrow = [36, 37, 38, 39, 44, 45, 46, 47]
def scanAllColors(port):
# send the "assume control" message; the MK2 documentation calls this
# "entering extended mode"
sendNote(port, 15, 12, 127)
# check out the MK2 programmer's manual linked above for a graphic
# demonstrating what colors are available
for color in range(127):
reset(port)
sendNote(port, 9, toprow[color % 8], color)
sendNote(port, 9, botrow[7 - (color % 8)], 127 - color)
time.sleep(0.05)
def flashingColors(port):
# assume control
sendNote(port, 15, 12, 127)
# channel 10 flashes the pad
for _ in range(127):
pad = random.choice(toprow + botrow)
sendNote(port, 10, pad, random.randint(0, 127))
time.sleep(0.05)
def pulsingColors(port):
# assume control
sendNote(port, 15, 12, 127)
# channel 11 pulses the pad
for _ in range(127):
pad = random.choice(toprow + botrow)
sendNote(port, 11, pad, random.randint(0, 127))
time.sleep(0.05)
if __name__ == "__main__":
# there are two midi ports exposed by the LaunchKey; one for input and one
# for output. This one is for input, and may have a different name on your
# system
port = mido.open_output("Launchkey Mini MK3 DAW Port")
reset(port)
scanAllColors(port)
flashingColors(port)
pulsingColors(port)
reset(port)
@ItzSwirlz
Copy link

Hello, it's not working on my Launchkey Mini MK3 on windows :/.I'm not sure if I should be in the drum or custom mode when I run it or what not but I can't see why. I tried both outports I had. (not sure why i had two)

@NaanProphet
Copy link

NaanProphet commented Feb 8, 2023

@ItzSwirlz this script didn't quite work for me either, but it did point me in the right direction.

Found a working manual for Launchkey Mini MK3 here and it seems to be working for the Mini as well:
https://www.kraftmusic.com/media/ownersmanual/Novation_Launchkey_Programmers_Reference_Manual.pdf

There are some slight differences, for example:

  • assume control mode is sent on channel 16 rather than 15 never mind, this is zero indexed
  • the lower left note is 112 in session mode, 36 in drum mode, and 80 in device select mode

@llimllib
Copy link
Author

llimllib commented Feb 8, 2023

That manual is for the MK3 (not mini) - I found the MK2 manual corresponded more closely with my device, but if it helps you that's awesome.

There is no manual for the MK3 mini as of when I wrote this script - I emailed Novation customer support and they confirmed that to be true.

@llimllib
Copy link
Author

llimllib commented Feb 8, 2023

just tested and this script still works with my device. I did have to do pip install python-rtmidi as well, which I'll add to the script comments

@llimllib
Copy link
Author

llimllib commented Feb 8, 2023

Also: "15" in the source code is channel 16 - they start from zero

@NaanProphet
Copy link

That manual is for the MK3 (not mini) - I found the MK2 manual corresponded more closely with my device, but if it helps you that's awesome.

Oh you're right! Thanks. Funny that the MK3 non-MINI manual is working so far for me. I'll edit my post.

Also: "15" in the source code is channel 16 - they start from zero

Oh right, thanks!

@NaanProphet
Copy link

So I noticed something interesting with my Launchkey Mini MK3 using MIDI Monitor. Once extended mode is activated, I can change colors, but I can no longer play any keys...

sendNote(port, 15, 12, 127)

It seems that command is getting spammed over and over to the DAW port, so it's struggling to send anything out of the MIDI port. I'm also unable to exit extended mode. Anyone run into this?

@NaanProphet
Copy link

So I noticed something interesting with my Launchkey Mini MK3 using MIDI Monitor. Once extended mode is activated, I can change colors, but I can no longer play any keys...

sendNote(port, 15, 12, 127)

It seems that command is getting spammed over and over to the DAW port, so it's struggling to send anything out of the MIDI port. I'm also unable to exit extended mode. Anyone run into this?

If it helps anyone, there was a duplicate MIDI device on my Mac. What I did to resolve it was:

  1. Unplug the device
  2. Open Audio MIDI Setup
  3. Click Window > Show MIDI Studio
  4. Delete the duplicate devices
  5. Plug device back in

Now I can enter extended mode as expected, without the message getting spammed over and over again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment