Skip to content

Instantly share code, notes, and snippets.

@CalvinLogan
Created December 10, 2018 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CalvinLogan/3893445557e35b48b67b3aa6977f23ae to your computer and use it in GitHub Desktop.
Save CalvinLogan/3893445557e35b48b67b3aa6977f23ae to your computer and use it in GitHub Desktop.
def drawShape(eventType, channel, data1, data2):
global window, shape1, shape2, shape3, shape4, shape5, shape6
# iicon position is random
x = randint(0, getScreenWidth()) # x may be anywhere on display
y = randint(0, getScreenHeight()) # y may be anywhere on display
colors = ["Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Pink", "White", "Teal"]
colorIdx = (data1 / 2) % len(colors)
color = colors[colorIdx]
shapeLists = [shape1, shape2, shape3, shape4, shape5, shape6]
shapeListIdx = (data1 / 3) % len(shapeLists)
shapeList = shapeLists[shapeListIdx]
shape = shapeList[color]
icon = Icon(shape,x,y)
window.add(icon)
# play note
Play.noteOn(data1, data2)
# establish a connection to an input MIDI device
midiIn = MidiIn("Unknown Vendor Oxygen 25")
# register a callback function to process incoming MIDI events
midiIn.onNoteOn(drawShape)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment