-
-
Save Denperidge/8e9403b73ad7034fc3164a8edb6c393f to your computer and use it in GitHub Desktop.
Python scripts that puts a rainbow fade on the novation launchkey 25 MK2 LED-lights. Original script was written by David Madison (https://www.partsnotincluded.com/how-to-control-the-leds-on-a-novation-launchkey-mini-ii/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Launchkey Mini II Sweep Animation | |
# by David Madison © 2018 | |
# www.partsnotincluded.com | |
# | |
# | |
# Modified to work for the Launchkey 25 MK2. | |
# Instead of the original sweep, it now displays | |
# a looping rainbow fade. | |
# Modifications by Klepvink | |
# https://github.com/Klepvink | |
# | |
# | |
# Modified to work for Clone Hero drums | |
# Added iterate_over_colors, available devices popup, | |
# global config variables, finally statement & pre-preq instructions | |
# And of course, set the drums to their respective colour, and the kick zone to a neutral colour | |
# Modifications by Denperidge | |
# https://denperidge.com | |
# | |
""" | |
Python dependencies | |
Either | |
pip install mido python-rtmidi | |
or | |
nix-shell -p python312 python312Packages.mido python312Packages.python-rtmidi | |
""" | |
import mido | |
from time import sleep | |
print("Available Devices") | |
print(mido.get_output_names()) | |
PORT = "Launchkey MK2 25:Launchkey MK2 25 Launchkey InCo 24:1" | |
NEUTRAL = 3 | |
# Colors, numbers for the LED's and further information are | |
# obtained via the MK2 Programmers Reference guide written | |
# by Danny Nugent. See https://resource.novationmusic.com/sites/default/files/novation/downloads/10535/launchkey-mk2-programmers-reference-guide.pdf | |
chunk1 = (40, 41, 36, 37) | |
chunk2 = (42, 43, 38, 39) | |
chunk3 = (48, 49, 44, 45) | |
chunk4 = (50, 51, 46, 47) | |
row1 = (40, 41, 42, 43, 48, 49, 50, 51) | |
row2 = (36, 37, 38, 39, 44, 45, 46, 47) | |
all_rows = row1 + row2 | |
all_leds = chunk1 + chunk2 + chunk3 + chunk4 | |
def write_led(led_id, color_vel): | |
midi_out.send(mido.Message('note_on', channel=15, | |
note=led_id, velocity=color_vel)) | |
def iterate_over_colors(): | |
i = 0 | |
try: | |
while True: | |
print(i) | |
write_led(row2[7], i) | |
sleep(0.5) | |
i = i+1 | |
except KeyboardInterrupt: | |
pass | |
if __name__ == "__main__": | |
try: | |
# Launchkey InControl port | |
midi_out = mido.open_output(PORT) | |
# Switch to "InControl" mode | |
midi_out.send(mido.Message.from_bytes([0x90, 0x0C, 0x7F])) | |
while True: | |
write_led(row2[0], NEUTRAL) | |
write_led(row1[0], NEUTRAL) | |
write_led(row1[1], NEUTRAL) | |
write_led(row2[1], 5) # red | |
write_led(row2[2], 13) # yellow | |
write_led(row1[2], 15) # yellow cymbal | |
write_led(row2[3], NEUTRAL) | |
write_led(row1[3], NEUTRAL) | |
write_led(row2[4], NEUTRAL) | |
write_led(row1[4], NEUTRAL) | |
write_led(row2[5], 42) # blue | |
write_led(row1[5], 37) # blue cymbal | |
write_led(row2[6], 21) # green | |
write_led(row1[6], 20) # green cymbal | |
write_led(row2[7], NEUTRAL) | |
write_led(row1[7], NEUTRAL) | |
sleep(0.5) | |
except KeyboardInterrupt: | |
pass | |
# Uncomment the line below to enable iterate after the first keyboard interrupt | |
#iterate_over_colors() | |
finally: | |
for led in all_leds: | |
write_led(led, 0) # Turn off all LEDs | |
# Disable "InControl" mode | |
midi_out.send(mido.Message.from_bytes([0x90, 0x0C, 0x00])) | |
midi_out.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment