Skip to content

Instantly share code, notes, and snippets.

@mwicat
Created November 30, 2021 20:33
Show Gist options
  • Save mwicat/b8c138fff8f713363421713236c4c183 to your computer and use it in GitHub Desktop.
Save mwicat/b8c138fff8f713363421713236c4c183 to your computer and use it in GitHub Desktop.
# You can set any of LinnStrument's note pad to any color by sending
# LinnStrument a series of three MIDI Control Change messages:
#
# 1) CC20: Column number of note pad to change (control key column is 0, left
# play column is 1, right play column is 25)
# 2) CC21: Row number of note pad to change (bottom row is 0, top is 7)
# 3) CC22: Color to change it to (0=as set in Note Lights settings,
# 1=red, 2=yellow, 3=green, 4=cyan, 5=blue,
# 6=magenta, 7=off, 8=white, 9=orange, 10=lime and 11=pink).
#
# First send CC20 and CC21 to select the column and row to be lit,
# then send CC22 to light it.
from enum import Enum
from random import randrange
import sys
import mido
from mido import Message
class Color(Enum):
SETTINGS = 0
RED = 1
YELLOW = 2
GREEN = 3
CYAN = 4
BLUE = 5
MAGENTA = 6
OFF = 7
WHITE = 8
ORANGE = 9
LIME = 10
PINK = 11
if len(sys.argv) < 2:
outputs = mido.get_output_names()
print('Usage: SCRIPT output_device')
print('Possible devices:')
for x in outputs:
print(x)
sys.exit(1)
outp_name = sys.argv[1]
outp = mido.open_output(outp_name)
note_color_str = [
'RED', 'OFF', 'ORANGE', 'YELLOW', 'OFF', 'GREEN', 'OFF', 'BLUE', 'CYAN', 'OFF', 'MAGENTA', 'OFF',
]
note_color = [Color[c_str] for c_str in note_color_str]
def show_led(column, row, color):
ccs = [
(20, column+1),
(21, 7-row),
(22, color),
]
for cc_num, cc_val in ccs:
cc = Message('control_change', channel=0, control=cc_num, value=cc_val, time=0)
outp.send(cc)
pos = 5
rowpos = 5
for row in range(8):
pos = rowpos
for column in range(16):
# color = 7
# while color == 7:
# color = randrange(1, 12)
# show_led(column, row, color)
color = note_color[pos].value
print('{}\t{}\t{}'.format(row, column, note_color[pos]))
pos = (pos + 1) % 12
show_led(column, row, color)
rowpos = (rowpos + 7) % 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment