I'm trying to figure out since last night how to send a single value from the custom-module in an already generated matrix (fader).
Here I generate my fader matrix in the custom module. So far so good.
receive('/EDIT', 'matrix_cFad_L', {'props': `JS{{
var props ={}
var VARcCC_L_Labels = [` + VARcCC_L + `]
props.colorWidget = "#336699ff"
props.alphaStroke = 1
props.alphaFillOff = 0.25
props.alphaFillOn = 1
props.lineWidth = 10
props.dashed = true
props.knobSize = 40
props.pips = true
props.doubleTap = true
props.css = "font-size: 60%"
props.range = {
"min": 0,
"max": 127
}
props.gradient = {
"0": "darkblue",
"1": "lightblue",
"0.6": "steelblue"
}
props.address = "/control"
props.preArgs = [
1,
VARcCC_L_Labels[$]
]
props.decimals = 0
props.target = "midi:OSC"
props.default = 100
return props
}}`
});
Then I receive new values from my external hardware fader and want to transfer it to the first fader in the matrix.
But, if I do it this way (see example below), it will of course overwrite all the "props".
var ValueFromExternFader = 60
receive('/EDIT', 'matrix_cFad_L', {'props': `JS{{
var props ={}
props.value = ` + ValueFromExternFader + `
return props
}}`
});
How do I have to write the syntax so that I can apply the value (in my case the value 60) directly to the first fader?
Is there a default ID to address the individual faders in the matrix?
Or would I also have to define the ID to be able to address the first fader directly?
What kind of thinking error am I making?
Don't use /EDIT to change a widget's value, simple use its address:
receive('/widget_address', value)
// or, if widget has preArgs
receive('/widget_address', preArg1, preArg2, value)
On a sidenote, you don't need to break backtick quotes (aka template strings) to insert variables:
var x = 2
var str = `I ate ${x} apples today`
(this has nothing to do with osc's advanced syntaxes, it's plain javascript)
The sidenote works great, thanks, never ending learning...
But i have a question about the /widget_address...
is it right if I say the /widget_address is the id?
and if my Matrix Widget (i generate 4 faders) has the id (in my case "matrix_cFad_L")
which id has than my first fader? "matrix_cFad_L0"?
From the props' documentation:
Note: unless overridden, children inherit from the matrix' id
and osc properties (id
and address
are appended with /$
)
In your case the address and preArgs are overidden (props.address
and props.preArgs
), should be something like
receive('/control', 1, CC, 60)
Why do you use /control? I only want to change the value of the first fader in a matrix.
I try like
receive('/matrix_cFad_L[0]',60)
I try several examples in the custom-modul. What do I think wrong?
/control
is the address you gave to the faders in the matrix. Widgets can be controlled using the same messages than the ones they send.
Also,
is it right if I say the /widget_address is the id?
is only true if the address property is not explicitly set (address
defaults to /widget_id
, except for widgets in a matrix, see my previous post). In any case these are two distinct properties.
Hmm... I completely misunderstood the address field. Now I have just made a big step forward again.
Thank you very much for your passionate help.