merge with dev

This commit is contained in:
langolierz
2020-02-29 14:51:50 +00:00
14 changed files with 291 additions and 61 deletions

View File

@@ -37,11 +37,13 @@ class MidiInput(object):
def open_this_port_and_start_listening(self, port_phrase):
midi_ports = mido.get_input_names()
midi_device_on_port = [s for s in midi_ports if port_phrase in s]
if midi_device_on_port:
midi_devices = [s for s in midi_ports if not ('Midi Through' in s)]
if port_phrase == 'serial':
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_device_on_port)
self.midi_device = mido.open_input(midi_device_on_port[subport_index])
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
self.message_handler.set_message('INFO', 'connected to midi device {}'.format(self.midi_device.name))

View File

@@ -16,6 +16,7 @@ class NumpadInput(object):
def bind_actions(self):
self.display.display_text.bind("<KeyPress>", self.on_key_press)
self.display.display_text.bind("<KeyRelease>", self.on_key_release)
self.display.display_text.bind("<Motion>", self.on_mouse_move)
def on_key_press(self, event):
numpad = list(string.ascii_lowercase[0:19])
@@ -34,7 +35,19 @@ class NumpadInput(object):
if event.char in numpad:
self.check_key_release_settings(event.char)
def run_action_for_mapped_key(self, key):
def on_mouse_move(self, event):
if self.data.settings['user_input']['MOUSE_INPUT']['value'] != 'enabled':
return
if event.x > 480 or event.y > 320:
return
width = 480
height = 320 # hard coded since display is fixed , and reading screen is more work
self.root.after(0, self.run_action_for_mapped_key, 'x_m', event.x / width)
self.root.after(0, self.run_action_for_mapped_key, 'y_m', event.y / height)
#self.run_action_for_mapped_key(event.char)
def run_action_for_mapped_key(self, key, value=-1):
this_mapping = self.key_mappings[key]
if self.data.control_mode in this_mapping:
mode = self.data.control_mode
@@ -42,17 +55,21 @@ class NumpadInput(object):
mode = 'DEFAULT'
if self.data.function_on and len(this_mapping[mode]) > 1:
print('the action being called is {}'.format(this_mapping[mode][1]))
#getattr(self.actions, this_mapping[mode][1])()
self.actions.call_method_name(this_mapping[mode][1])
if self.data.settings['sampler']['FUNC_GATED']['value'] == 'off':
self.data.function_on = False
is_function = 1
else:
print('the action being called is {}'.format(this_mapping[mode][0]))
#getattr(self.actions, this_mapping[mode][0])()
self.actions.call_method_name(this_mapping[mode][0])
self.display.refresh_display()
is_function = 0
print('the action being called is {}'.format(this_mapping[mode][is_function]))
if value != -1:
getattr(self.actions, this_mapping[mode][is_function])(value)
else:
getattr(self.actions, this_mapping[mode][is_function])()
if is_function and self.data.settings['sampler']['FUNC_GATED']['value'] == 'off':
self.data.function_on = False
if not value:
self.display.refresh_display()

View File

@@ -17,31 +17,49 @@ class OscInput(object):
self.actions = actions
self.data = data
self.osc_mappings = data.osc_mappings
self.osc_server = self.setup_osc_server()
self.osc_enabled = False
self.osc_server = None
self.poll_settings_for_osc_info()
def poll_settings_for_osc_info(self):
osc_setting_enabled = self.data.settings['user_input']['OSC_INPUT']['value'] == 'enabled'
if osc_setting_enabled and not self.osc_enabled:
self.setup_osc_server()
self.osc_enabled = True
elif not osc_setting_enabled and self.osc_enabled:
self.actions.create_client_and_shutdown_osc_server()
self.osc_enabled = False
self.root.after(1000, self.poll_settings_for_osc_info)
def setup_osc_server(self):
ip_address = self.data.get_ip_for_osc_client()
print('%%%%%%%%%%%%%%%%%%%%% setting up external_osc on ', ip_address)
server_parser = argparse.ArgumentParser()
server_parser.add_argument("--ip", default="0.0.0.0", help="the ip")
server_parser.add_argument("--port", type=int, default=5433, help="the port")
server_parser.add_argument("--ip", default=ip_address, help="the ip")
server_parser.add_argument("--port", type=int, default=8080, help="the port")
server_args = server_parser.parse_args()
this_dispatcher = dispatcher.Dispatcher()
this_dispatcher.map("/keyboard/*", self.on_osc_input)
this_dispatcher.map("/shaderparam0", self.on_param_osc_input)
this_dispatcher.map("/shaderparam1", self.on_param_osc_input)
this_dispatcher.map("/shaderparam2", self.on_param_osc_input)
this_dispatcher.map("/shaderparam3", self.on_param_osc_input)
this_dispatcher.map("/shutdown", self.exit_osc_server)
this_dispatcher.map("/*", self.on_param_osc_input)
#this_dispatcher.map("/*", print)
osc_server.ThreadingOSCUDPServer.allow_reuse_address = True
server = osc_server.ThreadingOSCUDPServer((server_args.ip, server_args.port), this_dispatcher)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()
return server
self.osc_server = server
def exit_osc_server(self, unused_addr, args):
print('%%%%%%%%%%%%%%%%%%%%% exiting external_osc')
self.osc_server.shutdown()
def on_osc_input(self, addr, args):