diff --git a/ACTIONS.md b/ACTIONS.md index 3e58276..1654f40 100644 --- a/ACTIONS.md +++ b/ACTIONS.md @@ -1,8 +1,8 @@ # Auto-generated Actions list -Fri 21 Feb 00:56:39 UTC 2020 +Sat 29 Feb 13:17:13 UTC 2020 -for branch=feature_plugins_shader_gadgets +for branch=feature_plugins # Methods * change_composite_setting(setting_value) @@ -30,6 +30,7 @@ for branch=feature_plugins_shader_gadgets * decrease_speed * decrease_this_param * disable_feedback + * eject_all_usb_drives * enable_feedback * enter_on_browser_selection * enter_on_settings_selection @@ -58,12 +59,17 @@ for branch=feature_plugins_shader_gadgets * load_this_detour_shader * _load_this_slot_into_next_player(slot) * map_on_shaders_selection - * modulate_param_layer_offset_to_amount(param, layer, amount) * move_browser_selection_down + * move_browser_selection_page_down + * move_browser_selection_page_up * move_browser_selection_up * move_settings_selection_down + * move_settings_selection_page_down + * move_settings_selection_page_up * move_settings_selection_up * move_shaders_selection_down + * move_shaders_selection_page_down + * move_shaders_selection_page_up * move_shaders_selection_up * next_bank * next_shader_layer @@ -125,6 +131,7 @@ for branch=feature_plugins_shader_gadgets * set_the_shader_param_3_layer_offset_2_continuous(amount) * set_the_shader_param_3_layer_offset_3_continuous(amount) * shutdown_pi + * stop_remote_process * switch_conjur_player_type(value) * switch_dev_mode(state) * switch_display_to_hdmi @@ -136,6 +143,8 @@ for branch=feature_plugins_shader_gadgets * switch_to_next_player * switch_to_this_detour(number) * switch_video_backend(state) + * toggle_access_point_delay(setting_value, osc_setting_state ) + * toggle_access_point(setting_value) * toggle_action_on_player * toggle_capture_preview * toggle_capture_recording @@ -175,6 +184,7 @@ for branch=feature_plugins_shader_gadgets ### Plugin routes * set_lfo_modulation_([0-3])_level (from LFOModulation) * toggle_lfo_active (from LFOModulation) + * set_lfo_speed (from LFOModulation) * (.*)&&(.*) (from ManipulatePlugin) * invert|(.*) (from ManipulatePlugin) * f:(.*):|(.*) (from ManipulatePlugin) @@ -211,14 +221,20 @@ for branch=feature_plugins_shader_gadgets * toggle_loop_automation (from TestPlugin) * print_arguments (from TestPlugin) * set_the_shader_param_([0-3])_layer_offset_([0-2])_continuous_inverted_example (from TestPlugin) - * wj_send_serial_([0-9a-zA-Z:]*) (from WJSendPlugin) - * wj_set_colour_([A|B|T])_([x|y]) (from WJSendPlugin) - * wj_set_back_colour_([x|y|z]) (from WJSendPlugin) - * wj_set_back_wash_colour_([x|y|z]) (from WJSendPlugin) - * wj_set_position_([N|L])_([x|y]) (from WJSendPlugin) + * wj_send_serial:([0-9a-zA-Z:]*) (from WJSendPlugin) + * wj_set_colour:([A|B|T])_([x|y]) (from WJSendPlugin) + * wj_set_back_colour:([x|y|z]) (from WJSendPlugin) + * wj_set_position:([N|L])_([x|y]) (from WJSendPlugin) * wj_set_mix (from WJSendPlugin) - * wj_send_append_pad_([0-9]*)_([[:0-9a-zA-Z]*) (from WJSendPlugin) - * wj_send_append_([:0-9a-zA-Z]*) (from WJSendPlugin) + * wj_set_modulation_([a-zA-Z_]*)[:]?([a-zA-Z_]*)_slot_([0-3])_level (from WJSendPlugin) + * wj_set_current_modulation_slot_([0-3])_level (from WJSendPlugin) + * wj_send_append_pad:([0-9]*)_([[:0-9a-zA-Z]*) (from WJSendPlugin) + * wj_send_append:([:0-9a-zA-Z]*) (from WJSendPlugin) + * wj_set_([a-zA-Z_]*)[:]?([a-zA-Z_]*) (from WJSendPlugin) + * wj_select_next_command (from WJSendPlugin) + * wj_select_previous_command (from WJSendPlugin) + * wj_select_next_argument (from WJSendPlugin) + * wj_select_previous_argument (from WJSendPlugin) ---- diff --git a/actions.py b/actions.py index d3f033a..8b2d439 100644 --- a/actions.py +++ b/actions.py @@ -728,6 +728,8 @@ class Actions(object): def quit_the_program(self): + self.data._update_json(self.data.SETTINGS_JSON, self.data.settings) + self.data.plugins.quit_plugins() self.video_driver.exit_all_players() self.exit_openframeworks() self.exit_osc_server('','') @@ -971,8 +973,8 @@ class Actions(object): def clear_message(self): self.message_handler.clear_all_messages() - def modulate_param_layer_offset_to_amount(self, param, layer, amount): - self.shaders.modulate_param_layer_offset_to_amount(param, amount, layer_offset=layer) + #"""def modulate_param_layer_offset_to_amount(self, param, layer, amount): + # self.shaders.modulate_param_layer_offset_to_amount(param, amount, layer_offset=layer)""" @staticmethod def try_remove_file(path): diff --git a/data_centre/data.py b/data_centre/data.py index ae4f693..0dce385 100644 --- a/data_centre/data.py +++ b/data_centre/data.py @@ -88,17 +88,20 @@ class Data(object): self.shader_bank_data = [self.create_empty_shader_bank() for i in range(3)] if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.SHADER_BANK_DATA_JSON): self.shader_bank_data = self._read_json(self.SHADER_BANK_DATA_JSON) - self.settings = self._read_json(self.DEFAULT_SETTINGS_JSON) + self.settings = self.default_settings = self._read_json(self.DEFAULT_SETTINGS_JSON) if os.path.isfile(self.PATH_TO_DATA_OBJECTS + self.SETTINGS_JSON): self.settings = self._read_json(self.SETTINGS_JSON) - self.settings['user_input']['REMOTE_SERVER']['value'] = 'disabled' # remote server off at boot + self.settings['user_input'].setdefault('REMOTE_SERVER', + self.default_settings['user_input']['REMOTE_SERVER'])['value'] = 'disabled' # remote server off at boot self.key_mappings = self._read_json(self.KEYPAD_MAPPING_JSON) self.osc_mappings = self._read_json(self.OSC_MAPPING_JSON) self.midi_mappings = self._read_json(self.MIDI_MAPPING_JSON) self.analog_mappings = self._read_json(self.ANALOG_MAPPING_JSON) + # TODO: move this to a triggerable command/menu item that will spit out files in a place viewable in browser by the 'remote' system + # TODO eventually: have config configurable via remote browser from utils import docs docs.generate_mappings_doc("MIDI mappings", self.midi_mappings) docs.generate_mappings_doc("OSC mappings", self.osc_mappings, column_one_header="OSC address") @@ -108,7 +111,6 @@ class Data(object): def initialise_plugins(self): #initialise plugin manager self.plugins = plugin_collection.PluginCollection("plugins", self.message_handler, self) - self.plugins.apply_all_plugins_on_value(5) def load_midi_mapping_for_device(self, device_name): # check if custom config file exists on disk for this device name diff --git a/data_centre/plugin_collection.py b/data_centre/plugin_collection.py index 9f8485f..a0e304f 100644 --- a/data_centre/plugin_collection.py +++ b/data_centre/plugin_collection.py @@ -15,6 +15,9 @@ class Plugin(object): self.description = 'UNKNOWN' self.pc = plugin_collection + def quit_plugin(self): + print("quitting " + type(self).__name__) + class MidiFeedbackPlugin(Plugin): """Base class for MIDI feedback plugins """ @@ -476,6 +479,10 @@ class PluginCollection(object): print("Looking for plugins under package %s" % self.plugin_package) self.walk_package(self.plugin_package) + def quit_plugins(self): + # tell each plugin to quit + for plugin in self.get_plugins(): + plugin.quit_plugin() def get_plugins(self, clazz = None): if clazz: @@ -483,16 +490,6 @@ class PluginCollection(object): else: return [c for c in self.plugins if not c.disabled] - def apply_all_plugins_on_value(self, argument): - """Apply all of the plugins on the argument supplied to this function - """ - print() - print('Applying all plugins on value %s:' %argument) - for plugin in self.plugins: - #print(" Applying %s on value %s yields value %s" % (plugin.description, argument, plugin.perform_operation(argument))) - pass - - def walk_package(self, package): """Recursively walk the supplied package to retrieve all plugins """ diff --git a/display_centre/display.py b/display_centre/display.py index ae0d815..6550042 100644 --- a/display_centre/display.py +++ b/display_centre/display.py @@ -256,7 +256,7 @@ class Display(object): self.display_text.insert(END, "%s "%a) self.display_text.insert(END, "\n") bar = u"_\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588" - for layer, modulations in enumerate(self.shaders.selected_modulation_level): + for layer, modulations in enumerate(self.shaders.modulation_level): if (layer==self.data.shader_layer): self.display_text.insert(END, '*') else: diff --git a/dotfiles/generate-list-actions.sh b/dotfiles/generate-list-actions.sh index c572d31..fa236dd 100755 --- a/dotfiles/generate-list-actions.sh +++ b/dotfiles/generate-list-actions.sh @@ -8,7 +8,7 @@ echo echo "# Methods" grep " def " actions.py | grep -v "^#" | sed -e 's/ def //' | sed -e 's/self//' | sed -e 's/(, /(/' | sed -e 's/()//' | sed -e 's/\(.*\)/ *\1/' | sed -e 's/://' | sort -n \ - | grep -v "parserlist\|check_if_should_start_openframeworks\|create_serial_port_process\|__init__\|persist_composite_setting\|receive_detour_info\|_refresh_frame_buffer\|refresh_frame_buffer_and_restart_openframeworks\|run_script\|setup_osc_server\|start_confirm_action\|stop_serial_port_process\|stop_openframeworks_process\|update_capture_settings\|update_config_settings\|update_video_settings\|try_remove_file\|get_callback\|call_method_name\|call_parse_method\|detect_types" + | grep -v "parserlist\|check_if_should_start_openframeworks\|create_serial_port_process\|__init__\|persist_composite_setting\|receive_detour_info\|_refresh_frame_buffer\|refresh_frame_buffer_and_restart_openframeworks\|run_script\|setup_osc_server\|start_confirm_action\|stop_serial_port_process\|stop_openframeworks_process\|update_capture_settings\|update_config_settings\|update_video_settings\|try_remove_file\|get_callback\|call_method_name\|call_parse_method\|detect_types\|show_ip\|toggle_remote_server\|enable_osc\|shutdown_osc_server" echo echo "## Dynamic routes" diff --git a/json_objects/plugins/ShaderLoopRecordPlugin/.placeholder b/json_objects/plugins/ShaderLoopRecordPlugin/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/json_objects/plugins/ShaderQuickPresetPlugin/.placeholder b/json_objects/plugins/ShaderQuickPresetPlugin/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/json_objects/plugins/WJSendPlugin/.placeholder b/json_objects/plugins/WJSendPlugin/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/plugins/ShaderLoopRecordPlugin.py b/plugins/ShaderLoopRecordPlugin.py index 45c6c43..fc3cf29 100644 --- a/plugins/ShaderLoopRecordPlugin.py +++ b/plugins/ShaderLoopRecordPlugin.py @@ -45,6 +45,11 @@ class ShaderLoopRecordPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin): def save_presets(self): self.pc.update_json(self.PRESET_FILE_NAME, self.frames) + def quit_plugin(self): + super().quit_plugin() + self.save_presets() + + # DisplayPlugin methods def get_display_modes(self): return ['LOOPREC','NAV_LPRC'] diff --git a/plugins/ShaderQuickPresetPlugin.py b/plugins/ShaderQuickPresetPlugin.py index 3da91fc..ce31a6e 100644 --- a/plugins/ShaderQuickPresetPlugin.py +++ b/plugins/ShaderQuickPresetPlugin.py @@ -25,6 +25,10 @@ class ShaderQuickPresetPlugin(ActionsPlugin): #,SequencePlugin): def save_presets(self): self.pc.update_json(self.PRESET_FILE_NAME, self.presets) + def quit_plugin(self): + super().quit_plugin() + self.save_presets() + @property def parserlist(self): return [ diff --git a/plugins/WJSendPlugin.py b/plugins/WJSendPlugin.py index b01c0b0..746f7c8 100644 --- a/plugins/WJSendPlugin.py +++ b/plugins/WJSendPlugin.py @@ -8,6 +8,9 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei disabled = False#True DEBUG = False #True ser = None + + PRESET_FILE_NAME = "WJSendPlugin/presets.json" + presets = {} # from http://depot.univ-nc.nc/sources/boxtream-0.9999/boxtream/switchers/panasonic.py """serial.Serial(device, baudrate=9600, bytesize=serial.SEVENBITS, @@ -29,12 +32,34 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei print ("WJSendPlugin is disabled, not opening serial") return + self.presets = self.load_presets() + print("read presets:\n%s\n" % self.presets) + # load the stored modulation levels into the current config + for cmd,levels in self.presets['modulation_levels'].items(): #.setdefault(cmd,[{},{},{},{}]): + print("setting commands[%s]['modulation'] to %s" % (cmd, levels)) + self.commands[cmd]['modulation'] = levels + + # build a reverse map for later use for cmd,struct in self.commands.items(): self.command_by_queue[struct['queue']] = struct self.pc.actions.tk.after(500, self.refresh) - self.selected_command_name = list(self.commands.keys())[0] + self.selected_command_name = list(sorted(self.commands.keys()))[0] + + def load_presets(self): + print("trying load presets? %s " % self.PRESET_FILE_NAME) + return self.pc.read_json(self.PRESET_FILE_NAME) or { 'modulation_levels': {} } + + def save_presets(self): + for cmd,struct in self.commands.items(): + self.presets.setdefault('modulation_levels',{})[cmd] = struct.get('modulation',[]) + self.pc.update_json(self.PRESET_FILE_NAME, self.presets) + + def quit_plugin(self): + super().quit_plugin() + self.save_presets() + # methods/vars for AutomationSourcePlugin # a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin @@ -159,6 +184,9 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei output = b'\2' + string.encode('ascii') + b'\3' #with self.serial_lock: self.ser.write(output) #.encode()) + # TODO: sleeping here seems to help serial response lag problem? + #import time + #time.sleep(0.02) #yield from self.ser.drain() if self.DEBUG: print("send_serial_string: sent string '%s'" % output) #.encode('ascii')) @@ -251,11 +279,9 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei def set_modulation_command_argument_level(self, command_name, argument_name, slot, level): if self.DEBUG: print("set_modulation_command_argument_level(%s, %s, %s, %s)" % (command_name, argument_name, slot, level)) - if not argument_name: argument_name = 'v' + if not argument_name: self.commands[command_name]['arg_names'][0] #argument_name = 'v' - if self.commands[command_name].get('modulation') is None: - self.commands[command_name]['modulation'] = [{},{},{},{}] - self.commands[command_name]['modulation'][slot][argument_name] = level + self.commands[command_name].setdefault('modulation',[{},{},{},{}])[slot][argument_name] = level def set_current_modulation_level(self, slot, level): self.set_modulation_command_argument_level(self.selected_command_name, self.commands[self.selected_command_name]['arg_names'][self.selected_argument_index], slot, level) @@ -331,7 +357,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei 'form': 'VCC:T{:02X}{:02X}', 'arg_names': [ 'x', 'y' ], 'arguments': { 'x': 127, 'y': 127 }, - 'modulation': [ {}, {}, { 'x': 1.0 }, { 'y': 1.0 } ] + #'modulation': [ {}, {}, { 'x': 1.0 }, { 'y': 1.0 } ] #'callback': self.set_colour }, 'mix': { diff --git a/user_input/numpad_input.py b/user_input/numpad_input.py index 0093a02..845697d 100644 --- a/user_input/numpad_input.py +++ b/user_input/numpad_input.py @@ -59,11 +59,11 @@ class NumpadInput(object): else: is_function = 0 - print('the action being called is {}'.format(this_mapping[mode][is_function])) + print('the numpad action being called is {} (mode is {})'.format(this_mapping[mode][is_function], mode)) if value != -1: - getattr(self.actions, this_mapping[mode][is_function])(value) + self.actions.call_method_name(this_mapping[mode][is_function],value) else: - getattr(self.actions, this_mapping[mode][is_function])() + self.actions.call_method_name(this_mapping[mode][is_function]) if is_function and self.data.settings['sampler']['FUNC_GATED']['value'] == 'off': self.data.function_on = False diff --git a/user_input/osc_input.py b/user_input/osc_input.py index 2394353..ae6db13 100644 --- a/user_input/osc_input.py +++ b/user_input/osc_input.py @@ -23,6 +23,8 @@ class OscInput(object): self.poll_settings_for_osc_info() def poll_settings_for_osc_info(self): + self.data.settings['user_input'].setdefault('OSC_INPUT', + self.data.default_settings['user_input'].get('OSC_INPUT')) 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() @@ -50,8 +52,11 @@ class OscInput(object): 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("/*", print) + # this is for accepting any old osc message to allow binding of modulation to osc messages + # TODO: make configurable? + this_dispatcher.map("/*", self.on_param_osc_input) + 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) diff --git a/video_centre/shaders.py b/video_centre/shaders.py index 348a992..c5f5da0 100644 --- a/video_centre/shaders.py +++ b/video_centre/shaders.py @@ -24,11 +24,16 @@ class Shaders(object): self.selected_speed_list = [1.0, 1.0, 1.0] self.selected_modulation_slot = 0 - self.selected_modulation_level = [[[0.0,0.0,0.0,0.0] for i in range(4)] for i in range(3)] + #self.modulation_level = [[[0.0,0.0,0.0,0.0] for i in range(4)] for i in range(3)] self.modulation_value = [0.0,0.0,0.0,0.0] #self.load_selected_shader() + @property + def modulation_level(self): + return self.data.settings['shader'].setdefault('modulation_level', + [[[0.0,0.0,0.0,0.0] for i in range(4)] for i in range(3)]) + def generate_shaders_list(self): shaders_menu_list = [] raw_list = self.shaders_menu.generate_raw_shaders_list() @@ -170,7 +175,7 @@ class Shaders(object): self.selected_modulation_slot = slot def reset_modulation(self, slot): - for layer in self.selected_modulation_level: + for layer in self.modulation_level: for layer,levels in enumerate(layer): levels[slot] = 0.0 @@ -234,7 +239,7 @@ class Shaders(object): plugin.set_modulation_value(param, self.modulation_value[param]) for layer,params in enumerate(self.selected_param_list): for ip,p in enumerate(params): - for p2,v in enumerate(self.selected_modulation_level[layer][ip]): + for p2,v in enumerate(self.modulation_level[layer][ip]): if v!=0: self.update_param_layer(ip,layer) break @@ -244,7 +249,7 @@ class Shaders(object): self.set_param_layer_modulation_level(param, layer, level) def set_param_layer_modulation_level(self, param, layer, level): - self.selected_modulation_level[layer][param][self.selected_modulation_slot] = level + self.modulation_level[layer][param][self.selected_modulation_slot] = level self.update_param_layer(param, layer) def update_param_layer(self, param, layer): @@ -254,7 +259,7 @@ class Shaders(object): self.get_modulation_value_list( self.selected_param_list[layer][param], self.modulation_value,#[0], #param], - self.selected_modulation_level[layer][param] + self.modulation_level[layer][param] ) )