Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. # So, you want to turn some buttons on...
  2.  
  3. import mido
  4. from mido import Message
  5.  
  6. # We're aiming for some specific values. The hex for turning a light green
  7. # is pretty simple: 90 <button> <state>. The '90' is the MIDI command
  8. # for 'note_on'. The 'note_on' command has two values that come after it:
  9. # the note and it's velocity. Since this is a controller, it uses the note
  10. # to signify which button to adjust, and it uses velocity to tell it how to
  11. # light up. Thanks to David Morrill for getting all this information
  12. # together.
  13. #
  14. # The buttons range from 0 to 98.
  15. # The state is a value from 0 to 6 for the main buttons...
  16. # 0: off 1: green 2: green_blink
  17. # 3: red 4: red_blink
  18. # 5: yellow 6: yellow_blink
  19. # ...and 0 through 2 for the circular ones.
  20. # 0: off 1: on 2: blink
  21. # The shift button is very sad as it has no LED.
  22. # Also, the Scene Launch buttons don't light up.
  23.  
  24. # First, let's open the channel to the APC Mini.
  25. m_out = mido.open_output(u'APC MINI MIDI 1')
  26.  
  27. # Then, let's turn button 3 green (or fourth button on
  28. # the bottom row).
  29. msg = Message('note_on', note=3, velocity=1)
  30. m_out.send(msg)
  31.  
  32. # Turn off all of the lights. Also note that I was too
  33. # lazy to type it out into a proper for loop.
  34. [m_out.send(Message('note_on', note=i, velocity=0) for i in xrange(0,99))]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement