Matrix of buttons : how to send differents MIDI notes for each button?

I have a matrix of 32 buttons, I would need to make each button to send a different MIDI note.

I use a script for each button inside matrix’s props ;
doc says :

Formulas in this field are resolved with an extra variable representing each widget’s index: $
but I can’t manage to find the way to use $ properly…

for ex I would like to do :
“script”: "send(‘midi:mon_port_midi’, ‘/note’, 1, , value)" (so first button will send note 1, second button note 2, ...) but this doesn't work, and I can't find any example of usage of in matrix props…

please help :confused:

The $ variable is available in JS{{}} and #{} blocks, not in scripts (unless you put such a block in the script, eg #{$}). In the future I’ll probably add a generic way to get a widget’s index from any script (not only in matrices).
In your case though it’s not necessary to use a script, you could simply set these properties in props:

  • target to midi:port
  • address to /note
  • preArgs to [1, #{$}]
1 Like

Thanks for your help

using this code in matrix’s props works fine :

“mode”: “push”,
“on”: 100,
“target”: “midi:mon_port_midi”,
“address”: “/note”,
“preArgs”: [1, #{$+48}]

this one works as well :

“mode”: “push”,
“on”: 100,
“script”: “send(‘midi:mon_port_midi’, ‘/note’, 1, #{$}+48, value)”

As I’m not a JS expert, I’m still very confused by the many syntax subtilities …
but amazed by the endless possibilities !
Having in the doc just one line of code showing how to use $ in matrix props would realy help :innocent:

1 Like

thanks that helped me !