diff --git a/data_centre/plugin_collection.py b/data_centre/plugin_collection.py index c82855f..de454d8 100644 --- a/data_centre/plugin_collection.py +++ b/data_centre/plugin_collection.py @@ -225,6 +225,10 @@ class AutomationSourcePlugin(Plugin): def recall_frame_data(self, data): raise NotImplementedError + def get_frame_summary(self, data): + line = self.__class__.name + "%s: %s"%(self.__class__.name,data) + return line + # these frame stubs deal with the simplest case of a frame being a dict of values # if its anything more complicated than that (like lists) then that will need to be # handled in the plugin by overriding these methods @@ -482,6 +486,13 @@ class PluginCollection(object): else: return [c for c in self.plugins if include_disabled or not c.disabled] + def get_plugin_for_class_name(self, class_name): + for plugin in self.get_plugins(): + #print("got class name %s" % type(plugin).__name__==class_name) + if type(plugin).__name__==class_name == class_name: + return plugin + return None + def walk_package(self, package): """Recursively walk the supplied package to retrieve all plugins """ diff --git a/plugins/LFOModulationPlugin.py b/plugins/LFOModulationPlugin.py index eb0eefc..15ecb0a 100644 --- a/plugins/LFOModulationPlugin.py +++ b/plugins/LFOModulationPlugin.py @@ -14,6 +14,7 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation # for keeping track of LFO levels level = [0.0]*MAX_LFOS #, 0.0, 0.0, 0.0] + speed = 0.5 stop_flag = False pause_flag = False @@ -22,8 +23,9 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation #self.PRESET_FILE_NAME = "ShaderLoopRecordPlugin/frames.json" self.presets = self.load_presets() - self.level = self.presets.get('levels', [0.0]*self.MAX_LFOS) + self.level = self.presets.get('levels', [0.0]*self.MAX_LFOS).copy() self.active = self.presets.get('active', False) + self.set_lfo_speed_direct(self.presets.get('speed'), self.speed) self.pc.shaders.root.after(1000, self.start_plugin) @@ -42,7 +44,7 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation 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, { 'levels': self.level.copy(), 'active': self.active } ) + self.pc.update_json(self.PRESET_FILE_NAME, { 'levels': self.level.copy(), 'active': self.active, 'speed': self.speed } ) # DisplayPlugin methods def get_display_modes(self): @@ -67,7 +69,7 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation # methods/vars for AutomationSourcePlugin # a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin def get_frame_data(self): - diff = { 'levels': self.level, 'speed': self.speed } + diff = { 'levels': self.level, 'speed': self.speed, 'active': self.active } #self.last_record = {} #print(">>> reporting frame data for rec\n\t%s" % diff) return diff @@ -76,15 +78,28 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation if data is None: return # print(">>>>recall from data:\n\t%s\n" %data) - """for queue, item in data.items(): - if item is not None: - self.send_buffered(queue, item[0], item[1], record = False)""" if data.get('levels') is not None: for slot,level in enumerate(data.get('levels')): self.set_lfo_modulation_level(slot, level) + if data.get('active') is not None: + self.active = self.get('active') if data.get('speed') is not None: self.set_lfo_speed_direct(data.get('speed')) + def get_frame_summary(self, data): + line = "" + if data.get('levels') is not None: + line += "LFO levels [" + for i in range(4): + line += self.pc.display.get_bar(data['levels'][i]) + line += "] " + if data.get('active') is not None: + line += "active " if data.get('active') else 'inactive ' + if data.get('speed') is not None: + line += self.pc.display.get_speed_indicator(data.get('speed')) + #print ("returning %s from %s" %(line, data)) + return line + # ActionsPlugin methods @property def parserlist(self): diff --git a/plugins/WJSendPlugin.py b/plugins/WJSendPlugin.py index df9e13d..b4be578 100644 --- a/plugins/WJSendPlugin.py +++ b/plugins/WJSendPlugin.py @@ -39,7 +39,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei 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(): - self.commands[cmd]['modulation'] = levels + self.commands[cmd]['modulation'] = levels.copy() # build a reverse map of friendly name -> command struct for later use for cmd,struct in self.commands.items(): @@ -83,6 +83,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei if item is not None: self.send_buffered(queue, item[0], item[1], record = False) + def get_frame_summary(self, data): + line = "WJMX: " + for key, value in data.items(): + line += key + ", " + print("returning line %s" % line) + return line # methods for ModulationReceiverPlugin - receives changes to the in-built modulation levels (-1 to +1) # experimental & hardcoded ! @@ -220,9 +226,8 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei # sorting the commands that are sent seems to fix jerk and lag that is otherwise pretty horrendous with self.queue_lock: for queue, command in sorted(self.queue.items()): - # TODO: modulate the parameters self.send_buffered(queue, command[0], command[1]) - #self.queue.clear() + #self.queue.clear() except Exception: print ("WJSendPlugin>>> !!! CAUGHT EXCEPTION running queue %s!!!" % queue) import traceback diff --git a/plugins/frame_manager.py b/plugins/frame_manager.py index 7856b82..2a45921 100644 --- a/plugins/frame_manager.py +++ b/plugins/frame_manager.py @@ -83,6 +83,9 @@ class Frame: count = 0 line = "" for key,d in sorted(self.f.items()): + #print ("get_frame_summary: checking %s value %s" % (key,d)) + if type(d) is dict and len(d)==0: # skip empty dicts + continue if key in ["selected_shader","layer_active_status","shader_params","shader_speeds","selected_shader_slots"]: # skip these as dealt with above pass @@ -98,10 +101,12 @@ class Frame: o += self.pc.display.get_bar(d[layer][param][slot]) o+= "] " summary.append("Shader layer %s: %s"%(layer,o)) - elif key in ["WJSendPlugin"]: + elif self.pc.get_plugin_for_class_name(key) is not None: + summary.append(self.pc.get_plugin_for_class_name(key).get_frame_summary(d)) + """elif key in ["WJSendPlugin"]: # tends to be heavy so save it for later # TODO: ask plugin to format the data for summary? - not_shown[key] = d + not_shown[key] = d""" else: line += "%s: %s" % (key, d) count += 1