Matrix changing props

Hi,

I'm trying to use a 2 values switch to change some matrix's stuff :

  • props.on
  • props.off
  • props.preArgs

So... let's say, if switch == 1, i want :

  • props.on = [37+$,127]
  • props.off = [28+$,127]
  • props.preArgs = [10,@{'this'}]

and if switch==2, i want :

  • props.on = 127
  • props.off = 10
  • props.preArgs = [10,60+$]

An here i am with my unworking thing :

props.on = "#{@{'switch_VST'}==2 ? '127' : '"+[37+$,127]+"'}"
props.off = "#{@{'switch_VST'}==2 ? '0' : '"+[28+$,127]+"'}"
props.address="/control"
props.preArgs="#{@{'switch_VST'}==2 ? '"+[10,60+$]+"' : '"+[10,@{'this'}]+"'}"
props.target="midi:OSC"
return props

I don't even remember how i had the good "switch==2" returns... but now... i'm stuck.

"Cerise sur le gâteau", i'll have to set a prop.script too, in order to make my matrix works as a switch, when switch==2... I know how to do all those things separately... but this way... :metal: :woozy_face: :upside_down_face:

Thanks

  • you don't need to use #{} blocks, you're already in a JS{} block.
  • @{} doesn't expect quotes
  • what are you trying to do by setting on or off to an array containing 2 numbers ? I dont get the logic with preArgs either. You won't get a midi message out of it unless you have some processing going on in a custom module.

Anyway, here are some syntax fixes:

var switch_vst = @{switch_VST}
props.on = switch_vst == 2 ? 127 : [37+$, 127]
props.off = switch_vst == 2 ? 0 : [28+$, 127]
props.address = "/control"
props.preArgs = switch_vst == 2 ? [10, 60+$] : [10, @_{this}] // dunno what you want to do here, but I guess you want to use the button's value, hence the underscore

Thank you, @jean-emmanuel.

I'll try to remember those syntax fixes :+1: . But for now, it's not working with it (even adding the missing :). And i loose color, labels...

what are you trying to do by setting on or off to an array containing 2 numbers ?

  • Well, in the original matrix, i have this :
props.on=[37+$,127]      
props.off=[28+$,127]
props.address="/control"
props.preArgs=[10,@{'this'}]
props.target="midi:OSC"

i'm sending one midi CC when on, and another when off, to show/hide tracks in Cubase. If i don't add the second value, nothing happens, and i get a

(DEBUG, MIDI) out: NONE (ERROR: wrong number of argument for /control) To: midi:OSC

This way it works well, so... Would it more appropriate using a script ?...

  • Then i have the "twin" matrix, with this :
props.on = 127
props.off = 10
props.address = "/control"
props.preArgs = [10, 60+$]
props.target="midi:OSC"

This sends CC to have a "show only track - macro" in Cubase.
It works fine too.

BTW: setting on to 127 and off to 10 instead of 0 is often usefull to make Cubase buttons and o-s-c buttons behave the same way... don't know why... nor how i got there...

Now, i was just trying to get the whole thing working in only one matrix, changing props with a switch.

I guess it would be much more easy keeping my two matrixes... and dealing with props.visible...
But i like the complicated way, i guess :sweat_smile: So... i'll keep trying...

props.preArgs=[10,@{'this'}]

This only works because for some reason @{'this'} is ignored and removed by the matrix, it makes no sense to write it here.

Ok.

So i focussed on prop.script, and with this :

props.address = "/control"
props.target="midi:OSC"
props.script= "if(get('switch_VST1')==1)"
+"{if(value) {send('/control',10,"+(28+$)+",127);} else {send('/control', 10, "+(37+$)+",127);}}"
+"else if(get('switch_VST1')==2) {set('Lib_*',0,{sync:false}); send('/control',10,"+(60+$)+",127);}"

That works, and I'm almost right where i wanted to be !

Just... i tried to use backticks to make prop.script more readable, but it didn't work...

visi