mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-11 19:00:04 +01:00
backport modulation features
This commit is contained in:
@@ -908,6 +908,11 @@ class Actions(object):
|
||||
( r"start_shader_layer_([0-2])", self.shaders.start_shader ),
|
||||
( r"stop_shader_layer_([0-2])", self.shaders.stop_shader ),
|
||||
( r"set_the_shader_param_([0-3])_layer_([0-2])_continuous", self.shaders.set_param_layer_to_amount ),
|
||||
( r"modulate_param_([0-3])_to_amount_continuous", self.shaders.modulate_param_to_amount ),
|
||||
( r"set_param_([0-3])_layer_([0-2])_modulation_level_continuous", self.shaders.set_param_layer_offset_modulation_level ),
|
||||
( r"set_param_([0-3])_layer_offset_([0-2])_modulation_level_continuous", self.shaders.set_param_layer_offset_modulation_level ),
|
||||
( r"select_shader_modulation_slot_([0-3])", self.shaders.select_shader_modulation_slot ),
|
||||
( r"set_shader_speed_layer_offset_([0-2])_amount", self.shaders.set_speed_offset_to_amount ),
|
||||
( r"set_shader_speed_layer_([0-2])_amount", self.shaders.set_speed_layer_to_amount ),
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,18 @@
|
||||
},
|
||||
"s": {
|
||||
"DEFAULT": ["load_slot_9_into_next_player","confirm_shutdown"],
|
||||
"PLAY_SHADER": ["play_shader_9","confirm_shutdown"]
|
||||
}
|
||||
"PLAY_SHADER": ["play_shader_9","confirm_shutdown"]
|
||||
},
|
||||
"/volume": {
|
||||
"DEFAULT": ["modulate_param_0_to_amount_continuous"]
|
||||
},
|
||||
"/kick": {
|
||||
"DEFAULT": ["modulate_param_1_to_amount_continuous"]
|
||||
},
|
||||
"/himid": {
|
||||
"DEFAULT": ["modulate_param_2_to_amount_continuous"]
|
||||
},
|
||||
"/high": {
|
||||
"DEFAULT": ["modulate_param_3_to_amount_continuous"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class OscInput(object):
|
||||
|
||||
def setup_osc_server(self):
|
||||
server_parser = argparse.ArgumentParser()
|
||||
server_parser.add_argument("--ip", default="127.0.0.1", help="the ip")
|
||||
server_parser.add_argument("--ip", default="0.0.0.0", help="the ip")
|
||||
server_parser.add_argument("--port", type=int, default=5433, help="the port")
|
||||
|
||||
server_args = server_parser.parse_args()
|
||||
@@ -29,6 +29,7 @@ class OscInput(object):
|
||||
this_dispatcher = dispatcher.Dispatcher()
|
||||
this_dispatcher.map("/recurOsc", self.on_osc_input)
|
||||
this_dispatcher.map("/shutdown", self.exit_osc_server)
|
||||
this_dispatcher.map("/*", self.on_osc_message)
|
||||
|
||||
server = osc_server.ThreadingOSCUDPServer((server_args.ip, server_args.port), this_dispatcher)
|
||||
server_thread = threading.Thread(target=server.serve_forever)
|
||||
@@ -38,8 +39,15 @@ class OscInput(object):
|
||||
def exit_osc_server(self, unused_addr, args):
|
||||
self.osc_server.shutdown()
|
||||
|
||||
def on_osc_input(self, unused_addr, args):
|
||||
print("!!!!!!!!!!!!!!!!" + args)
|
||||
def on_osc_message(self, addr, args):
|
||||
#print("!!!!!!!!!!!!!!!!%s\t%s" %(addr,args))
|
||||
#print ("%s" %self.osc_mappings.keys())
|
||||
if addr in self.osc_mappings:
|
||||
#'print("got a mapping for %s with value %s" % (addr,args))
|
||||
self.actions.call_method_name(self.osc_mappings[addr]['DEFAULT'][0], args)
|
||||
|
||||
def on_osc_input(self, addr, args):
|
||||
#print("!!!!!!!!!!!!!!!!" + addr + ", " + args)
|
||||
numpad = list(string.ascii_lowercase[0:19])
|
||||
|
||||
if args in numpad:
|
||||
@@ -47,7 +55,7 @@ class OscInput(object):
|
||||
else:
|
||||
print('{} is not in keypad map'.format(args))
|
||||
|
||||
def run_action_for_osc_channel(self, channel):
|
||||
def run_action_for_osc_channel(self, channel, args = None):
|
||||
this_mapping = self.osc_mappings[channel]
|
||||
if self.data.control_mode in this_mapping:
|
||||
mode = self.data.control_mode
|
||||
@@ -56,12 +64,14 @@ class OscInput(object):
|
||||
|
||||
if self.data.function_on and len(this_mapping[mode]) > 1:
|
||||
print('the action being called is {}'.format(this_mapping[mode][1]))
|
||||
getattr(self.actions, this_mapping[mode][1])()
|
||||
#getattr(self.actions, this_mapping[mode][1])()
|
||||
self.actions.call_method_name(this_mapping[mode][1], args)
|
||||
if self.data.settings['sampler']['FUNC_GATED']['value'] == 'off':
|
||||
self.data.function_on = False
|
||||
else:
|
||||
print('the action being called is {}'.format(this_mapping[mode][0]))
|
||||
getattr(self.actions, this_mapping[mode][0])()
|
||||
#getattr(self.actions, this_mapping[mode][0])()
|
||||
self.actions.call_method_name(this_mapping[mode][0], args)
|
||||
|
||||
self.display.refresh_display()
|
||||
|
||||
|
||||
@@ -14,8 +14,12 @@ class Shaders(object):
|
||||
self.selected_shader_list = [self.EMPTY_SHADER for i in range(3)]
|
||||
self.focused_param = 0
|
||||
self.shaders_menu_list = self.generate_shaders_list()
|
||||
|
||||
self.selected_modulation_slot = 0
|
||||
|
||||
self.selected_status_list = ['-','-','-'] ## going to try using symbols for this : '-' means empty, '▶' means running, '■' means not running, '!' means error
|
||||
self.selected_modulation_level = [[[0.0,0.0,0.0,0.0] for i in range(4)] for i in range(3)]
|
||||
self.modulation_value = [0.0,0.0,0.0,0.0]
|
||||
self.selected_param_list = [[0.0,0.0,0.0,0.0] for i in range(3)]
|
||||
self.selected_speed_list = [1.0, 1.0, 1.0]
|
||||
#self.load_selected_shader()
|
||||
@@ -154,6 +158,9 @@ class Shaders(object):
|
||||
def set_x3_as_speed(self, status):
|
||||
self.data.settings['shader']['X3_AS_SPEED']['value'] = 'enabled' if status else 'disabled'
|
||||
|
||||
def select_shader_modulation_slot(self, slot):
|
||||
self.selected_modulation_slot = slot
|
||||
|
||||
@staticmethod
|
||||
def get_new_param_amount(current, change):
|
||||
if current + change > 1:
|
||||
@@ -177,9 +184,64 @@ class Shaders(object):
|
||||
def set_param_layer_to_amount(self, param, layer, amount):
|
||||
if self.data.settings['shader']['X3_AS_SPEED']['value'] == 'enabled' and param == 3:
|
||||
self.set_speed_to_amount(amount, layer) #layer_offset=layer-self.data.shader_layer)
|
||||
else:
|
||||
self.osc_client.send_message("/shader/{}/param".format(str(layer)), [param, amount] )
|
||||
self.selected_param_list[layer][param] = amount
|
||||
else:
|
||||
self.selected_param_list[layer][param] = amount
|
||||
self.update_param_layer(param,layer)
|
||||
|
||||
def get_modulation_value_list(self, amount, values, levels):
|
||||
l = []
|
||||
for i,v in enumerate(values):
|
||||
l.append(self.get_modulation_value(amount, v, levels[i]))
|
||||
|
||||
from statistics import mean
|
||||
#print ("got mean %s from amount %s with %s*%s" % (mean(l), amount, values, levels))
|
||||
return mean(l)
|
||||
|
||||
def get_modulation_value(self, amount, value, level):
|
||||
if level==0:
|
||||
return amount
|
||||
|
||||
# TODO: read from list of input formulas, from plugins etc to modulate the value
|
||||
temp_amount = amount + (value * level)
|
||||
#print("from amount %s, modulation is %s, temp_amount is %s" % (amount, modulation, temp_amount))
|
||||
if temp_amount < 0: temp_amount = 0 # input range is 0-1 so convert back
|
||||
if temp_amount > 1: temp_amount = 1 # modulation however is -1 to +1
|
||||
|
||||
return temp_amount
|
||||
|
||||
def send_param_layer_amount_message(self, param, layer, amount):
|
||||
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
|
||||
for layer,params in enumerate(self.selected_param_list):
|
||||
for ip,p in enumerate(params):
|
||||
for p2,v in enumerate(self.selected_modulation_level[layer][ip]):
|
||||
if v!=0:
|
||||
self.update_param_layer(ip,layer)
|
||||
break
|
||||
|
||||
def set_param_layer_offset_modulation_level(self, param, layer, level):
|
||||
layer = (self.data.shader_layer + layer) % 3
|
||||
self.set_param_layer_modulation_level(param, layer, level)
|
||||
|
||||
def set_param_layer_modulation_level(self, param, layer, level):
|
||||
self.selected_modulation_level[layer][param][self.selected_modulation_slot] = level
|
||||
self.update_param_layer(param, layer)
|
||||
|
||||
def update_param_layer(self, param, layer):
|
||||
# merge all applicable layers
|
||||
|
||||
self.send_param_layer_amount_message(param, layer,
|
||||
self.get_modulation_value_list(
|
||||
self.selected_param_list[layer][param],
|
||||
self.modulation_value,#[0], #param],
|
||||
self.selected_modulation_level[layer][param]
|
||||
)
|
||||
)
|
||||
|
||||
def set_speed_offset_to_amount(self, layer_offset, amount):
|
||||
self.set_speed_to_amount(amount, layer_offset)
|
||||
|
||||
def set_speed_to_amount(self, amount, layer_offset=0):
|
||||
layer = (self.data.shader_layer + layer_offset) % 3
|
||||
@@ -188,4 +250,5 @@ class Shaders(object):
|
||||
def set_speed_layer_to_amount(self, layer, amount):
|
||||
self.osc_client.send_message("/shader/{}/speed".format(str(layer)), amount )
|
||||
self.selected_speed_list[layer] = amount
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user