mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-12 03:10:17 +01:00
sorted out some confusion with modulation parameter ranges. modulation works better now. changes to wjsendplugin so that wipe effect is at least prioritised now so looks smoother (wtf...)
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
"LENGTH_SET": ["return_to_default_control_mode"],
|
||||
"CONFIRM": ["return_to_default_control_mode"],
|
||||
"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": {
|
||||
"NAV_BROWSER": ["move_browser_selection_down"],
|
||||
@@ -19,7 +20,6 @@
|
||||
"SHADER_PARAM": ["increase_this_param", "increase_shader_param"],
|
||||
"PLAY_SHADER": ["increase_this_param", "increase_shader_param"],
|
||||
"NAV_WJMX": ["wj_select_next_command"]
|
||||
|
||||
},
|
||||
"c": {
|
||||
"NAV_BROWSER": ["enter_on_browser_selection"],
|
||||
@@ -41,7 +41,8 @@
|
||||
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"],
|
||||
"SHADER_PARAM": ["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": {
|
||||
"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
|
||||
def getLFO(self, position, 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
|
||||
|
||||
# built-in waveshapes
|
||||
# outgoing values should be between 0 and 1!!
|
||||
# todo: more of the these, and better!
|
||||
def f_sin(self, position, level):
|
||||
#return level * (( math.sin(position*math.pi)))
|
||||
value = (
|
||||
(math.sin(position * math.pi*2) / 2)
|
||||
-0.5
|
||||
) + 0.5
|
||||
value = math.sin(position * math.pi * 2) / 2
|
||||
value *= level
|
||||
value += 0.5 # normalise to range 0 - 1
|
||||
|
||||
return value
|
||||
|
||||
def f_double_cos(self, position, level):
|
||||
return self.f_sin(math.cos(position*math.pi), level)
|
||||
#return self.f_sin(math.acos(position), level)
|
||||
|
||||
# SequencePlugin methods
|
||||
def run_sequence(self, position):
|
||||
@@ -106,6 +106,9 @@ class LFOModulationPlugin(ActionsPlugin,SequencePlugin,DisplayPlugin):
|
||||
if not self.active:
|
||||
return
|
||||
|
||||
for lfo in range(0,4):
|
||||
for lfo in range(0,self.MAX_LFOS):
|
||||
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)
|
||||
)
|
||||
|
||||
@@ -80,7 +80,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
||||
# find which commands are mapped to this modulation, and trigger a send of them
|
||||
# so that they update with the new modulation value
|
||||
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 self.DEBUG: print("\tparam %s, checking modulation %s" % (param, cmd.get('modulation')))
|
||||
if len(cmd.get('modulation')[param])>0:
|
||||
@@ -90,8 +90,10 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
||||
to_send[cmd['queue']] = cmd
|
||||
continue
|
||||
|
||||
for queue,cmd in sorted(to_send.items()):
|
||||
self.send_buffered(cmd['queue'], cmd['form'], [x for x in [ cmd['arguments'][y] for y in cmd['arg_names'] ] ], record=False)
|
||||
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)
|
||||
#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
|
||||
def show_plugin(self, display, display_mode):
|
||||
@@ -152,11 +154,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
||||
serial_lock = threading.Lock()
|
||||
def send_serial_string(self, string):
|
||||
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'
|
||||
#with self.ser:
|
||||
with self.serial_lock:
|
||||
#with self.serial_lock:
|
||||
self.ser.write(output) #.encode())
|
||||
#yield from self.ser.drain()
|
||||
if self.DEBUG:
|
||||
print("send_serial_string: sent string '%s'" % output) #.encode('ascii'))
|
||||
#if 'S' in string:
|
||||
@@ -205,9 +208,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
||||
# TODO: actually output modulated version of args
|
||||
output = form.format(*mod_args)
|
||||
self.send_serial_string(output)
|
||||
else:
|
||||
if self.DEBUG: print("WJSendPlugin>> skipping sending %s %s as it is similar to what was previously sent" % (form,mod_args))
|
||||
|
||||
self.last[queue] = (form,args)
|
||||
self.last_modulated[queue] = (form,mod_args)
|
||||
if record:
|
||||
if self.last[queue]!=(form,args) and record:
|
||||
self.last_record[queue] = (form,args)
|
||||
else:
|
||||
pass
|
||||
@@ -238,11 +244,13 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
||||
( 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_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):
|
||||
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 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):
|
||||
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):
|
||||
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()):
|
||||
selected_command_index = 0#self.commands.keys()[0]
|
||||
self.selected_command_name = sorted(list(self.commands.keys()))[selected_command_index]
|
||||
|
||||
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):
|
||||
self.selected_argument_index += 1
|
||||
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:
|
||||
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]))
|
||||
# amount, value, level
|
||||
newvalue = self.pc.shaders.get_modulation_value(
|
||||
args[arg_index]/255.0,
|
||||
self.modulation_value[slot],
|
||||
|
||||
@@ -230,7 +230,8 @@ class Shaders(object):
|
||||
self.osc_client.send_message("/shader/{}/param".format(str(layer)), [param, amount] )
|
||||
|
||||
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):
|
||||
plugin.set_modulation_value(param, self.modulation_value[param])
|
||||
for layer,params in enumerate(self.selected_param_list):
|
||||
|
||||
Reference in New Issue
Block a user