mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-13 20:00:12 +01:00
Merge branch 'feature_plugins' into feature_plugins_shader_gadgets
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
"LENGTH_SET": ["return_to_default_control_mode"],
|
"LENGTH_SET": ["return_to_default_control_mode"],
|
||||||
"CONFIRM": ["return_to_default_control_mode"],
|
"CONFIRM": ["return_to_default_control_mode"],
|
||||||
"SHADER_PARAM": ["decrease_this_param", "decrease_shader_param"],
|
"SHADER_PARAM": ["decrease_this_param", "decrease_shader_param"],
|
||||||
"PLAY_SHADER": ["decrease_this_param", "decrease_shader_param"]
|
"PLAY_SHADER": ["decrease_this_param", "decrease_shader_param"],
|
||||||
|
"NAV_WJMX": ["wj_select_previous_command"]
|
||||||
},
|
},
|
||||||
"b": {
|
"b": {
|
||||||
"NAV_BROWSER": ["move_browser_selection_down"],
|
"NAV_BROWSER": ["move_browser_selection_down"],
|
||||||
@@ -19,7 +20,6 @@
|
|||||||
"SHADER_PARAM": ["increase_this_param", "increase_shader_param"],
|
"SHADER_PARAM": ["increase_this_param", "increase_shader_param"],
|
||||||
"PLAY_SHADER": ["increase_this_param", "increase_shader_param"],
|
"PLAY_SHADER": ["increase_this_param", "increase_shader_param"],
|
||||||
"NAV_WJMX": ["wj_select_next_command"]
|
"NAV_WJMX": ["wj_select_next_command"]
|
||||||
|
|
||||||
},
|
},
|
||||||
"c": {
|
"c": {
|
||||||
"NAV_BROWSER": ["enter_on_browser_selection"],
|
"NAV_BROWSER": ["enter_on_browser_selection"],
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"],
|
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"],
|
||||||
"SHADER_PARAM": ["decrease_param_focus"],
|
"SHADER_PARAM": ["decrease_param_focus"],
|
||||||
"PLAY_SHADER": ["decrease_param_focus"],
|
"PLAY_SHADER": ["decrease_param_focus"],
|
||||||
"NAV_DETOUR": ["decrease_mix_shader"]
|
"NAV_DETOUR": ["decrease_mix_shader"],
|
||||||
|
"NAV_WJMX": ["wj_select_previous_argument"]
|
||||||
},
|
},
|
||||||
"f": {
|
"f": {
|
||||||
"DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"],
|
"DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"],
|
||||||
|
|||||||
@@ -77,23 +77,23 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin):
|
|||||||
#lfo_speed = [1.0]*MAX_LFOS
|
#lfo_speed = [1.0]*MAX_LFOS
|
||||||
def getLFO(self, position, lfo):
|
def getLFO(self, position, lfo):
|
||||||
lfo_value = getattr(self,self.formula[lfo])(position, self.level[lfo])
|
lfo_value = getattr(self,self.formula[lfo])(position, self.level[lfo])
|
||||||
self.last_lfo_status[lfo] = " sent {:03.1f}%".format(lfo_value*100.0) #, position*self.lfo_speed[lfo])
|
self.last_lfo_status[lfo] = " sent {:03.1f}%".format(lfo_value*100.0)
|
||||||
return lfo_value
|
return lfo_value
|
||||||
|
|
||||||
# built-in waveshapes
|
# built-in waveshapes
|
||||||
|
# outgoing values should be between 0 and 1!!
|
||||||
# todo: more of the these, and better!
|
# todo: more of the these, and better!
|
||||||
def f_sin(self, position, level):
|
def f_sin(self, position, level):
|
||||||
#return level * (( math.sin(position*math.pi)))
|
#return level * (( math.sin(position*math.pi)))
|
||||||
value = (
|
value = math.sin(position * math.pi * 2) / 2
|
||||||
(math.sin(position * math.pi*2) / 2)
|
|
||||||
-0.5
|
|
||||||
) + 0.5
|
|
||||||
value *= level
|
value *= level
|
||||||
|
value += 0.5 # normalise to range 0 - 1
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def f_double_cos(self, position, level):
|
def f_double_cos(self, position, level):
|
||||||
return self.f_sin(math.cos(position*math.pi), level)
|
return self.f_sin(math.cos(position*math.pi), level)
|
||||||
|
#return self.f_sin(math.acos(position), level)
|
||||||
|
|
||||||
# SequencePlugin methods
|
# SequencePlugin methods
|
||||||
def run_sequence(self, position):
|
def run_sequence(self, position):
|
||||||
@@ -106,6 +106,9 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin):
|
|||||||
if not self.active:
|
if not self.active:
|
||||||
return
|
return
|
||||||
|
|
||||||
for lfo in range(0,4):
|
for lfo in range(0,self.MAX_LFOS):
|
||||||
if self.level[lfo]>0.0:
|
if self.level[lfo]>0.0:
|
||||||
self.pc.actions.call_method_name("modulate_param_%s_to_amount_continuous"%lfo, self.getLFO(position, lfo))
|
self.pc.actions.call_method_name(
|
||||||
|
"modulate_param_%s_to_amount_continuous"%lfo,
|
||||||
|
self.getLFO(position, lfo)
|
||||||
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import threading
|
|||||||
|
|
||||||
class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationReceiverPlugin, AutomationSourcePlugin):
|
class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationReceiverPlugin, AutomationSourcePlugin):
|
||||||
disabled = False#True
|
disabled = False#True
|
||||||
DEBUG = False#True
|
DEBUG = False #True
|
||||||
ser = None
|
ser = None
|
||||||
# from http://depot.univ-nc.nc/sources/boxtream-0.9999/boxtream/switchers/panasonic.py
|
# from http://depot.univ-nc.nc/sources/boxtream-0.9999/boxtream/switchers/panasonic.py
|
||||||
"""serial.Serial(device, baudrate=9600,
|
"""serial.Serial(device, baudrate=9600,
|
||||||
@@ -80,7 +80,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
# find which commands are mapped to this modulation, and trigger a send of them
|
# find which commands are mapped to this modulation, and trigger a send of them
|
||||||
# so that they update with the new modulation value
|
# so that they update with the new modulation value
|
||||||
to_send = {}
|
to_send = {}
|
||||||
for queue,cmd in sorted(self.command_by_queue.items()):
|
for queue,cmd in sorted(self.command_by_queue.items(),reverse=True):
|
||||||
if cmd.get('modulation') is not None:
|
if cmd.get('modulation') is not None:
|
||||||
#if self.DEBUG: print("\tparam %s, checking modulation %s" % (param, cmd.get('modulation')))
|
#if self.DEBUG: print("\tparam %s, checking modulation %s" % (param, cmd.get('modulation')))
|
||||||
if len(cmd.get('modulation')[param])>0:
|
if len(cmd.get('modulation')[param])>0:
|
||||||
@@ -90,8 +90,10 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
to_send[cmd['queue']] = cmd
|
to_send[cmd['queue']] = cmd
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for queue,cmd in sorted(to_send.items()):
|
for queue,cmd in sorted(to_send.items(),reverse=True):
|
||||||
self.send_buffered(cmd['queue'], cmd['form'], [x for x in [ cmd['arguments'][y] for y in cmd['arg_names'] ] ], record=False)
|
#self.send_buffered(cmd['queue'], cmd['form'], [x for x in [ cmd['arguments'][y] for y in cmd['arg_names'] ] ], record=False)
|
||||||
|
#with self.queue_lock:
|
||||||
|
self.send(cmd['queue'], cmd['form'], [x for x in [ cmd['arguments'][y] for y in cmd['arg_names'] ] ])
|
||||||
|
|
||||||
#methods for DisplayPlugin
|
#methods for DisplayPlugin
|
||||||
def show_plugin(self, display, display_mode):
|
def show_plugin(self, display, display_mode):
|
||||||
@@ -152,11 +154,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
serial_lock = threading.Lock()
|
serial_lock = threading.Lock()
|
||||||
def send_serial_string(self, string):
|
def send_serial_string(self, string):
|
||||||
try:
|
try:
|
||||||
if self.DEBUG: print("WJSendPlugin>> sending string %s " % string)
|
if self.DEBUG:
|
||||||
|
print("WJSendPlugin>> sending string %s " % string)
|
||||||
output = b'\2' + string.encode('ascii') + b'\3'
|
output = b'\2' + string.encode('ascii') + b'\3'
|
||||||
#with self.ser:
|
#with self.serial_lock:
|
||||||
with self.serial_lock:
|
self.ser.write(output) #.encode())
|
||||||
self.ser.write(output) #.encode())
|
#yield from self.ser.drain()
|
||||||
if self.DEBUG:
|
if self.DEBUG:
|
||||||
print("send_serial_string: sent string '%s'" % output) #.encode('ascii'))
|
print("send_serial_string: sent string '%s'" % output) #.encode('ascii'))
|
||||||
#if 'S' in string:
|
#if 'S' in string:
|
||||||
@@ -205,10 +208,13 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
# TODO: actually output modulated version of args
|
# TODO: actually output modulated version of args
|
||||||
output = form.format(*mod_args)
|
output = form.format(*mod_args)
|
||||||
self.send_serial_string(output)
|
self.send_serial_string(output)
|
||||||
self.last[queue] = (form,args)
|
else:
|
||||||
self.last_modulated[queue] = (form,mod_args)
|
if self.DEBUG: print("WJSendPlugin>> skipping sending %s %s as it is similar to what was previously sent" % (form,mod_args))
|
||||||
if record:
|
|
||||||
self.last_record[queue] = (form,args)
|
self.last[queue] = (form,args)
|
||||||
|
self.last_modulated[queue] = (form,mod_args)
|
||||||
|
if self.last[queue]!=(form,args) and record:
|
||||||
|
self.last_record[queue] = (form,args)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
#print("WJSendPlugin>> found no difference between:\n\t%s\n\t%s\n?" % (self.last_modulated.get(queue), (form,mod_args)))
|
#print("WJSendPlugin>> found no difference between:\n\t%s\n\t%s\n?" % (self.last_modulated.get(queue), (form,mod_args)))
|
||||||
@@ -238,11 +244,13 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
( r"^wj_send_append:([:0-9a-zA-Z]*)$", self.send_append ),
|
( r"^wj_send_append:([:0-9a-zA-Z]*)$", self.send_append ),
|
||||||
( r"^wj_set_([a-zA-Z_]*)[:]?([a-zA-Z_]*)$", self.catch_all ),
|
( r"^wj_set_([a-zA-Z_]*)[:]?([a-zA-Z_]*)$", self.catch_all ),
|
||||||
( r"^wj_select_next_command$", self.select_next_command ),
|
( r"^wj_select_next_command$", self.select_next_command ),
|
||||||
( r"^wj_select_next_argument$", self.select_next_argument )
|
( r"^wj_select_previous_command$", self.select_previous_command ),
|
||||||
|
( r"^wj_select_next_argument$", self.select_next_argument ),
|
||||||
|
( r"^wj_select_previous_argument$", self.select_previous_argument )
|
||||||
]
|
]
|
||||||
|
|
||||||
def set_modulation_command_argument_level(self, command_name, argument_name, slot, level):
|
def set_modulation_command_argument_level(self, command_name, argument_name, slot, level):
|
||||||
print("set_modulation_command_argument_level(%s, %s, %s, %s)" % (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: argument_name = 'v'
|
||||||
|
|
||||||
if self.commands[command_name].get('modulation') is None:
|
if self.commands[command_name].get('modulation') is None:
|
||||||
@@ -252,15 +260,27 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
def set_current_modulation_level(self, slot, 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)
|
self.set_modulation_command_argument_level(self.selected_command_name, self.commands[self.selected_command_name]['arg_names'][self.selected_argument_index], slot, level)
|
||||||
|
|
||||||
|
def select_previous_command(self):
|
||||||
|
selected_command_index = list(sorted(self.commands.keys())).index(self.selected_command_name)-1
|
||||||
|
if selected_command_index<0:
|
||||||
|
selected_command_index = len(self.commands.keys())
|
||||||
|
self.selected_command_name = sorted(list(self.commands.keys()))[selected_command_index]
|
||||||
|
|
||||||
|
self.selected_argument_index = 0
|
||||||
|
|
||||||
def select_next_command(self):
|
def select_next_command(self):
|
||||||
selected_command_index = list(sorted(self.commands.keys())).index(self.selected_command_name)+1
|
selected_command_index = list(sorted(self.commands.keys())).index(self.selected_command_name)+1
|
||||||
print("selected %s" % selected_command_index)
|
|
||||||
if selected_command_index>=len(self.commands.keys()):
|
if selected_command_index>=len(self.commands.keys()):
|
||||||
selected_command_index = 0#self.commands.keys()[0]
|
selected_command_index = 0#self.commands.keys()[0]
|
||||||
self.selected_command_name = sorted(list(self.commands.keys()))[selected_command_index]
|
self.selected_command_name = sorted(list(self.commands.keys()))[selected_command_index]
|
||||||
|
|
||||||
self.selected_argument_index = 0
|
self.selected_argument_index = 0
|
||||||
|
|
||||||
|
def select_previous_argument(self):
|
||||||
|
self.selected_argument_index -= 1
|
||||||
|
if self.selected_argument_index<0:
|
||||||
|
self.selected_argument_index = len(self.commands[self.selected_command_name]['arg_names'])
|
||||||
|
|
||||||
def select_next_argument(self):
|
def select_next_argument(self):
|
||||||
self.selected_argument_index += 1
|
self.selected_argument_index += 1
|
||||||
if self.selected_argument_index>=len(self.commands[self.selected_command_name]['arg_names']):
|
if self.selected_argument_index>=len(self.commands[self.selected_command_name]['arg_names']):
|
||||||
@@ -286,6 +306,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
if m>0.0:
|
if m>0.0:
|
||||||
arg_index = command.get('arg_names').index(arg_name)
|
arg_index = command.get('arg_names').index(arg_name)
|
||||||
if self.DEBUG: print("\t\tupdating modulation slot %s, arg is %s\n\t with modlevel '%s' * modvalue '%s'" % (arg_index, args[arg_index], m, self.modulation_value[slot]))
|
if self.DEBUG: print("\t\tupdating modulation slot %s, arg is %s\n\t with modlevel '%s' * modvalue '%s'" % (arg_index, args[arg_index], m, self.modulation_value[slot]))
|
||||||
|
# amount, value, level
|
||||||
newvalue = self.pc.shaders.get_modulation_value(
|
newvalue = self.pc.shaders.get_modulation_value(
|
||||||
args[arg_index]/255.0,
|
args[arg_index]/255.0,
|
||||||
self.modulation_value[slot],
|
self.modulation_value[slot],
|
||||||
@@ -307,7 +328,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
'colour_T': {
|
'colour_T': {
|
||||||
'name': 'Colour Corrector - both',
|
'name': 'Colour Corrector - both',
|
||||||
'queue': 'VCC',
|
'queue': 'VCC',
|
||||||
'form': 'VCC:T{:02X}{:02X}00',
|
'form': 'VCC:T{:02X}{:02X}',
|
||||||
'arg_names': [ 'x', 'y' ],
|
'arg_names': [ 'x', 'y' ],
|
||||||
'arguments': { 'x': 127, 'y': 127 },
|
'arguments': { 'x': 127, 'y': 127 },
|
||||||
'modulation': [ {}, {}, { 'x': 1.0 }, { 'y': 1.0 } ]
|
'modulation': [ {}, {}, { 'x': 1.0 }, { 'y': 1.0 } ]
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ class Shaders(object):
|
|||||||
self.osc_client.send_message("/shader/{}/param".format(str(layer)), [param, amount] )
|
self.osc_client.send_message("/shader/{}/param".format(str(layer)), [param, amount] )
|
||||||
|
|
||||||
def modulate_param_to_amount(self, param, value):
|
def modulate_param_to_amount(self, param, value):
|
||||||
self.modulation_value[param] = (value-0.5)*2
|
# incoming data here should be in format 0 to 1; needs changing to -1 to +1
|
||||||
|
self.modulation_value[param] = (value-0.5)*2 # normalise to -1 to +1
|
||||||
for plugin in self.data.plugins.get_plugins(ModulationReceiverPlugin):
|
for plugin in self.data.plugins.get_plugins(ModulationReceiverPlugin):
|
||||||
plugin.set_modulation_value(param, self.modulation_value[param])
|
plugin.set_modulation_value(param, self.modulation_value[param])
|
||||||
for layer,params in enumerate(self.selected_param_list):
|
for layer,params in enumerate(self.selected_param_list):
|
||||||
|
|||||||
Reference in New Issue
Block a user