mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-13 20:00:12 +01:00
plugins summarise their frame data for display (LFOModulation, rudimentary WJMXSend altho cant see it working?), LFOModulation should save+recall active state and speed now too?
This commit is contained in:
@@ -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
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,7 +226,6 @@ 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()
|
||||
except Exception:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user