Whitespace

This commit is contained in:
Ryan Jarvis
2020-05-01 11:28:50 -07:00
parent 9ebbb439cb
commit 81a37df50e
31 changed files with 1575 additions and 1600 deletions

View File

@@ -18,10 +18,10 @@ class MidiInput(object):
self.try_open_port()
def try_open_port(self):
#self.data.midi_status = 'disconnected'
# self.data.midi_status = 'disconnected'
self.midi_setting = self.data.settings['user_input']['MIDI_INPUT']['value']
self.port_index = self.data.midi_port_index
#print('try open port : midi setting is {}'.format(midi_setting))
# print('try open port : midi setting is {}'.format(midi_setting))
if self.midi_setting == 'usb':
self.actions.stop_serial_port_process()
self.open_this_port_and_start_listening('20')
@@ -29,7 +29,7 @@ class MidiInput(object):
self.actions.create_serial_port_process()
self.open_this_port_and_start_listening('serial')
else:
self.actions.stop_serial_port_process()
self.actions.stop_serial_port_process()
self.data.midi_status = 'disconnected'
self.root.after(1000, self.try_open_port)
@@ -40,7 +40,7 @@ class MidiInput(object):
midi_devices = [s for s in midi_devices if port_phrase in s]
if midi_devices:
if self.data.midi_status == 'disconnected':
subport_index = self.port_index % len(midi_devices)
subport_index = self.port_index % len(midi_devices)
self.midi_device = mido.open_input(midi_devices[subport_index])
self.data.midi_status = 'connected'
self.data.midi_device_name = self.midi_device.name
@@ -48,7 +48,7 @@ class MidiInput(object):
self.midi_mappings = self.data.load_midi_mapping_for_device(self.midi_device.name.split(":")[0])
self.midi_output = self.find_output_plugin(midi_devices[subport_index])
if self.midi_output:
#self.midi_feedback_device = mido.open_output(midi_device_on_port[subport_index])
# 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':
@@ -62,7 +62,7 @@ class MidiInput(object):
current_message_buffer = [i.dict() for i in self.midi_device.iter_pending()]
refined_buffer = []
#refine buffer from lastest messages first
# refine buffer from lastest messages first
current_message_buffer.reverse()
for message in current_message_buffer:
# discard notes from wrong channel
@@ -81,7 +81,7 @@ class MidiInput(object):
for message in refined_buffer:
self.on_midi_message(message)
#print('the number processed {}'.format(i))
# print('the number processed {}'.format(i))
if self.data.settings['user_input']['MIDI_INPUT']['value'] == self.midi_setting and self.data.midi_port_index == self.port_index:
self.root.after(self.midi_delay, self.poll_midi_input)
else:
@@ -94,9 +94,9 @@ class MidiInput(object):
mapped_message_name = message_dict['type']
mapped_message_value = None
if 'note' in message_dict:
mapped_message_name = '{} {}'.format(mapped_message_name,message_dict['note'])
mapped_message_name = '{} {}'.format(mapped_message_name, message_dict['note'])
if 'control' in message_dict:
mapped_message_name = '{} {}'.format(mapped_message_name,message_dict['control'])
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():
@@ -119,23 +119,23 @@ class MidiInput(object):
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]
#print('[][][][][ in mode {}, the action being called is {} from message_name {} in control_mode {}'
# print('[][][][][ in mode {}, the action being called is {} from message_name {} in control_mode {}'
# .format(mode, method_name, message_name, self.data.control_mode))
if mapped_message_value is not None:
norm_message_value = mapped_message_value/127
norm_message_value = mapped_message_value / 127
else:
norm_message_value = None
self.actions.call_method_name(method_name, norm_message_value)
## 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()
# self.refresh_midi_feedback()
# Plugins to support MIDI feedback
@@ -143,31 +143,29 @@ class MidiInput(object):
# 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)
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")
print("Found one! Opening device")
p.set_midi_device(mido.open_output(midi_device))
return p
print ("Didn't find one!")
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)
if self.midi_output.supports_midi_feedback(self.data.midi_device_name):
self.root.after(self.midi_delay * 5, self.refresh_midi_feedback)
def find_binding_for_action(self, action):
for bind,a in self.midi_mappings.items():
#print("looped over %s : %s " % (bind,a))
for (b,c) in a.items():
for bind, a in self.midi_mappings.items():
# print("looped over %s : %s " % (bind,a))
for (b, c) in a.items():
if action in c:
#print ("find_binding_for_action(%s) got %s" % (action, bind))
# print ("find_binding_for_action(%s) got %s" % (action, bind))
return bind