missed necessary file for midi input detection! also fix midi feedback not working if the shader plugins are not installed

This commit is contained in:
Tristan Rowley
2020-01-14 23:56:07 +00:00
parent e2de50c38a
commit 6996bef707
2 changed files with 46 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ class MidiInput(object):
self.data = data
self.midi_mappings = data.midi_mappings
self.midi_device = None
self.midi_feedback_device = None
self.midi_setting = None
self.port_index = 0
self.midi_delay = 40
@@ -41,7 +42,13 @@ class MidiInput(object):
subport_index = self.port_index % len(midi_device_on_port)
self.midi_device = mido.open_input(midi_device_on_port[subport_index])
self.data.midi_status = 'connected'
self.data.midi_device_name = self.midi_device.name
self.message_handler.set_message('INFO', 'connected to midi device {}'.format(self.midi_device.name))
self.midi_mappings = self.data.load_midi_mapping_for_device(self.midi_device.name.split(":")[0])
self.midi_output = self.find_output_plugin(midi_device_on_port[subport_index])
if self.midi_output:
#self.midi_feedback_device = mido.open_output(midi_device_on_port[subport_index])
self.root.after(self.midi_delay, self.refresh_midi_feedback)
self.poll_midi_input()
elif self.data.midi_status == 'connected':
self.data.midi_status = 'disconnected'
@@ -98,7 +105,7 @@ class MidiInput(object):
if 'control' in message_dict:
mapped_message_name = '{} {}'.format(mapped_message_name,message_dict['control'])
mapped_message_value = message_dict['value']
if mapped_message_name in self.midi_mappings.keys():
self.run_action_for_mapped_message(mapped_message_name, mapped_message_value)
else:
@@ -106,14 +113,19 @@ class MidiInput(object):
def run_action_for_mapped_message(self, message_name, mapped_message_value):
this_mapping = self.midi_mappings[message_name]
#if self.data.function_on and "FN_%s"%self.data.control_mode in this_mapping:
# mode = "FN_%s"%self.data.control_mode
#el
if self.data.control_mode in this_mapping:
mode = self.data.control_mode
#elif self.data.function_on and "FN_DEFAULT" in this_mapping:
# mode = "FN_DEFAULT"
elif 'DEFAULT' in this_mapping:
mode = 'DEFAULT'
if self.data.function_on and len(this_mapping[mode]) > 1:
method_name = this_mapping[mode][1]
self.data.function_on = False
#self.data.function_on = False
else:
method_name = this_mapping[mode][0]
@@ -127,4 +139,30 @@ class MidiInput(object):
## only update screen if not continuous - seeing if cc can respond faster if not refreshing screen on every action
if 'continuous' not in message_name:
self.display.refresh_display()
#self.refresh_midi_feedback()
# Plugins to support MIDI feedback
def find_output_plugin(self, midi_device):
# loop over the plugins
# find one that self.supports_midi_feedback(self.midi_device.name):
# open the midi device self.midi_feedback_device = mido.open_output(midi_device_on_port[subport_index])
print ("Looking for a MIDI Feedback plugin that supports %s..." % midi_device)
from data_centre.plugin_collection import MidiFeedbackPlugin
for p in self.data.plugins.get_plugins(MidiFeedbackPlugin):
if p.supports_midi_feedback(midi_device):
print ("Found one! Opening device")
p.set_midi_device(mido.open_output(midi_device))
return p
print ("Didn't find one!")
def refresh_midi_feedback(self):
self.midi_output.refresh_midi_feedback()
if self.midi_output and self.data.settings['user_input']['MIDI_INPUT']['value'] == self.midi_setting and self.data.midi_port_index == self.port_index:
if self.midi_output.supports_midi_feedback(self.data.midi_device_name):
self.root.after(self.midi_delay*5, self.refresh_midi_feedback)