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):
|
def recall_frame_data(self, data):
|
||||||
raise NotImplementedError
|
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
|
# 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
|
# if its anything more complicated than that (like lists) then that will need to be
|
||||||
# handled in the plugin by overriding these methods
|
# handled in the plugin by overriding these methods
|
||||||
@@ -482,6 +486,13 @@ class PluginCollection(object):
|
|||||||
else:
|
else:
|
||||||
return [c for c in self.plugins if include_disabled or not c.disabled]
|
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):
|
def walk_package(self, package):
|
||||||
"""Recursively walk the supplied package to retrieve all plugins
|
"""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
|
# for keeping track of LFO levels
|
||||||
level = [0.0]*MAX_LFOS #, 0.0, 0.0, 0.0]
|
level = [0.0]*MAX_LFOS #, 0.0, 0.0, 0.0]
|
||||||
|
speed = 0.5
|
||||||
|
|
||||||
stop_flag = False
|
stop_flag = False
|
||||||
pause_flag = False
|
pause_flag = False
|
||||||
@@ -22,8 +23,9 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation
|
|||||||
|
|
||||||
#self.PRESET_FILE_NAME = "ShaderLoopRecordPlugin/frames.json"
|
#self.PRESET_FILE_NAME = "ShaderLoopRecordPlugin/frames.json"
|
||||||
self.presets = self.load_presets()
|
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.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)
|
self.pc.shaders.root.after(1000, self.start_plugin)
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation
|
|||||||
def save_presets(self):
|
def save_presets(self):
|
||||||
#for cmd,struct in self.commands.items():
|
#for cmd,struct in self.commands.items():
|
||||||
# self.presets.setdefault('modulation_levels',{})[cmd] = struct.get('modulation',[{},{},{},{}])
|
# 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
|
# DisplayPlugin methods
|
||||||
def get_display_modes(self):
|
def get_display_modes(self):
|
||||||
@@ -67,7 +69,7 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation
|
|||||||
# methods/vars for AutomationSourcePlugin
|
# methods/vars for AutomationSourcePlugin
|
||||||
# a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin
|
# a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin
|
||||||
def get_frame_data(self):
|
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 = {}
|
#self.last_record = {}
|
||||||
#print(">>> reporting frame data for rec\n\t%s" % diff)
|
#print(">>> reporting frame data for rec\n\t%s" % diff)
|
||||||
return diff
|
return diff
|
||||||
@@ -76,15 +78,28 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin, Automation
|
|||||||
if data is None:
|
if data is None:
|
||||||
return
|
return
|
||||||
# print(">>>>recall from data:\n\t%s\n" %data)
|
# 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:
|
if data.get('levels') is not None:
|
||||||
for slot,level in enumerate(data.get('levels')):
|
for slot,level in enumerate(data.get('levels')):
|
||||||
self.set_lfo_modulation_level(slot, level)
|
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:
|
if data.get('speed') is not None:
|
||||||
self.set_lfo_speed_direct(data.get('speed'))
|
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
|
# ActionsPlugin methods
|
||||||
@property
|
@property
|
||||||
def parserlist(self):
|
def parserlist(self):
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
print("read presets:\n%s\n" % self.presets)
|
print("read presets:\n%s\n" % self.presets)
|
||||||
# load the stored modulation levels into the current config
|
# load the stored modulation levels into the current config
|
||||||
for cmd,levels in self.presets['modulation_levels'].items():
|
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
|
# build a reverse map of friendly name -> command struct for later use
|
||||||
for cmd,struct in self.commands.items():
|
for cmd,struct in self.commands.items():
|
||||||
@@ -83,6 +83,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
if item is not None:
|
if item is not None:
|
||||||
self.send_buffered(queue, item[0], item[1], record = False)
|
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)
|
# methods for ModulationReceiverPlugin - receives changes to the in-built modulation levels (-1 to +1)
|
||||||
# experimental & hardcoded !
|
# 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
|
# sorting the commands that are sent seems to fix jerk and lag that is otherwise pretty horrendous
|
||||||
with self.queue_lock:
|
with self.queue_lock:
|
||||||
for queue, command in sorted(self.queue.items()):
|
for queue, command in sorted(self.queue.items()):
|
||||||
# TODO: modulate the parameters
|
|
||||||
self.send_buffered(queue, command[0], command[1])
|
self.send_buffered(queue, command[0], command[1])
|
||||||
#self.queue.clear()
|
#self.queue.clear()
|
||||||
except Exception:
|
except Exception:
|
||||||
print ("WJSendPlugin>>> !!! CAUGHT EXCEPTION running queue %s!!!" % queue)
|
print ("WJSendPlugin>>> !!! CAUGHT EXCEPTION running queue %s!!!" % queue)
|
||||||
import traceback
|
import traceback
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ class Frame:
|
|||||||
count = 0
|
count = 0
|
||||||
line = ""
|
line = ""
|
||||||
for key,d in sorted(self.f.items()):
|
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"]:
|
if key in ["selected_shader","layer_active_status","shader_params","shader_speeds","selected_shader_slots"]:
|
||||||
# skip these as dealt with above
|
# skip these as dealt with above
|
||||||
pass
|
pass
|
||||||
@@ -98,10 +101,12 @@ class Frame:
|
|||||||
o += self.pc.display.get_bar(d[layer][param][slot])
|
o += self.pc.display.get_bar(d[layer][param][slot])
|
||||||
o+= "] "
|
o+= "] "
|
||||||
summary.append("Shader layer %s: %s"%(layer,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
|
# tends to be heavy so save it for later
|
||||||
# TODO: ask plugin to format the data for summary?
|
# TODO: ask plugin to format the data for summary?
|
||||||
not_shown[key] = d
|
not_shown[key] = d"""
|
||||||
else:
|
else:
|
||||||
line += "%s: %s" % (key, d)
|
line += "%s: %s" % (key, d)
|
||||||
count += 1
|
count += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user