I'm using python-rtmidi to read a MIDI device with sliders and knobs.
I get CONTROL_CHANGE events whenever a slider moves or a knob is turned (this works fine).
But how can I poll the MIDI device to find out the initial position of the sliders and knobs when my program starts?
The user hasn't moved anything, so no CONTROL_CHANGE messages are sent.
(I don't have any documentation for the MIDI device; it's a "WORLDE Easycontrol 9"; I'm just trying to use standard MIDI messages.)
Also - while I have your attention - is there a standard command to turn the button LEDs on/off? I've tried sending CONTROL_CHANGE commands to the button's controller number (values 0 and 127), but the LEDs only light when the buttons are manually pushed.
My existing code:
import rtmidi
class Midi:
CONTROL_CHANGE = 0xB0
def __init__(self, port=0):
self.midi_in = rtmidi.MidiIn() # gets BUT DOES NOT OPEN a midi input port
self.midi_out = rtmidi.MidiOut()
try:
self.midi_in.open_port(port)
self.midi_out.open_port(port)
self.running = True
except:
self.running = False # in case there was no such MIDI port
def read(self):
if self.running:
event = self.midi_in.get_message()
if event:
return event[0]
return None
def write(self, message):
if self.running:
self.midi_out.send_message(message)