Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
Last active November 15, 2018 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesTheBard/61290a939b91125f7604 to your computer and use it in GitHub Desktop.
Save JamesTheBard/61290a939b91125f7604 to your computer and use it in GitHub Desktop.
AKAI APC Mini with Mido
# So, you want to turn some buttons on...
import mido
from mido import Message
# We're aiming for some specific values. The hex for turning a light green
# is pretty simple: 90 <button> <state>. The '90' is the MIDI command
# for 'note_on'. The 'note_on' command has two values that come after it:
# the note and it's velocity. Since this is a controller, it uses the note
# to signify which button to adjust, and it uses velocity to tell it how to
# light up. Thanks to David Morrill for getting all this information
# together.
#
# The buttons range from 0 to 98.
# The state is a value from 0 to 6 for the main buttons...
# 0: off 1: green 2: green_blink
# 3: red 4: red_blink
# 5: yellow 6: yellow_blink
# ...and 0 through 2 for the circular ones.
# 0: off 1: on 2: blink
# The shift button is very sad as it has no LED.
# Also, the Scene Launch buttons don't light up.
# First, let's open the channel to the APC Mini.
m_out = mido.open_output(u'APC MINI MIDI 1')
# Then, let's turn button 3 green (or fourth button on
# the bottom row).
msg = Message('note_on', note=3, velocity=1)
m_out.send(msg)
# Turn off all of the lights. Also note that I was too
# lazy to type it out into a proper for loop.
[m_out.send(Message('note_on', note=i, velocity=0) for i in xrange(0,99))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment