diff --git a/actions.py b/actions.py index cda7aef..6b99006 100644 --- a/actions.py +++ b/actions.py @@ -531,7 +531,8 @@ class Actions(object): self.data.settings['shader']['STROBE_AMOUNT']['value'] = scaled_amount def get_midi_status(self): - self.message_handler.set_message('INFO', ("midi status is {} to %s"%(self.data.midi_device_name)).format(self.data.midi_status)) + device_name = 'none' if not hasattr(self.data,'midi_device_name') else self.data.midi_device_name + self.message_handler.set_message('INFO', ("midi status is {} to %s"%(device_name)).format(self.data.midi_status)) def cycle_midi_port_index(self): self.data.midi_port_index = self.data.midi_port_index + 1 diff --git a/plugins/ManipulatePlugin.py b/plugins/ManipulatePlugin.py index 1e66290..4539961 100644 --- a/plugins/ManipulatePlugin.py +++ b/plugins/ManipulatePlugin.py @@ -10,22 +10,34 @@ use |f: : to bookend your formula eg "control_change 48": { - "DEFAULT": ["invert|f:sin(x*pi):|set_the_shader_param_0_layer_offset_0_continuous&&set_variable_A&&print_arguments","set_strobe_amount_continuous"], + "DEFAULT": ["invert|f:sin(x*pi):|set_the_shader_param_0_layer_offset_0_continuous>&print_arguments&&set_variable_A&&print_arguments","set_strobe_amount_continuous"], "NAV_DETOUR": ["set_detour_speed_position_continuous"] }, -example above inverts input, runs sin(x*pi) on it, then uses that value to set the shader param layer 0. it also sets variable A to be the *original* value, and call print_arguments to print it +example above inverts input, runs sin(x*pi) on it, then uses that value to set the shader param layer 0 and prints the value to console. it also sets variable A to be the *original* value, and calls print_arguments to print it + "DEFAULT": ["invert|f:sin(x*pi):|set_the_shader_param_0_layer_offset_0_continuous>&set_variable_B>&print_arguments&&set_variable_A&&print_arguments","set_strobe_amount_continuous"], + +this one is similar the above but there's three branches as separated by the &&:- + invert| + f:sin(x*pi):| + set_the_shader_param_0_layer_offset_0_continuous>& + set_variable_B>& + print_arguments + && + set_variable_A + && + print_arguments "control_change 49": { "DEFAULT": ["set_the_shader_param_1_layer_offset_0_continuous&&A>print_arguments","set_shader_speed_layer_0_amount"], "NAV_DETOUR": ["set_detour_start_continuous"] }, -example above outputs value stored in variable A and prints it +example above outputs value stored in variable A and prints it as well as seting current shader value TODO: >> ?? invert|set_the_shader_param_0_layer_>>print_arguments>>set_variable_A - invert input, send to variable and to shader ? + invert input, send to variable and to shader ? """ @@ -38,12 +50,19 @@ class ManipulatePlugin(ActionsPlugin): @property def parserlist(self): return [ + ( r"(.*)&&(.*)", self.run_multi ), # split && first since they need to be processed separately ( r"^invert\|(.*)$", self.invert ), - ( r"^f:(.*):\|(.*)$", self.formula ), + ( r"^f:(.*):\|(.*)$", self.formula ), # formula eg ```f:sin(x):|``` ( r"^set_variable_([a-zA-Z0-9]+)$", self.set_variable ), - ( r"^([A-Z0-9]+)>(.*)$", self.recall_variable ) + ( r"^([A-Z0-9]+)>(.*)$", self.recall_variable ), # recall variable and pipe into righthand side eg ```VAR1>invert|set_the_shader_.....``` + ( r"^(.*)>\&(.*)$", self.run_multi ) # pick up piped commands that duplicate a chain of values last ] + def run_multi(self, action1, action2, value): + print("multi running %s and %s with value %s" % (action1, action2, value)) + self.pc.actions.call_method_name(action1, value) + self.pc.actions.call_method_name(action2, value) + variables = {} def invert(self, action, value): @@ -65,10 +84,34 @@ class ManipulatePlugin(ActionsPlugin): ) def set_variable(self, var_name, value): + print("set_variable (%s) to %s" % (var_name, value)) self.variables[var_name] = value def recall_variable(self, var_name, action, *args): - print ("recall_variable(%s) got args %s" % (var_name,args)) + print ("recall_variable (%s) as %s" % (var_name,args)) self.pc.actions.call_method_name( action, self.variables.get(var_name)# + list(args) ) + + """def pipe2(self, left, right1, separator, right2, tail, value): + self.pc.actions.call_method_name( + left + separator + right1, value + ) + self.pc.actions.call_method_name( + left + separator + right2, value + ) + self.pc.actions.call_method_name( + tail, value + )""" + + def pipe(self, left, right, value): + # ?? + print("pipe calling left '%s' and right '%s', both with value '%s'" % (left, right, value)) + self.pc.actions.call_method_name( + left, value + ) + + self.pc.actions.call_method_name( + right, value + ) + diff --git a/plugins/MultiActionsPlugin.py b/plugins/MultiActionsPlugin.py index 1038482..41474cd 100644 --- a/plugins/MultiActionsPlugin.py +++ b/plugins/MultiActionsPlugin.py @@ -2,10 +2,16 @@ import data_centre.plugin_collection from data_centre.plugin_collection import ActionsPlugin class MultiActionsPlugin(ActionsPlugin): - disabled = False + disabled = False # this is only a demo of very basic multi-actions plugin -- superceded by ManipulatePlugin def __init__(self, plugin_collection): super().__init__(plugin_collection) + try: + from plugins import ManipulatePlugin + self.disabled = True # if we've found ManipulatePlugin then disable this one + except: + # if it fails, we're good to go (so long as not disabled explictly above) + pass @property def parserlist(self):