-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplay.py
executable file
·34 lines (29 loc) · 913 Bytes
/
play.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
#
# Quick usage example of "grid_instrument" with MIDI output port.
# Works with all Launchpads: Mk1, Mk2, S/Mini, Pro, XL and LaunchKey
#
#
# David Hilowitz 1/15/19
# decided.ly / davehilowitz.com
#
import grid_instrument
import rtmidi
import time
def note_callback(messageType, midiNote, velocity):
if messageType is "note_on":
midiout.send_message([0x90, midiNote, velocity])
elif messageType is "note_off":
midiout.send_message([0x80, midiNote, velocity])
# Create a MIDI output port
midiout = rtmidi.MidiOut()
midiout.open_virtual_port("Grid Instrument (Virtual Port)")
# Set up GridInstrument
instrument = grid_instrument.GridInstrument()
instrument.intro_message = 'grid'
instrument.note_callback = note_callback
instrument.launchpad_pro_velocity_multiplier = 2.5
instrument.min_velocity = 100
instrument.max_velocity = 100
instrument.default_velocity = 100
instrument.start()