|
Post by schlapbe on Mar 17, 2022 2:41:36 GMT -5
Hi you all, I ran into a problem yesterday and I can't wrap my head around it, why it did not work in the first place in ClyphX, when running in Vision Studio Code perfectly. I have a mixer matrix setup, where volume values are stored for each submix and I wrote a recall action. It is a one-dimension list (I want to change to classes at a later point....) [0,0,0,0,0,104] etc.... I got a function, where I can recall an individual submix.
def submix_recall(self,action_def,args) that works fine so far.
Now I want to have a total-matrix-recall action where submix 1-17 is recalled: def matrix_recall(): for x in range(1,17): submix_recall(??,??,x)
I tried around so many things, but it did not work at all. In Visual Studio Code it worked perfectly without the self and action_def arguments like this:
def submix_recall(args): CODE for submixrecall def matrix_recall(): for x in range(1,17): submix_recall(x)
matrix_recall()
ChainsawArt kirkwoodwest Any ideas? I found a workaround where I use the submix_recall with argument 1-16 or ALL, but inside the function I have literally twice the same code.....
I found also another weird thing, but that is probably for another post
|
|
|
Post by schlapbe on Mar 17, 2022 17:58:03 GMT -5
Thank you ChainsawArt as always for being my light at the end of the tunnel.... source_vars=[ ["position","sourcename","SENDLetter","MIDI CH","MIDI CC","source-led--note"], [1,"input","-",1,102], [2,"Pedalboard","K",1,104,12], [3,"Distortion","I",1,105,24], [4,"microcosm","E",1,106], [5,"blooper","C",1,108], [6,"mtlasm.856","B",1,109], [7,"MOOD","J",2,105], [8,"tensor","A",1,105], [9,"ottobit jr.","D",2,108], [10,"H9 exevntide(DESK)","G",2,110], [11,"CXM 1978","F",2,112], [12,"Volante","I",2,102], [13,"MIC1 - Input 9","-",1,110], [14,"MIC2 - Input 10","-",1,111], [15,"MIC3 - Input 11","-",1,112], [16,"MIC3 - Input 12","-",1,113], ] submix_vars=[ ["Position","NAME","mono(1)/stereo(2)","MIDI CH","MIDI CC","Ableton IN","RME IN"], [1,"re-record",2,13,104], [2,"Pedalboard",1,13,106], [3,"Filter",1,14,108], [4,"microcosm",2,13,108], [5,"blooper",1,13,110], [6,"856mtlasm",1,13,111], [7,"MOOD",1,14,107], [8,"tensor",1,13,107], [9,"ottobit",2,14,110], [10,"H9 Desk",2,14,112], [11,"CXM 1978",2,14,114], [12,"VOLANTE",2,14,104], [13,"PHONES",2,13,112], [14,"MAIN OUT",2,13,116], [15,"PHONES2",2,13,114], [16,"ATEM",2,14,102], ]
class ExampleActions(UserActionsBase): def create_actions(self): self.add_global_action('matrixrecall', self.matrix_recall) self.add_global_action('submixrecall', self.submix_recall)
def submix_recall(self,action_def,args): global matrix if str(args).upper() == "ALL": self.canonical_parent.log_message("COMPLETE MATRIX RECALL") for submix_recall in range (1,17): submix_ch=str(submix_vars[submix_recall][3]) submix_cc=str(submix_vars[submix_recall][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd) #self.canonical_parent.log_message(submix_cmd) for x in range(1,submixtotal+1): input_ch=str(source_vars[x][3]) input_cc=str(source_vars[x][4]) matrix_pos=(submix_recall-1)*12+x-1 matrix_vol_value=str(matrix[matrix_pos]) midi_cmd="MIDI CC %s %s %s" % (input_ch,input_cc,matrix_vol_value) self.canonical_parent.clyphx_pro_component.trigger_action_list(midi_cmd) self.canonical_parent.log_message("select Phones Submix") submix_ch=str(submix_vars[13][3]) submix_cc=str(submix_vars[13][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd) self.canonical_parent.log_message(submix_cmd) return if int(args) in range(1,17): self.canonical_parent.log_message("only SUBMIX xz recall") submix_recall=int(args) submix_ch=str(submix_vars[submix_recall][3]) submix_cc=str(submix_vars[submix_recall][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd) for x in range(1,submixtotal+1): input_ch=str(source_vars[x][3]) input_cc=str(source_vars[x][4]) matrix_pos=(submix_recall-1)*12+x-1 matrix_vol_value=str(matrix[matrix_pos]) midi_cmd="MIDI CC %s %s %s" % (input_ch,input_cc,matrix_vol_value) self.canonical_parent.clyphx_pro_component.trigger_action_list(midi_cmd) #self.canonical_parent.log_message(midi_cmd) #select phones mix after TotalMix Recall submix_ch=str(submix_vars[13][3]) submix_cc=str(submix_vars[13][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.log_message("select Phones Submix") self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd) #self.canonical_parent.log_message(submix_cmd) return def matrix_recall(self,action_def,args): for x in range(1,17): submix_recall(self,action_def,x) self.canonical_parent.log_message("Matrix recall function %s" % x) self.canonical_parent.show_message("Matrix recalled")
this is how it works now. Well, submix recall does work. But I'd like to shrink down the code, because it is basically the same code twice..... the matrix_recall does not go through the Message output. I guess there is some syntax error, which is not reported in the log file. or is this something I could track down with the debugging feature in ClyphX? terrarium : I see you now!
|
|
|
Post by terrarium on Mar 17, 2022 18:31:34 GMT -5
Hey i recommend doing debug messages like this instead.
fnc = self.canonical_parent.clyphx_pro_component.trigger_action_list fnc("MSG OPENING URL")
instead of the show_message passage you got there. It's just more reliable.
For your preset definition here, that way you're doing is with the multi-dimensional array is cool, but I'd probably do it in JSON. This way you won't have to remember what position each effect is in your array because the EFFECT is the index not a number (ex source_vars['ottobit jr.'] vs source_vars[9]). you can probably just save yourself writing a class.
|
|
|
Post by ChainsawArt on Mar 17, 2022 22:32:39 GMT -5
Here you go. I wasn't sure what value the "submixtotal" variable was referencing, so I had to comment out the for-loop in testing, but this should work. Hopefully this gives you an idea of how to write and use generic functions in a User Action script. Let me know how it goes for you.
class ExampleActions(UserActionsBase):
def create_actions(self): self.add_global_action('matrixrecall', self.matrix_recall)
def matrix_recall(self, action_def, args): ''' global user action that accepts integers or the "all" keyword ''' if args.isnumeric(): ''' If all characters in args string are numeric, do this ''' self.submix_recall(int(args)) elif str(args).upper() == "ALL": for x in range(1, 17): ''' run the submix_recall function passing the values of x in the for-loop as args to the function one at a time ''' self.submix_recall(x) submix_ch=str(submix_vars[13][3]) submix_cc=str(submix_vars[13][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.log_message("select Phones Submix") self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd)
def submix_recall(self, args): ''' generic recall function ''' submix_recall=args self.canonical_parent.log_message(submix_recall) submix_ch=str(submix_vars[submix_recall][3]) submix_cc=str(submix_vars[submix_recall][4]) submix_cmd="MIDI CC %s %s 127" % (submix_ch, submix_cc) self.canonical_parent.clyphx_pro_component.trigger_action_list(submix_cmd) for x in range(1,submixtotal+1): input_ch=str(source_vars[x][3]) input_cc=str(source_vars[x][4]) matrix_pos=(submix_recall-1)*12+x-1 matrix_vol_value=str(matrix[matrix_pos]) midi_cmd="MIDI CC %s %s %s" % (input_ch,input_cc,matrix_vol_value) self.canonical_parent.clyphx_pro_component.trigger_action_list(midi_cmd)
|
|
|
Post by schlapbe on Mar 18, 2022 2:10:11 GMT -5
Hey man, brilliant. I had a chat with terrarium last night and he also gave me the missing piece of information. it is pretty simple, if you got the concept of self right..... Thank you for your effort, ChainsawArt ! Highly appreciated! def function_to_call(self, action_def, args): some_action_XY
and than:
self.function_to_call(action_def,parameters)
instead of function_to_call(self,action_def,parameters)
|
|
|
Post by terrarium on Mar 18, 2022 21:41:25 GMT -5
Here's a note for both of ya'll, ChainsawArt schlapbe. I just think you'll be much better served by a static human readable data structure, rather than a class. Here's an example from your code with JSON instead of an array. test={ "input": {"sendletter":"a", "midi_ch":1}, "pedalboard": {"sendletter":"b", "midi_ch":2}, "Distortion": {"sendletter":"c", "midi_ch":3}, "microcosm":{"sendletter":"d", "midi_ch":4}} print("The sendletter for distortion is " + test["Distortion"]["sendletter"]) Here's a debugger you can use. jsonformatter.curiousconcept.com/#
|
|